Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Turtle Code:: Triangle with color Drawing a Sierpinski triangle using GUI/Turtle. Write a program that draws Sierpinski triangle using recursive methods as shown below:

Python Turtle Code:: Triangle with color

Drawing a Sierpinski triangle using GUI/Turtle.

Write a program that draws Sierpinski triangle using recursive methods as shown below:

image text in transcribed

Hints:

The three points of the triangle are passed to invoke displayTriangles. If order == 0, the displayTriangles (order, p1, p2, p3) function displays a triangle that connects three points p1, p2, and p3, as shown in Figure a. Otherwise, it performs the following tasks:

1. Obtains a midpoint between p1 and p2), a midpoint between p2 and p3, and a midpoint between p3 and p1, as shown in Figure b.

2. Recursively invokes displayTriangles with a reduced order to display three smaller Sierpinski triangles. Note that each small Sierpinski triangle is structurally identical to the original big Sierpinski triangle except that the order of a small

triangle is one less, as shown in Figure b.

image text in transcribed

Drawing a Sierpinski triangle spawns calls to draw three small Sierpinski triangles recursively.

Once done, rewrite the programs for filled Sierpinski triangles.

Sierpinski Triangle ATA Enter an order: Display Sierpinski Triangle

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions