Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design and implement a single program: to produce a simple graphical representation of a set of triangles, as shown in Figure1. The output should consist

Design and implement a single program:

  • to produce a simple graphical representation of a set of triangles, as shown in Figure1. The output should consist of four triangles with sides of length 20, 40, 60 and 80, respectively, placed vertically as shown. Other than the top triangle, the top of each triangle should be exactly halfway along the baseline of the triangle above
  • that, in principle, can produce larger numbers of triangles simply by changing one number that specifies the number of triangles
  • with the turtle starting at the position that we want to be the bottom left-hand corner of the bottom-most triangle and the turtle pointing to the right.

a. Produce a top-level decomposition, making use of exactly one loop. At this stage, express your answer in terms of two sub-problems.

b. Refine your decomposition to give an algorithm. As you include extra detail, make use of a second loop.

c. Translate your algorithm into Python, including appropriate comments, and run your program to ensure the output matches Figure1. You do not need to submit an output. Paste your completed Python code into your solution document as text and state whether it is successful in producing the required output.

Your answer must be a translation of your algorithm from Part(b), otherwise no marks will be awarded.

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

Students also viewed these Programming questions