Please answer JUST the last questions using python. Thanks! We need to use speci
ID: 3602176 • Letter: P
Question
Please answer JUST the last questions using python. Thanks!
We need to use specific txt files but you can just give me the a very simple step by step of how to complete that code.
THANKS!
Preparation Download the zip file "Weather" and place it in the directory where you are going to store and execute your file. Then unzip it. You should now have a directory with some 500 different files Make sure that you can open the files Days in the Month Write a function that will return the number of days in a month given the year and the month. All date components are integers. Of course, you will have to determine for February whether the year is a leap year or not. Generating File Names Write a function that given a year, month, and date (as integers) generates a file name for an ARC file. That is, on a MAC, given 2006, 2, 14, your program should return the string Weather/ARC-2006-02-14.txt On a windows machine, you will need to revert the slash. As you see from a listing of the directory or the example above, the format uses leading zeroes. Python does this for you. Format recognizes (:02d) as an instruction to reserve two letters with the leading one being a zero for one letter entries. Now write a function that generates file names for all the days in a given month Processing Files ature from the third and following lines Write a function that opens an ARC file, reads the temper and prints them out. Opening the file should not be problematic. We can read all lines in the file myFile into a list by saying list (myFile).We then get the lines with data from the list. Those lines, we split, obtaining a list of words. If you look closely, you see that the entries are separated not by spaces, but by tabs, i.e. ' '. You have to figure out which one is the temperature. The temperature is a string. We therefore change it into a float. Minima and Maxima Write your own function minmax that takes a numerical list as an argument and returns the minimum and the maximum of the list. Hint: You want to initialize the minimum to a very large number and the maximum to a very large, negative number.Explanation / Answer
def get_min_max_temperature_each_day(month,year):
"""will return the number of days"""
number_of_days = get_days_in_month(month,year)
"""iterate over each date"""
for number in range(number_of_days):
"""gets the file name to read"""
file_name = generate_file_name(date,month,year)
"""gets the list of temperatures """
temperature_list = processing_file(file_name)
"""gets minimum and maximum temperature"""
min_temperature,max_temperature = minmax(temperature_list)
"""creates date"""
date = '-'.join([year,"%02d"%(month,),"%02d"%(number,)])
"""prints minimum and maximum temperature of each day in given month and year"""
print date,min_temperature,max_temperature
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.