Answer to Question #221748 in Python for Hari nadh babu

Question #221748

Shaded Diamond


This Program name is Shaded Diamond. Write a Python program to Shaded Diamond



The below link contains Shaded Diamond question, explanation and test cases



https://drive.google.com/file/d/19tuGOTP2lO8EK2sIw1lela2W6qdK0lwY/view?usp=sharing



We need exact output when the code was run

1
Expert's answer
2021-08-02T07:16:45-0400
N = int(input())
diamond = []
for i in range(1, N + 1):
    line = ' '.join(['*' for x in range(i)])
    diamond.append(line.center(2 * N, ' ')) 
for i in range(N - 1, 0, -1):
    line = '*' + ' '.join([' ' for x in range(i - 1)]) + '*'
    if i == 1:
        line = line[::-2]
    diamond.append(line.center(2 * N, ' '))
print('\n'.join(diamond))

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