Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.21 KB | None | 0 0
  1. ## Author: Jacob Christian
  2. ## Date: 02/21/2018
  3. print('This program draws parallelograms')
  4. width = int(input('How wide would you like '+                #Grabs width
  5.               'the parallelogram (from 10-300)? '))
  6. while True:
  7.     if width < 10 or width > 300:
  8.         width = int(input('Number out of range. '+           #Validation Check
  9.                           'Please re-enter your width. ' ))  #for width
  10.     else:
  11.         break
  12. height = int(input('How tall would you like '+               #Grabs height
  13.               'the parallelogram (from 10-300)? '))    
  14. while True:    
  15.     if height < 10 or height > 300:
  16.         height = int(input('Number out of range. '+          #Validation Check
  17.                            'Please re-enter your width. ' )) #for height
  18.     else:
  19.         break
  20.    
  21. print('What angle would you like (from 1-179)? ')            #Grabs angle    
  22. print('(Note: Your angle input will be the angle on the '+
  23.       'bottom left and top right)')
  24. angle_a = int(input(''))
  25.  
  26. while True:
  27.     if angle_a < 1 or angle_a > 179:
  28.         angle_a = int(input('Number out of range. '+         #Validation Check
  29.                             'Please re-enter your angle. ')) #for angle
  30.     elif angle_a == 90:
  31.         angle_a = int(input('That makes a box. '+
  32.                             'Please re-enter your angle. ')) #Box check
  33.     else:
  34.         break
  35. angle_b = 180-angle_a                                        #converts adjacent
  36.                                                              #angle
  37. import turtle
  38. turtle.hideturtle()
  39. turtle.penup()                                               #removes line draw
  40. turtle.setposition(-200,0)                                   #Sets head
  41. turtle.pendown()                                             #adds line draw
  42. #loops to make 2 passes
  43. for i in range(2):                                          
  44.     turtle.forward(width)                                    #moves (width)                                  
  45.     turtle.left(angle_a)                                     #shifts angle
  46.     turtle.forward(height)                                   #moves (height)
  47.     turtle.left(angle_b)                                     #shifts 180 - angle
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement