Computer Science
Answer
n = 3 # number of rows
# upper half
for i in range(n) :
for j in range(n, i+1, -1) :
print(' ', end = '')
for k in range(i+1) :
print('*', end = ' ')
print()
# lower half
for i in range(n-1) :
for j in range(i + 1) :
print(' ', end = '')
for k in range(n-1, i, -1) :
print('*', end = ' ')
print()
Output
*
* *
* * *
* *
*
Related Questions
Write programs to print the following shapes:
*
* *
* * *
* *
*Write programs to print the following shapes:
*
* *
* *
* *
*Write programs to find the sum of the following series:
x + x2/2 + x3/3 + …… + xn/n (Input x and n both)
Write programs to find the sum of the following series:
x - x2/2! + x3/3! - x4/4! + x5/5! - x6/6! (Input x)