This task is part of project10 which is due at 23:00 EST on 2025-11-18.
You have the option to work with a partner on this task if you wish. Working with a partner requires more work to coordinate schedules, but if you work together and make sure that you are both understanding the code you write, you will make progress faster and learn more.
You can download the starter code for this task using this link.
You can submit this task using this link.
Put all of your work for this task into the file
recursiveCircles.py
(you will create this file from scratch)
This task and the recursiveScales task are very similar. This task is graphics-oriented and works with turtle graphics, while the recursive scales task is based on audio and music instead. You may choose to do either task but you do not need to do both.
In this task, you will create a file named recursiveCircles.py and
write functions concentricCircles and colorListCircles.
concentricCircles does the exact same thing the function of the same
name from the circles task, while colorListCircles is a
new function that is similar to multicolorCircles from that task, but
not as complex. However, for this task, you are not allowed to use any
loops, and must use recursion instead.
concentricCirclesThe concentricCircles
function should draw exactly
same pattern as the concentricCircles function from the earlier
circles task. The only
difference is how it draws the pattern: you are not allowed to
use any loops, and you
must instead use
recursion
instead.
These concentricCircles examples show how
the function should work, and we have provided a
test_recursiveCircles.py file which will test your results using
optimism.
As a reminder, here is the specification for concentricCircles
function:
We will test both how many circles are drawn as well as whether the correct circles are drawn in the correct order.
Hint: Each function call frame only needs to draw a single circle.
Note that you must use the turtleBeads
drawDot
function to draw each circle.
As an extra goal, your function should call drawDot in only one
place, and
should only contain one recursive
call.
colorListCirclesThe colorListCircles function
must draw concentric circles using colors from a
list. It has two parameters:
the first specifies the radius of the largest circle, and the second
is a list of colors. The number of concentric circles drawn is the length
of the list, and these circles are colored, from largest to smallest, by
the colors in the list from first to last. When viewed as nested rings,
all rings should have the same thickness. If the list is empty, nothing
should be drawn.
These colorListCircles examples show how
colorListCircles should work.
We will test both how many circles are
drawn as well as whether the
correct circles are drawn in the correct
order. As in concentricCircles, you may not
use any loops and you must
use recursion.
Also, you will still need to use
drawDot.
As an extra goal, your function should call drawDot in only one
place, and should
only contain one recursive
call.
concentricCircles examples
These examples show how concentricCircles works. Note that the
outerColor is always used for the outermost circle, whether there are
an odd or even number of circles. Accordingly, the otherColor is NOT
always used for the innermost circle: that depends on the total number of
circles.
In []:PrintsconcentricCircles(180, 3, 'HotPink', 'LightSkyBlue1')A HotPink dot at (0, 0) with radius 180 A LightSkyBlue1 dot at (0, 0) with radius 120 A HotPink dot at (0, 0) with radius 60ImageIn []:
PrintsconcentricCircles(190, 4, 'LightSalmon2', 'Khaki1')A LightSalmon2 dot at (0, 0) with radius 190 A Khaki1 dot at (0, 0) with radius 142 A LightSalmon2 dot at (0, 0) with radius 95 A Khaki1 dot at (0, 0) with radius 48ImageIn []:
PrintsconcentricCircles(140, 7, 'Gold', 'DeepSkyBlue')A Gold dot at (0, 0) with radius 140 A DeepSkyBlue dot at (0, 0) with radius 120 A Gold dot at (0, 0) with radius 100 A DeepSkyBlue dot at (0, 0) with radius 80 A Gold dot at (0, 0) with radius 60 A DeepSkyBlue dot at (0, 0) with radius 40 A Gold dot at (0, 0) with radius 20Image
colorListCircles examples
These examples show how colorListCircles works. The first color in the
list is used for the outermost circle. Unlike the previous
multicolorCircles task, colors are not repeated: each color from the
list is used for one circle.
In []:PrintscolorListCircles(160, ['black', 'blue', 'red', 'yellow'])A black dot at (0, 0) with radius 160 A blue dot at (0, 0) with radius 120 A red dot at (0, 0) with radius 80 A yellow dot at (0, 0) with radius 40ImageIn []:
PrintscolorListCircles( 180, ['red', 'orange', 'yellow', 'green', 'blue', 'navy', 'purple3'] )A red dot at (0, 0) with radius 180 A orange dot at (0, 0) with radius 154 A yellow dot at (0, 0) with radius 129 A green dot at (0, 0) with radius 103 A blue dot at (0, 0) with radius 77 A navy dot at (0, 0) with radius 51 A purple3 dot at (0, 0) with radius 26ImageIn []:
PrintscolorListCircles( 150, [ 'Aquamarine2', 'Khaki2', 'LimeGreen', 'Aquamarine2', 'Khaki2', 'LimeGreen', 'Aquamarine2', 'Khaki2', 'LimeGreen', 'Aquamarine2', 'Khaki2', 'LimeGreen', 'Aquamarine2', 'Khaki2', 'LimeGreen', ] )A Aquamarine2 dot at (0, 0) with radius 150 A Khaki2 dot at (0, 0) with radius 140 A LimeGreen dot at (0, 0) with radius 130 A Aquamarine2 dot at (0, 0) with radius 120 A Khaki2 dot at (0, 0) with radius 110 A LimeGreen dot at (0, 0) with radius 100 A Aquamarine2 dot at (0, 0) with radius 90 A Khaki2 dot at (0, 0) with radius 80 A LimeGreen dot at (0, 0) with radius 70 A Aquamarine2 dot at (0, 0) with radius 60 A Khaki2 dot at (0, 0) with radius 50 A LimeGreen dot at (0, 0) with radius 40 A Aquamarine2 dot at (0, 0) with radius 30 A Khaki2 dot at (0, 0) with radius 20 A LimeGreen dot at (0, 0) with radius 10Image
test result
This example shows what the result of the provided test file should look
like once both concentricCircles and colorListCircles are working.
In []:Imageimport test_recursiveCircles
= or by defining a parameter for a function) you must also later use that variable as part of another expression. If you need to create a variable that you won't use, it must have the name _, but you should only do this if absolutely necessary.concentricCircles must make the correct number of calls to drawDot
concentricCircles function must call drawDot the correct number of times.concentricCircles must make the correct function calls
concentricCircles function must call the drawDot function in the correct order, with the correct arguments, while the correct position and pen_color values are set upcolorListCircles must make the correct number of calls to drawDot
colorListCircles function must call drawDot the correct number of times.colorListCircles must make the correct function calls
colorListCircles function must call the drawDot function in the correct order, with the correct arguments, while the correct position and pen_color values are set upconcentricCircles must draw the correct image
concentricCircles is called must match the solution image.colorListCircles must draw the correct image
colorListCircles is called must match the solution image.concentricCircles with 4 parameters
def to define concentricCircles with 4 parametersdrawDot
concentricCircles with 4 parameters, call drawDot in exactly one place.concentricCircles
concentricCircles with 4 parameters, call concentricCircles in exactly one place.concentricCircles with 4 parameters
def to define concentricCircles with 4 parametersconcentricCircles with 4 parameters, do not use any kind of loop.concentricCircles with 4 parameters, use an if statement (possibly accompanied by an elif or else block) in at least one place.drawDot
concentricCircles with 4 parameters, call drawDot in at least one place.concentricCircles
concentricCircles with 4 parameters, call concentricCircles in at least one place.colorListCircles with 2 parameters
def to define colorListCircles with 2 parametersdrawDot
colorListCircles with 2 parameters, call drawDot in exactly one place.colorListCircles
colorListCircles with 2 parameters, call colorListCircles in exactly one place.colorListCircles with 2 parameters
def to define colorListCircles with 2 parameterscolorListCircles with 2 parameters, do not use any kind of loop.colorListCircles with 2 parameters, use an if statement (possibly accompanied by an elif or else block) in at least one place.drawDot
colorListCircles with 2 parameters, call drawDot in at least one place.colorListCircles
colorListCircles with 2 parameters, call colorListCircles in at least one place.