Case Study 2:
def sierpinski(myTurtle, p1, p2, p3, depth) :
if depth > 0:
sierpinski(myTurtle, p1,
midPoint(p1, p2) , midPoint(p1, p3) , depth - 1)
sierpinski(myTurtle, p2,
midPoint(p2, p3) , midPoint(p2, p1) , depth - 1)
sierpinski(myTurtle, p3,
midPoint(p3, p1) , midPoint(p3, p2) , depth - 1) else:
drawTriangle(myTurtle, p1, p2, p3)
-Refer to the session in the accompanying Case Study 2. Which of the following lines correctly implements the midPoint function: def midPoint(p1, p2) ?
A) return ((p1[0] + p2[0]) /2.0, (p1[1] + p2[1]) /2.0)
B) return ((p1[1] + p2[1]) /2.0, (p1[1] + p2[1]) /2.0)
C) return ((p1[0] + p2[0]) /3.0, (p1[1] + p2[1]) /3.0)
D) return ((p1 + p2[0]) /2.0, (p1 + p2[1]) /2.0)
Correct Answer:
Verified
Q3: Case Study 1:
1. def drawSquare(aTurtle, side):
2. for
Q4: Case Study 1:
1. def drawSquare(aTurtle, side):
2. for
Q5: When drawing a tree with a recursive
Q6: How many recursive steps are used to
Q7: Case Study 2:
def sierpinski(myTurtle, p1, p2, p3,
Q9: How is the Sierpinski triangle drawn?
A) The
Q10: When drawing a Koch snowflake, what is
Q11: In computer science, a grammar consists of:
A)
Q12: In a grammar, the _ is the
Q13: Case Study 3:
Axiom A
Rules A → B
B
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents