Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import glob
- filenames = glob.glob('*.dat')
- for file in filenames:
- data = open(file)
- if file.startswith('weather'):
- weather_data_list = []
- for line in data:
- weather_data_list += [line.split()]
- separate_days_data = [x for x in weather_data_list[2:]]
- temperatures_list = [x[:3] for x in separate_days_data[:-1]]
- numeric_lists = [[elem.replace('*', '') for elem in lst] for lst in
- temperatures_list] # Remove asterisks from string
- values = [[int(x) for x in sublist] for sublist in numeric_lists]
- max_temperatures = [x[1] for x in values]
- min_temperatures = [x[2] for x in values]
- subtraction_results = [x - y for x, y in zip(max_temperatures, min_temperatures)]
- day_with_smallest_temp_spread = subtraction_results.index(min(subtraction_results)) + 1
- print('Day with smallest temperature spread is day number', day_with_smallest_temp_spread)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement