Answer to Question #233902 in Python for kaavya

Question #233902

W pattern with *

Write a program to print W pattern of N lines using an asterisk(*) character as shown below.

Note: There is a space after each asterisk * character.

Input

The first line is an integer N.

Explanation

For

N = 5The output should be


* * * * * * * * *

* * * * * * * *

* * * * * *

* * * *

* *


Sample Input 1

5

Sample Output 1

* * * * * * * * *

* * * * * * * *

* * * * * *

* * * *

* *

Sample Input 2

4

Sample Output 2

* * * * * * *

* * * * * *

* * * *

* *




1
Expert's answer
2021-09-06T23:57:37-0400
n = int(input('Enter integer here: '))
s = (2 * n) - 1
s1 = s - 1
s2 = s1 - 2
n2 = n - 2
print('* ' * s)
print('* ' * s1)
while n2 > 0:
  print('* ' * s2)
  s2 = s2 - 2
  n2 = n2 - 1

Enter integer here: 4
* * * * * * * 
* * * * * * 
* * * * 
* *

Enter integer here: 5
* * * * * * * * * 
* * * * * * * * 
* * * * * * 
* * * * 
* * 

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