Sign InNuggetsCoursesCodePadCheatsheet

Archery Target

With the help of a loop, simulate an archery target. Use a variable to hold the initial radius.

import turtle import random circles = 5 radius = 20 delta = 20 size =20 for i in range(circles): t = turtle.Turtle() t.speed(50) t.pensize(size) t.color(random.randrange(256), random.randrange(256), random.randrange(256)) t.up() t.right(90) t.forward(i*delta) t.left(90) t.down() t.circle(radius + i*delta) t.hideturtle()

Now it's your turn. Fill in the missing pieces below to align the circles!

import turtle import random circles = 5 radius = 20 delta = 20 size =20 for i in range(circles): t = turtle.Turtle() t.speed(50) t.pensize(size) t.color(random.randrange(256), random.randrange(256), random.randrange(256)) t.up() # fill in here # fill in here # fill in here t.down() t.circle(radius + i*delta) t.hideturtle()
© CS Wonders·Home·About·Contact·Classes·Gallery·Glossary·Fun Facts