Answer to Question #267477 in Python for taufiq umar

Question #267477

given a integer valun N as input, write a program to print a shaded diamond of 2*N-1 rows using astherisk(*) character..


1
Expert's answer
2021-11-17T12:03:09-0500
n = int(input('Enter N: '))
print(' ' * (n - 1) + '*' + ' ' * (n - 1))
for i in range(1, n - 1):
    print(' ' * (n - i - 1) + '*' + ' ' * (2 * i - 1) + '*' + ' ' * (n - i - 1))
print('*' + ' ' * (2 * (n - 1) - 1) + '*')
for i in range(-n + 2, 0):
    print(' ' * (n - -i - 1) + '*' + ' ' * (2 * -i - 1) + '*' + ' ' * (n - -i - 1))
print(' ' * (n - 1) + '*' + ' ' * (n - 1))

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
APPROVED BY CLIENTS