Advertisement
earlution

Multiple balloons

May 15th, 2020
1,134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. import turtle
  2. bob = turtle.Turtle()
  3.  
  4. bob.left(90) # to point Turtle up
  5. bob.left(45) # to go to the left so I can have a spread of balloons
  6. balloon_colours = ["Red", "Blue", "Green", "Purple", "Orange"]
  7.  
  8. for i in range(5): # i represents each iteration
  9.   bob.right(15) # Offset by 15° so we can get a spread of balloons
  10.   bob.pencolor("black") # Sets the colour of the string
  11.   bob.forward(150) # Sets the length of the string
  12.   bob.pencolor(balloon_colours[i]) # Set the colour of the balloon, I can use i to pick a different colour from the list
  13.   bob.pensize(60) # This sets the size of the baloon, experiment...
  14.   bob.forward(1) # Draw the balloon
  15.   bob.pensize(1) # Reset the the pensize
  16.   bob.penup()
  17.   bob.backward(151) # Return Turtle to starting position
  18.   bob.pendown()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement