Answer to Question #220763 in Python for SARIKONDA BALA BHA

Question #220763

Digit 9

You are given

N as input. Write a program to print the pattern of 2*N - 1 rows using an asterisk(*) as shown below.Note: There is a space after each asterisk * character.Input

The first line of input is an integer

N.Explanation

In the given example,

N = 4.So, the output should be


* * * *

* *

* *

* * * *

*

*

* * * *


Sample Input 1

4

Sample Output 1

* * * *

* *

* *

* * * *

*

*

* * * *




1
Expert's answer
2021-07-27T07:43:27-0400
N=int(input())
rows=2*N - 1
for r in range(0,rows):
    for c in range(0,N):
        if r>0 and r<rows-1 and r!=N-1:
            if c>0 and c<N-1:
                print("  ",end=" ")
            else:
                if r>=N and r<rows-1 and c==0:
                    print("  ",end=" ")
                else:
                    print("* ",end=" ")
        else:
            print("* ",end=" ")
    print("\n")







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