Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 2 ( 2 5 marks ) This question tests your understanding of Block 1 Part 2 . A frieze is a decorative pattern made

Question 2(25 marks)
This question tests your understanding of Block 1 Part 2.
A frieze is a decorative pattern made from repeated copies of a basic element arranged in a line. Figure 1 shows part of a vertical frieze on the wall of a house.
Figure 1 Example frieze
a.Provide a top-level decomposition of the problem of drawing a frieze, assuming for the moment that the basic element is repeated just 3 times.
At this stage you are not trying to produce a solution; just break the problem itself down into smaller parts. We are looking for a birds eye view that could apply to a frieze composed of any basic element, and for now you should just assume that the exact form of the basic element will be considered later, so you can just say draw basic element for that step.
Your initial decomposition should use exactly one loop.
(4 marks)
In the remainder of this question, you will design and implement a program to draw the simpler frieze shown in Figure 2.
Figure 2 The frieze to be drawn for this question
In this frieze the basic element is a square tilted at 45 degrees to the horizontal. The sides of the square are 50 units long and each copy of the basic element is shifted upward by 100 units relative to the previous copy (Figure 3).
Figure 3 Dimensions of the frieze
b.Next refine your decomposition, adding more detail so that it becomes an algorithm. This is not yet a program, so you should write the steps in English rather than as Python statements. To draw the basic element of the frieze you will need to use a second loop.
(8 marks)
c.Translate your algorithm into Python, including appropriate comments. Name your Python file Q2_OUCU_c.py, where OUCU is your OU computer username, e.g., abc123. Run your program to test that it produces an output corresponding to Figure 2.
Paste your Python code into your solution document as text, using an evenly spaced font such as Courier New or Consolas, and state whether it produced the expected output.
Also include the code file in your TMA zip file.
Your answer must be a translation of your algorithm from (b), otherwise marks will be deducted.
Here and in Part (d) below you should use only techniques and language features taught in TM112. If you decide to use techniques or language features not covered in the module, you must give a justification for this, or marks will be lost.
(11 marks)
d.Save the code file again, this time as Q2_OUCU_d.py. In part (c) your code always produces 3 repetitions of the basic element. Now modify your code so that the required number of repetitions is held in a variable number_of_elements, where number_of_elements is initialised to 3 in this case but can be initialised to a different value as required.
Run your program using different values of number_of_elements to test that it produces the expected output.
Paste your Python code into your solution document as text, using an evenly spaced font such as Courier New or Consolas, and state whether it produced the expected output when you ran it.
Also include the code file in your TMA zip file.
(2 marks)
(Total 25 marks)

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

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions