GeeksForGeeks - Company Questions - Pattern Printing.py
Pattern Printing
Problem Statement:
Starting from one print a series of asterisk(*) till N terms with increasing order and difference being 1.
Input:
First line of the input is the number of test cases T. And first line of test case contain the value of 'N'.
First line of the input is the number of test cases T. And first line of test case contain the value of 'N'.
Output:
Series of asterisk's is printed in a single line with one space between each iteration.
Constraints:
1 <=T<= 30
1 <=N<= 100
Series of asterisk's is printed in a single line with one space between each iteration.
Constraints:
1 <=T<= 30
1 <=N<= 100
Example:
Input:
5
1
10
5
6
2
Output:
*
* ** *** **** ***** ****** ******* ******** ********* **********
* ** *** **** *****
* ** *** **** ***** ******
* **
Solution:
Language: Python
#code
k = "*"
n = input()
while(n>0):
n-=1
L = []
temp = input()
#print temp
for j in range(0,temp):
#print j
L.append(k*(j+1))
print " ".join(L)
Comments
Post a Comment