Question: PYTHON please help, i have added the example tables in the bottom see attached please, also for part 4, I have attached the pattern to
PYTHON please help, i have added the example tables in the bottom see attached please, also for part 4, I have attached the pattern to use (2.2)
We have provided two problems for you to work with. For each problem you are asked to carry out the six steps listed below.
-
Provide a high-level decomposition. This should do no more than break the problem into the main subproblems. It is a description of what the solution needs to do, without going into the detail of how it will be done. As a rather fanciful example, if you were planning a mission to collect rock samples from the Moon a high-level decomposition could be
> Collect Moon rocks
>> Fly to Moon
>> Land
>> Collect rock samples
>> Return to Earth
As you see this leaves out all the detail of things like distances and velocities and just gives the big picture. Of course, your decompositions will be very different, but we hope the example gives a feel for the level of detail appropriate in a high-level decomposition.
- Say what the inputs and outputs of the problem are.
- Write two tests for the problem. Present the tests in a table, with a column for each input and output, and an extra column with a brief explanation of why you selected each test (as is done in Block 2 Part 2 Activity 2.10, for example).
- Identify which of the TM112 pattern or patterns should be applied to the solution of the problem. State clearly the name of the pattern and the pattern number, for example "List generation Pattern 2.2". A list of all the patterns can be found in the Problem solving and Python quick reference . Please use the 2.2 case analysis below
- Write an algorithm for the problem by instantiating the pattern you have chosen.
- Implement your chosen pattern as Python code. This must match the steps of your chosen pattern and you should use comments in the code to make it clear how the two correspond. Marks will be lost if the program does not follow the algorithm.
The problems
-
a.Convert a list of whole numbers representing distances in miles to a list of the corresponding distances in kilometres, rounded to 1 decimal place. You should use a conversion factor of 1.61 from miles to kilometres. The Python round function was introduced in 1.2.3 of Block 1 Part 1.
(9 marks)
-
b.Given a list of whole numbers, if there is a value or values that exceed 100 the result should be the last such value found in the list. If there is no value that exceeds 100 the result should be the special Python value None.


Activity 2.10 (exploratory) Python editor: testing the hot days program Write a test table and run those tests on your program Hide discussion Discussion The tests in Table 2.1 cover the borderline values of the temperatures (30 and 31, for considering a day to be hot or not) of the input list, and of the output list. daily_temperatures hot_days Comment 0 smallest input empty list [25. 24. 221 0 smallest output no hot days [31, 33) [31.33] largest output all days are hot 28, 30, 31, 30, 31, 32] (31. 31. 32] borderline temperatures 2.2 Case analysis (two cases) (B1 P4, Pattern 4.2, p. 209) (Generates an output that depends on a case-by-case analysis of the inputs from two cases and appropriate selection.) 1 initialise the input variables 2 if the input values fall into the first case: 2a compute the outputs according to the first case 3 3 otherwise compute the outputs according to the second case 4 print the outputs
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
