Menu

Hi I Cannot Get My Head Around This With This Computer Science Question

0 Comment

Question 5 (14 marks)
This question is about Block 2 Part 5. This question requires you to calculate values using Python functions. There are two
approaches you can use.
add suitable code to the provided file, then run it
run the provided file first, to load the required function and data into memory, then do the calculation in the interactive Python
shell.
Feel free to choose the approach you prefer.
The download folder for this TMA contains TM112_200_TMA02_05_files. zip (go to TMA02 – Python files and download
TM112_20D_TMA02_Q5files. zip and unzip the file). While you are working on this question, keep all the files in
TM112_20D_TMA02_Q5_files together in that folder. Moving files out of the folder may result in some of the code not working.
Open the folder TM112_20D_TMA02_05_files and inspect the contents of q5. py. The Python list population in q5. py holds UK
population in millions 1990 – 2017 (ONS, 2018). The Python list gas in q5. py holds 28 yearly values for the retail price of gasoline
in the US (in $) (Statista 2019).
a. q5. py imports the Python function median ( ) you used in Block 2 Part 5 to calculate the median of a list of numbers.
Use this function to find the median of the list of the population.
In your Solution document give the median, correct to two decimal places. Also provide the Python code you used for calling
the median() function and explain how you executed it.
(4 marks)
b. In Section 5.1 you were introduced to Polya’s four stage process for problem solving. List the four stages
(2 marks)
c. Figure 2 shows a scatterplot of the two python lists in q5. py – population and gas. The python file q5. py imports the function
corr_coef( ) which you used in Section 5.4 of Block 2 Part 5 to calculate the correlation coefficient between two lists.
Use this function to calculate the correlation coefficient and provide the resulting figure rounded to two decimal pl
o
Classify the size of the effect, following Table 5.4 in Block 2 Part 5.
Briefly discuss whether any effect you have found is likely to be causal.
The maximum word limit for the Question 5(c) is 60 words.
(8 marks)
3.5
3.
Price of gasoline in $
2.5
2.
1.5
1.
…….
0.5
0.
56.00
57.00
58.00 59.00
60.00
61.00
62.00
63.00
64.00
65.00
66.00 67.00
UK Population in millions
Figure 2 Price of gasoline in the US (in $) Vs UK Population in millions. Both are from 1990 – 2017.
(Total 14 marks)
References
Office for National Statistics (ONS) (2018) United Kingdom population mid-year estimate [Online]. Available at
https://www.ons.gov.uk/peoplepopulationandcommunity/populationandmigration/populationestimates/timeseries/ukpop (Accessed
2nd October, 2019)
Statista (2019) Retail price of regular gasoline in the United States from 1990 to 2018 [Online]. Available https://www.statista.com/
statistics/204740/retail-price-of-gasoline-in-the-united-states-since-1990/(Accessed 30th January 2019).
References created using the OU Harvard guide to citing references for online materials.Python Programming