Question

dle Edit Search View Encoding Language Settings Tools Macro Run Plugins Window 1 isport turtle 3 tina turtle.Turtle 4 SCreen-


1. Exercise to draw concentric circles: a. Download concentriccircles.py b. Start by uncommenting and running the tests of th
connex: x Microsof x 23 Recur × /fde46843-6be2-4a13-8ff2-b3b440d37cc2/ Notice, in the simplest case stri(24, 0, o with a CUTO
dle Edit Search View Encoding Language Settings Tools Macro Run Plugins Window 1 isport turtle 3 tina turtle.Turtle 4 SCreen-turtle.Screen ) 5 acreen.bgoolor ("white") 6 tina.shape ("turtle" 7tina.pencolor ("blue") SCALE -20 10 12 13 14 15 16 17 18 19 20 21 input: n # output: a drawing of n concentric circles centered at 0,0 # this function is written using iteration (using a loop) Edef concentric loop (n) : for size in range(n) : tina.penup tina goto (O, -SCALE size) tina.pendown ) tina.circle (SCALE size) tina.hideturtle ) screen.exitonclick( 23 L 24 25 input:n 26 # output: a drawing of n concentric 다rcle, ce tered at 0.0 # wzite concentric recursive here 28 30 32 # uncomment the following one at time # eo see the output of the concentric-loop tunction ython file 0 Type here to search
1. Exercise to draw concentric circles: a. Download concentriccircles.py b. Start by uncommenting and running the tests of the concentric loop c. Write the recursive version of this function in the file under the comments d. Test your function by uncommenting the tests of the concentric recursive function one at a time to see what the output looks like provided. Your function must be named concentric recursive function one at a time to compare the output to that of concentric ldop
connex: x Microsof x 23 Recur × /fde46843-6be2-4a13-8ff2-b3b440d37cc2/ Notice, in the simplest case stri(24, 0, o with a CUTOFF of 25, no recursive calls are made, and the basecase draws one triangle with side length of24 The next testcase is a call to stri(so, o, o) with a CUTOFF of 25 This case, starts with an equilateral triangle with side length of S0. Inside of that triangle, three more Sierpinski triangles are drawn with a side length of 25 (two on the bottom and one above). The inner triangles are drawn in red to highlight the recursion: With the later testcase stri 1s0, o, 0) with a CUTOFF of 25 In this case, the outer triangle is drawn with side length 150, inside that triangle are 3 more Sierpinski triangles are drawn, and inside each of those 3 more Sierpinski triangles, and so on If we were to lower the CUTOFF value it would take much more time to run the program, but a more detailed fractal would be drawn like this one from
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import turtle

tina = turtle.Turtle()
screen = turtle.Screen()
screen.bgcolor("white")
tina.shape("turtle")
tina.pencolor("blue")

SCALE=20

def concentric_loop(n):
for size in range (1,n):
tina.penup()
tina.goto(0,-SCALE*size)
tina.pendown()
tina.circle(SCALE*size)
tina.hideturtle()
screen.exitonclick()
  
#input n
#output concentric circle at 0,0
def concentric_recursive(n):
tina.penup()
tina.goto(0,-SCALE*n)
tina.pendown()
tina.circle(SCALE*n)
if(n > 0):
concentric_recursive(n-1)
else:
tina.hideturtle()
screen.exitonclick()
  
concentric_recursive(5)

Add a comment
Know the answer?
Add Answer to:
Dle Edit Search View Encoding Language Settings Tools Macro Run Plugins Window 1 isport turtle 3 ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • #include <iostream> #include <iomanip> #include <vector> using namespace std; Part 1. [30 points] In this part,...

    #include <iostream> #include <iomanip> #include <vector> using namespace std; Part 1. [30 points] In this part, your program loads a vending machine serving cold drinks. You start with many foods, some are drinks. Your code loads a vending machine from foods, or, it uses water as a default drink. Create class Drink, make an array of drinks, load it and display it. Part 1 steps: [5 points] Create a class called Drink that contains information about a single drink. Provide...

  • You need not run Python programs on a computer in solving the following problems. Place your...

    You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT