Answer to Question #242398 in Python for saras

Question #242398

Given an integer N, write a program to print pattern "8" in (2*N + 1) rows and N columns, similar to the pattern shown below

* * * * * 
*       * 
*       * 
*       * 
*       * 
* * * * * 
*       * 
*       * 
*       * 
*       * 
* * * * * 




1
Expert's answer
2021-09-27T01:54:48-0400
columns = int(input("Enter a number of columns: "))
rows = 2*columns + 1
for row in range(rows):
  if row == 0 or row == rows - 1 or row == (rows - 1)/2:
    print(columns*"*")
  else:
    print()
    print("*"+" "*(columns-2)+"*")


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