Instructions for circles

(produced at 01:04 a.m. UTC on 2024-10-16)

This task is part of project06 which is due at 23:00 EDT on 2024-10-22.

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 circles.py
(you will create this file from scratch)

This project is very similar the scales task which uses wavesynth to generate audio instead of turtle to make pictures. You only have to do one of the two (but you must do audioToolkit).

In this task you will define the following functions:

  • concentricCircles
  • multicolorCircles
  • circleDesign

Your circles.py file should begin with this header, which you should paste into the file and fill out (as usual, each function you write must be documented):

"""
Authors:
Consulted:
Date:
Purpose: CS 111 circles task: draws concentric circles in alternating
colors.
"""
You will need to import turtle and turtleBeads by putting the following lines at the beginning of your code (import turtleBeads first so that the beLoud print statements will work correctly):

from turtleBeads import *
from turtle import *

Part A: concentricCircles

In this subtask, your goal is to generate pictures like those shown in these examples for concentricCircles, consisting of multiple concentric circles of alternating colors that form a bullseye pattern.

Define the concentricCircles function such that:

  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.
  2. The third and fourth parameters specify an outer color and an other color, respectively. The outer color is used for the largest (i.e., outermost) circle, and then every other circle in from the edge alternates between that color and the 'other' color.
  3. All rings have the same thickness, and the radius of the innermost circle is equal to that thickness. Put another way, the radius of each circle is a multiple of the radius of the innermost dot. For example if the total radius is 100 and there are 4 circles, their radii will be 25, 50, 75, and 100.

