Part 1: Write a python program that reads a file and finds the day and year of t
ID: 3718931 • Letter: P
Question
Part 1: Write a python program that reads a file and finds the day and year of the lowest recorded temp ever. Your program should only read & process the data file one line at a time, and NOT keep data in memory. We are simulating Big Data analysis.
and also Modify your program so it will:
1) Find both the highest and lowest recorded temperatures
2) Report each month/day/year when these temps were reached
3) Make no assumptions about how many days will tie for the highest temp or lowest temp.
Remember, the program must process the data line by line, only one time.
to be written in Python
Explanation / Answer
file = open("input190.txt","r")
list = []
max = 0.0
min = 10000.0
for line in file:
list1 = line.split(" ") # Assuming data in file as m/day/year temp
list.append(list1)
if float(list1[1]) > max:
max = float(list1[1])
if float(list1[1]) < min:
min = float(list1[1])
file.close()
print("Highest temperature:",max)
print("Lowest temperature:",min)
print("Maximum Temperature recorded on")
for i in range(len(list)):
if float(list[i][1]) == max:
print(list[1][0])
print("Minimum Temperature recorded on")
for i in range(len(list)):
if float(list[i][1]) == min:
print(list[1][0])
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.