KrasimiraGeorgieva

Draw square_diamant

Feb 2nd, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. n = int(input('Enter number from 1 to 100:'))
  2. print()
  3.  
  4. while (n >= 50):
  5.   for i in range(1, n+1):
  6.     for m in range(1, n+1):
  7.         print('$', end=' ')
  8.     print()
  9.   break
  10. else:  
  11.   if (n == 1):
  12.       print("*")
  13.   elif (n == 2):
  14.       print("**")
  15.   else:
  16.       if (n % 2 == 0):
  17.           pos1, pos2 = n // 2, n // 2 + 1
  18.       else:
  19.           pos1, pos2 = (n + 1) // 2, (n + 1) // 2
  20.       total_row = n - (1 - n % 2)
  21.   for row in range (total_row // 2):
  22.       for col in range (1, n + 1):
  23.           if (col == pos1 or col == pos2):
  24.               print('*', end='')
  25.           else:
  26.               print('-', end='')
  27.       print()
  28.       pos1 -= 1
  29.       pos2 += 1
  30.    
  31.   for row in range (total_row - total_row // 2):
  32.       for col in range (1, n + 1):
  33.           if (col == pos1 or col == pos2):
  34.               print('*', end='')
  35.           else:
  36.               print('-', end='')
  37.       print()
  38.       pos1 += 1
  39.       pos2 -= 1
Advertisement
Add Comment
Please, Sign In to add comment