Notes

  • Read the rules above carefully, to determine how to calculate the radius of the largest and smallest circles, as well as every radius in between.
  • The "outer" color is always used to color the outermost circle.
  • You must use either a for loop or a while loop to draw the circles.
  • The order in which the circles are drawn matters, because whatever is drawn later covers stuff drawn earlier.
  • For this function, we recommend that you create an iteration table (see the lecture on list processing patterns) to plan out your strategy for solving it.
  • You must use the turtleBeads drawDot function (reference for drawDot) to draw your circles, rather than using the turtle circle function or the turtleBeads drawCircle function, because we will grade based on whether your calls to drawDot are correct. drawDot works just like drawCircle, except that it is much faster, the circle it draws is always filled in, and it uses the pen color, not the fill color (this also means you don't need to call begin_fill and end_fill).

Testing

You can test your concentricCircles function by executing the example code in the shell. We recommend using noTrace beforehand and showPicture afterwards to speed things up. We have also supplied a test_circles.py file which draws four circles and uses optimism to check that the printed output is correct.

Part B: multicolorCircles

For this part, you will create a multicolorCircles function which uses a (possibly nested) loop to draw concentric circles using an arbitrary number of colors. These multicolorCircles examples show how it should work.

multicolorCircles must accept 3 parameters:

  1. A base radius, which will be the radius of the smallest circle (this is different from concentricCircles above). The second-smallest circle will have twice this radius, the third-smallest three times this radius, and so on.
  2. A list of strings indicating colors to use in succession, starting from the outermost circle.
  3. A positive integer specifying the number of cycles to complete, where a single cycle involves using each color from the list of colors once.

Notes

  • Because each cycle uses every color from the list, the total number of circles will be equal to the length of the colors list times the number of cycles. You may assume that the cycles argument will always be an integer, which implies that every multicolored circle pattern will have one or more complete copies of the color cycle, never partial copies.
  • Whereas for concentricCircles you were given the outermost radius as an argument, in multicolorCircles you are given the innermost radius. This value is also the difference between the radii of each successive circle, so for example, if the value was 10 and there were 3 circles, their radii would be 10, 20, and 30.
  • There are multiple viable approaches to this problem, including two loops after each other, just one loop, or two loops inside each other.
  • As with concentricCircles, you must use the turtleBeads drawDot function to draw your circles, rather than using the turtle circle function or the turtleBeads drawCircle function, because we will grade based on whether your calls to drawDot are correct.

Part C: circleDesign

For this last part, get creative. Make a function named circleDesign with zero parameters which uses concentricCircles and/or multicolorCircles within some kind of loop, to create a custom design. This example design gives a taste of the kinds of things you could do.

The only requirements are that:

  1. Your function has no parameters.
  2. Your function doesn't crash or enter an infinite loop.
  3. It contains a loop, and inside of that loop it calls concentricCircles and/or multicolorCircles.

You can have it draw whatever design you wish to create, we are not grading based on what gets drawn.

Examples

concentricCircles examples

These examples show what should be drawn when concentricCircles is called. Note that the turtle does not need to move from the starting position at all. Also note that the printed output rounds of the radii to make them easier to read, but the actual radii are not rounded; you should NOT use the 'round' function in your code.

In []:
concentricCircles(60, 3, 'HotPink', 'LightSkyBlue1')
Prints
A HotPink dot at (0, 0) with radius 60 A LightSkyBlue1 dot at (0, 0) with radius 40 A HotPink dot at (0, 0) with radius 20
Image A HotPink dot at (0, 0) with radius 60
A LightSkyBlue1 dot at (0, 0) with radius 40
A HotPink dot at (0, 0) with radius 20
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

multicolorCircles examples

These examples show what should be drawn when multicolorCircles is called. Note that the turtle does not need to move from the starting position at all. Also note that the printed output rounds of the radii to make them easier to read, but the actual radii are not rounded; you should NOT use the 'round' function in your code.

In []:
multicolorCircles(16, ['black', 'blue', 'red', 'yellow'], 1)
Prints
A black dot at (0, 0) with radius 64 A blue dot at (0, 0) with radius 48 A red dot at (0, 0) with radius 32 A yellow dot at (0, 0) with radius 16
Image A black dot at (0, 0) with radius 64
A blue dot at (0, 0) with radius 48
A red dot at (0, 0) with radius 32
A yellow dot at (0, 0) with radius 16
In []:
multicolorCircles( 12, ['red', 'orange', 'yellow', 'green', 'blue', 'navy', 'purple3'], 2 )
Prints
A red dot at (0, 0) with radius 168 A orange dot at (0, 0) with radius 156 A yellow dot at (0, 0) with radius 144 A green dot at (0, 0) with radius 132 A blue dot at (0, 0) with radius 120 A navy dot at (0, 0) with radius 108 A purple3 dot at (0, 0) with radius 96 A red dot at (0, 0) with radius 84 A orange dot at (0, 0) with radius 72 A yellow dot at (0, 0) with radius 60 A green dot at (0, 0) with radius 48 A blue dot at (0, 0) with radius 36 A navy dot at (0, 0) with radius 24 A purple3 dot at (0, 0) with radius 12
Image A red dot at (0, 0) with radius 168
A orange dot at (0, 0) with radius 156
A yellow dot at (0, 0) with radius 144
A green dot at (0, 0) with radius 132
A blue dot at (0, 0) with radius 120
A navy dot at (0, 0) with radius 108
A purple3 dot at (0, 0) with radius 96
A red dot at (0, 0) with radius 84
A orange dot at (0, 0) with radius 72
A yellow dot at (0, 0) with radius 60
A green dot at (0, 0) with radius 48
A blue dot at (0, 0) with radius 36
A navy dot at (0, 0) with radius 24
A purple3 dot at (0, 0) with radius 12
In []:
multicolorCircles(4, ['Aquamarine2', 'Khaki2', 'LimeGreen'], 12)
Prints
A Aquamarine2 dot at (0, 0) with radius 144 A Khaki2 dot at (0, 0) with radius 140 A LimeGreen dot at (0, 0) with radius 136 A Aquamarine2 dot at (0, 0) with radius 132 A Khaki2 dot at (0, 0) with radius 128 A LimeGreen dot at (0, 0) with radius 124 A Aquamarine2 dot at (0, 0) with radius 120 A Khaki2 dot at (0, 0) with radius 116 A LimeGreen dot at (0, 0) with radius 112 A Aquamarine2 dot at (0, 0) with radius 108 A Khaki2 dot at (0, 0) with radius 104 A LimeGreen dot at (0, 0) with radius 100 A Aquamarine2 dot at (0, 0) with radius 96 A Khaki2 dot at (0, 0) with radius 92 A LimeGreen dot at (0, 0) with radius 88 A Aquamarine2 dot at (0, 0) with radius 84 A Khaki2 dot at (0, 0) with radius 80 A LimeGreen dot at (0, 0) with radius 76 A Aquamarine2 dot at (0, 0) with radius 72 A Khaki2 dot at (0, 0) with radius 68 A LimeGreen dot at (0, 0) with radius 64 A Aquamarine2 dot at (0, 0) with radius 60 A Khaki2 dot at (0, 0) with radius 56 A LimeGreen dot at (0, 0) with radius 52 A Aquamarine2 dot at (0, 0) with radius 48 A Khaki2 dot at (0, 0) with radius 44 A LimeGreen dot at (0, 0) with radius 40 A Aquamarine2 dot at (0, 0) with radius 36 A Khaki2 dot at (0, 0) with radius 32 A LimeGreen dot at (0, 0) with radius 28 A Aquamarine2 dot at (0, 0) with radius 24 A Khaki2 dot at (0, 0) with radius 20 A LimeGreen dot at (0, 0) with radius 16 A Aquamarine2 dot at (0, 0) with radius 12 A Khaki2 dot at (0, 0) with radius 8 A LimeGreen dot at (0, 0) with radius 4
Image A Aquamarine2 dot at (0, 0) with radius 144
A Khaki2 dot at (0, 0) with radius 140
A LimeGreen dot at (0, 0) with radius 136
A Aquamarine2 dot at (0, 0) with radius 132
A Khaki2 dot at (0, 0) with radius 128
A LimeGreen dot at (0, 0) with radius 124
A Aquamarine2 dot at (0, 0) with radius 120
A Khaki2 dot at (0, 0) with radius 116
A LimeGreen dot at (0, 0) with radius 112
A Aquamarine2 dot at (0, 0) with radius 108
A Khaki2 dot at (0, 0) with radius 104
A LimeGreen dot at (0, 0) with radius 100
A Aquamarine2 dot at (0, 0) with radius 96
A Khaki2 dot at (0, 0) with radius 92
A LimeGreen dot at (0, 0) with radius 88
A Aquamarine2 dot at (0, 0) with radius 84
A Khaki2 dot at (0, 0) with radius 80
A LimeGreen dot at (0, 0) with radius 76
A Aquamarine2 dot at (0, 0) with radius 72
A Khaki2 dot at (0, 0) with radius 68
A LimeGreen dot at (0, 0) with radius 64
A Aquamarine2 dot at (0, 0) with radius 60
A Khaki2 dot at (0, 0) with radius 56
A LimeGreen dot at (0, 0) with radius 52
A Aquamarine2 dot at (0, 0) with radius 48
A Khaki2 dot at (0, 0) with radius 44
A LimeGreen dot at (0, 0) with radius 40
A Aquamarine2 dot at (0, 0) with radius 36
A Khaki2 dot at (0, 0) with radius 32
A LimeGreen dot at (0, 0) with radius 28
A Aquamarine2 dot at (0, 0) with radius 24
A Khaki2 dot at (0, 0) with radius 20
A LimeGreen dot at (0, 0) with radius 16
A Aquamarine2 dot at (0, 0) with radius 12
A Khaki2 dot at (0, 0) with radius 8
A LimeGreen dot at (0, 0) with radius 4

circleDesign example

This example shows one kind of design you could create out of concentric circles for the circleDesign function. Note that the function must not have any parameters, but beyond testing that it doesn't crash, we don't care exactly what it draws, so you DO NOT have to create this exact pattern.

In []:
circleDesign()
Prints
A pattern of overlapping bullseyes arranged to look like scales. Each bullseye has 6 rings, colored red, orange, and yellow, and then again red, orange, and yellow, from the outermost to innermost. This creates a bright, almost glowing color to the whole image. The bullseyes are arranged in alternating rows of 6 or 7, where each bullseye touches the edge of the next along a row. The rows of 6 are offset by the radius of one bullseye to the right and above the rows of 7, and the rows of 7 are offset from each other so that their bullseyes touch at the top and bottom edges. Since higher-up rows are drawn on top of lower-down rows, except at the edges of the pattern each circle has its upper-left and upper-right parts covered by circles above it, while its lower half is completely visible, similar to how scales of a fish or reptile overlap.
Image A pattern of overlapping bullseyes arranged to look like scales. Each
bullseye has 6 rings, colored red, orange, and yellow, and then again
red, orange, and yellow, from the outermost to innermost. This creates a
bright, almost glowing color to the whole image. The bullseyes are
arranged in alternating rows of 6 or 7, where each bullseye touches the
edge of the next along a row. The rows of 6 are offset by the radius of
one bullseye to the right and above the rows of 7, and the rows of 7 are
offset from each other so that their bullseyes touch at the top and
bottom edges. Since higher-up rows are drawn on top of lower-down rows,
except at the edges of the pattern each circle has its upper-left and
upper-right parts covered by circles above it, while its lower half is
completely visible, similar to how scales of a fish or reptile overlap.

Rubric

Group goals:
 
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 multicolorCircles must make the correct number of calls to drawDot
Your multicolorCircles function must call drawDot the correct number of times.
 
unknown multicolorCircles must make the correct function calls
Your multicolorCircles 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 circleDesign must not crash
Your circleDesign function must run without crashing.
 
unknown concentricCircles must draw the correct image
The image drawn in the turtle window after concentricCircles is called must match the solution image.
 
unknown multicolorCircles must draw the correct image
The image drawn in the turtle window after multicolorCircles is called must match the solution image.
 
unknown Define concentricCircles with 4 parameters
Use def to define concentricCircles with 4 parameters
 
unknown Use any kind of loop
Within the definition of concentricCircles with 4 parameters, use any kind of loop in at least one place.
 
unknown Call color
Within the loop within the definition of concentricCircles with 4 parameters, call color, pencolor, or penColor in at least one place.
 
unknown Call drawDot
Within the loop within the definition of concentricCircles with 4 parameters, call drawDot in at least one place.
 
unknown Define multicolorCircles with 3 parameters
Use def to define multicolorCircles with 3 parameters
 
unknown Use any kind of loop
Within the definition of multicolorCircles with 3 parameters, use any kind of loop in at least one place.
 
unknown Call color
Within the loop within the definition of multicolorCircles with 3 parameters, call color, pencolor, or penColor in at least one place.
 
unknown Call drawDot
Within the loop within the definition of multicolorCircles with 3 parameters, call drawDot in at least one place.
 
unknown Define circleDesign with 0 parameters
Use def to define circleDesign with 0 parameters
 
unknown Use any kind of loop
Within the definition of circleDesign with 0 parameters, use any kind of loop in at least one place.
 
unknown Call concentricCircles
Within the loop within the definition of circleDesign with 0 parameters, call concentricCircles or multicolorCircles in at least one place.