Answer to Question #257738 in Python for Pavani

Question #257738

given an integer N as input write a program to print a shaded diamond of 2*N -1 rows using an asterisk(*) .


1
Expert's answer
2021-10-27T16:22:54-0400
N=int(input("Enter N: "))
n = 0
for i in range(1, N + 1):
    for j in range (1, (N - i) + 1):
        print(end = " ")
        
    while n != (2 * i - 1):
        print("*", end = "")
        n = n + 1
    n = 0
        
    print()


k = 1
n = 1
for i in range(1, N):
    for j in range (1, k + 1):
        print(end = " ")
    k = k + 1
        
    while n <= (2 * (N - i) - 1):
        print("*", end = "")
        n = n + 1
    n = 1
    print()



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog