Q. Consider the temperature given below for the month of June in North India. Calculate the average temperature and median value. This temperature gets dipped with a variation of 20° C in the month of December. Write a Python program to calculate the changed median value and average temperature.
Location | Temperature (in °C) |
---|---|
Delhi | 41 |
Shimla | 32 |
Chandigarh | 43 |
Rohtak | 40 |
Srinagar | 28 |
SriGanganagar | 45 |
Answer :-
import statistics as s data = [41, 32, 43, 40, 28, 45] print ("Data :-", data) print ("Average temperature in month of June :-", s.mean(data)) print ("Median value in month of June :-", s.median(data)) new_data = [] for i in data: new_data += [i - 20] print ("\nAverage temperature in month of December :-", s.mean(new_data)) print ("Median value in month of December :-", s.median(new_data))
Output :-
Data :- [41, 32, 43, 40, 28, 45]
Average temperature in month of June :- 38.166666666666664
Median value in month of June :- 40.5
Average temperature in month of December :- 18.166666666666668
Median value in month of December :- 20.5
>>>
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )