0% found this document useful (0 votes)
8 views2 pages

Coding Club Turtle

Uploaded by

bloodscar96
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Coding Club Turtle

Uploaded by

bloodscar96
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Go to: https://pythonsandbox.

com/turtle

1. Run the code in the editor and see what happens!

2. Delete the code in the editor. Copy and paste the following code. This code will
draw a square!

import turtle
t = turtle.Turtle()
t.speed(5)
t.forward(100)
t.right(90) #this rotates turtle 90 degrees
t.forward(100)
t.right(90)
t.forward(100)
t.right(90)
t.forward(100)

3. This code also draws a square. Try replacing the code from step 2. Make sure
that the indentation matches the indentation on this doc.

import turtle
t = turtle.Turtle()
t.speed(5)

#using the “for i in range” lets you repeat what is


indented under it the number of times you say in the
parentheses after range.
for i in range(4):
t.forward(100)
t.right(90)

4. Try changing the code from step 3 to draw a triangle instead of a square.
Triangles have 3 sides, and the turtle has to turn 120 degrees at each turn.
5. You can also draw circles. Try copying and pasting this code.

import turtle
t = turtle.Turtle()
t.speed(5)
t.circle(100, 360) #the first number is the degrees you
want to draw, and the second number is the radius of
the circle.

6. Change the code to draw a half-circle with a radius of 75. What happens if you
make the degrees negative instead of positive?

7. t.color("blue") will change the color of what you are drawing to blue. Try
adding this line somewhere in your code to make your half-circle blue instead of
black.

8. Using what you know, try drawing a purple square with side length 40.

9. t.penup() will let you pick up your turtle and move it without drawing a line. To
put your turtle back down, use t.pendown(). Using what you know, try
drawing 2 circles next to each other.

10. Try copying and pasting this code and seeing what happens. I used the modulo
operator “%” to make the turtle change color based on whether the step “i” was
even or odd.

import turtle
t = turtle.Turtle()
t.speed(5)

for i in range(100):
if i % 2 == 1:
t.color("green")
if i % 2 == 0:
t.color("orange")
t.forward(i)
t.right(30)

11. Try making the spiral different colors! You could also try changing the angle in
t.right to make a “tighter” or “looser” spiral.

You might also like