Draw the following fractal shape with recursion, Python and Turtle. (It have to a right triangle with the same orientation)
Added by Christina B.
Close
Step 1
Here's the code to achieve this: ```python import turtle def draw_triangle(length, depth): if depth == 0: for _ in range(3): turtle.forward(length) turtle.right(120) else: draw_triangle(length/2, depth-1) Show more…
Show all steps
Your feedback will help us improve your experience
Hannah Wilds and 55 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
(Turtle: draw a triangle) Write a program that draws a triangle as shown in Figure $1.18 \mathrm{c}$
Create a fractal by starting with a square, dividing each line segment into three equal lengths, and replacing the middle third of each side with three line segments whose lengths are one-third the length of the original segment. This is the first iteration. Repeat this process and draw the next iteration of this fractal. Repeat the process up until five iteration.
Donna D.
Sri K.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Watch the video solution with this free unlock.
EMAIL
PASSWORD