Instructions for recursiveCircles

(produced at 00:54 a.m. UTC on 2024-11-13)

This task is part of project10 which is due at 23:00 EST on 2024-11-19.

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.

Part A: concentricCircles

The 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:

  1. It draws a series of concentric circles, where the first parameter specifies the radius of the outermost circle, and the second parameter specifies the number of circles to draw. When viewed as nested rings, all rings should have the same thickness.
  2. The third and fourth parameters specify an outer color and an other color, respectively. The outer color is used for the outermost circle, and then every other circle in from the edge alternates between that color and the other color.

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.

Part B: colorListCircles

The 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.

Notes

Examples

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 []:
concentricCircles(180, 3, 'HotPink', 'LightSkyBlue1')
Prints
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 60
Image 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 60
In []:
concentricCircles(190, 4, 'LightSalmon2', 'Khaki1')
Prints
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 48
Image 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 48
In []:
concentricCircles(140, 7, 'Gold', 'DeepSkyBlue')
Prints
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 20
Image 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 20

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 []:
colorListCircles(160, ['black', 'blue', 'red', 'yellow'])
Prints
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 40
Image 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 40
In []:
colorListCircles( 180, ['red', 'orange', 'yellow', 'green', 'blue', 'navy', 'purple3'] )
Prints
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 26
Image 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 26
In []:
colorListCircles( 150, [ 'Aquamarine2', 'Khaki2', 'LimeGreen', 'Aquamarine2', 'Khaki2', 'LimeGreen', 'Aquamarine2', 'Khaki2', 'LimeGreen', 'Aquamarine2', 'Khaki2', 'LimeGreen', 'Aquamarine2', 'Khaki2', 'LimeGreen', ] )
Prints
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 10
Image 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 10

test result

This example shows what the result of the provided test file should look like once both concentricCircles and colorListCircles are working.

In []:
import test_recursiveCircles
Image

Rubric

Group goals:
 
unknown Do not ignore the results of any fruitful function calls
According to the "Don't waste fruit" principle, every place you call a fruitful function (built-in or custom) you must store the result in a variable, or that function call must be part of a larger expression that uses its return value.
 
unknown Do not create any variables that you never make use of
According to the "Don't waste boxes" principle, every time you create a variable (using = 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.
 
unknown All functions are documented
Each function you define must include a non-empty documentation string as the very first thing in the function.
 
unknown concentricCircles must make the correct number of calls to drawDot
Your concentricCircles function must call drawDot the correct number of times.
 
unknown concentricCircles must make the correct function calls
Your 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 up
 
unknown colorListCircles must make the correct number of calls to drawDot
Your colorListCircles function must call drawDot the correct number of times.
 
unknown colorListCircles must make the correct function calls
Your 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 up
 
unknown concentricCircles must draw the correct image
The image drawn in the turtle window after concentricCircles is called must match the solution image.
 
unknown colorListCircles must draw the correct image
The image drawn in the turtle window after colorListCircles is called must match the solution image.
 
unknown Define concentricCircles with 4 parameters
Use def to define concentricCircles with 4 parameters
 
unknown Do not use any kind of loop
Within the definition of concentricCircles with 4 parameters, do not use any kind of loop.
 
unknown Use a conditional
Within the definition of concentricCircles with 4 parameters, use an if statement (possibly accompanied by an elif or else block) in at least one place.
 
unknown Call drawDot
Within the definition of concentricCircles with 4 parameters, call drawDot in at least one place.
 
unknown Call concentricCircles
Within the definition of concentricCircles with 4 parameters, call concentricCircles in at least one place.
 
unknown Define concentricCircles with 4 parameters
Use def to define concentricCircles with 4 parameters
 
unknown Call drawDot
Within the definition of concentricCircles with 4 parameters, call drawDot in exactly one place.
 
unknown Call concentricCircles
Within the definition of concentricCircles with 4 parameters, call concentricCircles in exactly one place.
 
unknown Define colorListCircles with 2 parameters
Use def to define colorListCircles with 2 parameters
 
unknown Do not use any kind of loop
Within the definition of colorListCircles with 2 parameters, do not use any kind of loop.
 
unknown Use a conditional
Within the definition of colorListCircles with 2 parameters, use an if statement (possibly accompanied by an elif or else block) in at least one place.
 
unknown Call drawDot
Within the definition of colorListCircles with 2 parameters, call drawDot in at least one place.
 
unknown Call colorListCircles
Within the definition of colorListCircles with 2 parameters, call colorListCircles in at least one place.
 
unknown Define colorListCircles with 2 parameters
Use def to define colorListCircles with 2 parameters
 
unknown Call drawDot
Within the definition of colorListCircles with 2 parameters, call drawDot in exactly one place.
 
unknown Call colorListCircles
Within the definition of colorListCircles with 2 parameters, call colorListCircles in exactly one place.