Before you keep reading...
Runestone Academy can only continue if we get support from individuals like you. As a student you are well aware of the high cost of textbooks. Our mission is to provide great books to you for free, but we ask that you consider a $10 donation, more if you can or less if $10 is a burden.
Before you keep reading...
Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.
🤔 Drawing a Circle with the Turtle¶
Suppose that we want our turtle to draw a circle, the circle should have a certain radius that the user can supply and then the turtle can draw one from the current location of the turtle.
Drawing a circle may sound like a real challenge, but here is another example of a problem solving exercise where you can start simple work out a few cases with paper and pencil in order to see the pattern. Once you see the pattern then you can generalize your solution.
To begin lets think of a simpler shape we can have the turtle draw such as a triangle, and since a radius doesn’t really make a lot of sense for a triangle lets suppose that the user supplies us with the length of the side for a triangle.
Ask the user for a side length and then draw a triangle.
Ask the user for a side length and then draw a square
Ask the user for a side length and then draw an octagon (8-sided)
Now there are a couple of jumps we need to make:
Although we think of a circle as being perfectly round, we can’t really achieve that on a computer screen. So our circle will be an approximation of a circle. In fact you have probably already noticed that the octagon looks a lot more circle-ish than the triangle did. So we will approximate our turtle by making a polygon with a lot of sides.
How did you figure out how far to make the turtle turn for the triangle, square, and octagon?
to make the leap to drawing our approximate circle we will need to figure out how many sides we need how long those sides should be and how much to turn. Depending on the order you answer the questions, you may get a different final program. Remember that you can always do a little experiementing to see what looks good, you don’t have to have the perfect answer on the first try, and its OK to use an assumption for one of the answers to the three questions.
Ask the user for a radius and then draw a circle with that radius.
Ask the user for a radius and then draw a circle with that radius, but make the center of the circle at the current location of the turtle.
Post Project Questions
During this project I was primarily in my...
- 1. Comfort Zone
- 2. Learning Zone
- 3. Panic Zone
Completing this project took...
- 1. Very little time
- 2. A reasonable amount of time
- 3. More time than is reasonable
Based on my own interests and needs, the things taught in this project...
- 1. Don't seem worth learning
- 2. May be worth learning
- 3. Are definitely worth learning
For me to master the things taught in this project feels...
- 1. Definitely within reach
- 2. Within reach if I try my hardest
- 3. Out of reach no matter how hard I try