Advertisement
Arcot

ch3 ex3

Oct 23rd, 2022
993
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. from turtle import *
  2.  
  3. t=Turtle()
  4.  
  5. answer=input("choose which shape to draw: circle, polygon or star")
  6.  
  7. if answer=="circle":
  8.   radius=int(input("Enter radius of circle"))
  9.   t.circle(radius)
  10. elif answer=="polygon":
  11.   sides=int(input("How many sides do you want in polygon"))
  12.   length=int(input("What length should each side be"))
  13.   angle=360/sides
  14.   for i in range(sides):
  15.     t.forward(length)
  16.     t.right(angle)
  17. elif answer=="star":
  18.   sides=int(input("How many sides do you want in star"))
  19.   length=int(input("What length should each side be"))
  20.   angle=180-(180/sides)
  21.   for i in range(sides):
  22.     t.forward(length)
  23.     t.right(angle)
  24. else:
  25.   print("invalid input")
  26.  
  27. done()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement