Advertisement
JkSoftware

Day 18 - Turtle Shapes

Nov 27th, 2021
1,302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. from turtle import Turtle, Screen
  2. import random
  3.  
  4. timmy = Turtle()
  5. timmy.shape("arrow")
  6. timmy.color("black")
  7. colors = ["red", "green", "yellow", "blue", "purple", "magenta", "lime", "gold", "navy", "deep sky blue"]
  8.  
  9.  
  10. def draw_shape(num_sides):
  11.     angel = 360 / num_sides
  12.     for i in range(num_sides):
  13.         timmy.forward(100)
  14.         timmy.right(angel)
  15.  
  16.  
  17. for shape_sides in range(3, 11):
  18.     timmy.color(random.choice(colors))
  19.     draw_shape(shape_sides)
  20.  
  21. screen = Screen()
  22. screen.exitonclick()
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement