Answer to Question #301684 in Python for sruthi

Question #301684

Enter integer here: 5

. . . . 0 . . . .

. . . 0 0 0 . . .

. . 0 0 0 0 0 . .

. 0 0 0 0 0 0 0 .

0 0 0 0 0 0 0 0 0

. 0 0 0 0 0 0 0 .

. . 0 0 0 0 0 . .

. . . 0 0 0 . . .

. . . . 0 . . . .


can i get code for this please,

using for loop


1
Expert's answer
2022-02-24T04:19:49-0500
n = 11

if n%2 == 1:
    for i in range(1,n,2):
        i = '.' * ((n-i)//2)  + '0' *i + '.' * ((n-i)//2)
        print (i)
    for i in range(n,0,-2):
        i = '.' * ((n-i)//2)  + '0' *i + '.' * ((n-i)//2)
        print (i)

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