Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #Input
  2.  
  3. box_size=int(input("Enter square size:"))
  4.  
  5. if (box_size % 2) == 0:
  6. box_size=int(box_size)
  7. for row in range(box_size,0,-1):
  8. for col in range(row):
  9. print('*'*row*2,end='')
  10. print()
  11. print()
  12.  
  13. else:
  14. inner_size = box_size - 2
  15. print ('*' * box_size)
  16. for i in range(inner_size,0,-1):
  17. print ('*' + ' ' * inner_size + '*')
  18. print ('*' * box_size)
  19. print()
  20.  
  21. #Output for even
  22.  
  23. Enter square size:6
  24. ************
  25. ************
  26. ************
  27. ************
  28. ************
  29. ************
  30.  
  31. **********
  32. **********
  33. **********
  34. **********
  35. **********
  36.  
  37. ********
  38. ********
  39. ********
  40. ********
  41.  
  42. ******
  43. ******
  44. ******
  45.  
  46. ****
  47. ****
  48.  
  49. **
  50.  
  51. #Output for odd
  52.  
  53. Enter square size:5
  54. *****
  55. * *
  56. *****
  57. * *
  58. *****
  59. * *
  60. *****
  61.  
  62. #The odd output seems to be missing some *
  63. #and there's no spaces between them. Each box is
  64. #supposed be smaller than the last till it reaches zero.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement