Advertisement
furas

Python - draw steps - (Stackoverflow)

Aug 6th, 2020 (edited)
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. # https://stackoverflow.com/questions/63289079/how-to-draw-steps-in-python
  2.  
  3. # --- functions ---
  4.  
  5. def get_info():
  6.     steps  = int(input("How many steps? "))
  7.     height = int(input("Step height? "))
  8.     width  = int(input("Step width? "))
  9.     offset = int(input("Step offset? "))
  10.     return steps, height, width, offset
  11.  
  12. def draw_row(width, offset):
  13.     print('  '*offset, end='')
  14.     print('* '*width, end='')
  15.     print()    
  16.  
  17. def draw_rectangle(height, width, offset):
  18.     for i in range(height):
  19.         draw_row(width, offset)
  20.  
  21. def main():
  22.     steps, height, width, offset = get_info()
  23.     for i in range(steps):
  24.         # every rectangle need differen offset - offset*0, offset*1, offset*2, etc.
  25.         draw_rectangle(height, width, offset*i)
  26.  
  27. # --- start ---
  28.  
  29. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement