Question: Create a function, temp _ dictionary ( ) that can read from a file name passed in as a parameter. The file passed in contains

Create a function, temp_dictionary() that can read from a file name passed in as a parameter. The file passed in contains individual temperatures in degrees Fahrenheit from cities around the world on a given day. Your job is to read the file and create a dictionary from the data. Steps Create a function called temp_dictionary () that takes in a file name as a parameter. Read the first line, which tells you the number of city/temperature pairs in the file. The structure of the file can be seen in the example file, temperatures_example.txt Read the rest of the file. The information for one city is on two lines. The first line is a city name, the second line is that city's temperature, and so on. Create a dictionary, storing the city name as a key and the temperature as its value. Be sure to return your dictionary!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!