Question: The site OpenWeatherMap provides a simple REST API to get weather data. Your assignment is to write a Python script that will get the current

The site OpenWeatherMap provides a simple REST API to get weather data. Your assignment is to write a Python script that will get the current weather data for a particular zip code and then print out some of that data in a table. Please use the zip code assigned below

For the zip code 30144, the output would look like this:

Name: Kennesaw Current Temperature: 40.44 degrees Fahrenheit Atmospheric Pressure: 992.52 hPa Wind Speed 9.86 mph Wind Direction 287.503 Time of Report 2016-02-25 11:13:24 

To be able to carry out this assignment you will need to register for a free account with OpenWeatherMap. You will provide an id (username) when registering. Once you have registered, you will receive an APIID, essentially your password for using the service.

The current weather data API page tells you how to create a request for the current weather at a particular zip code. Information on the page tells the structure of the data returned. The How to start page tells how to include the APIID and id in a request. Unless you care to convert from Kelvin to degrees Fahrenheit and convert from kilometers per hour to miles per hour in your script, be sure to request imperial units from the server.

The data you get back will be encoded as JSON. You will need to decode it to access the information contained in the response.

Use the datetime class in the datetime package from the standard library to convert the time stamp included in the data to readable form. The value included in the data is the number of seconds since the epoch (standard Unix timestamp). The displayed value above is the default display of a datetime object created from the raw timestamp.

Script Structure Requirements

Please pay attention to these! These particular requirements are included so that the instructor can test your script using the instructors account.

At the beginning of your script assign values to variables user_id and user_apiid. These will be strings with the values of your id and apiid. Do not include your id or your apiid values directly in your code, use the variables instead. When your program is tested, the instructors values will be substituted.

Evaluation

Your script will run from the project directory that contains it. The values of the variables user_id and user_apiid will be modified before running the script.

The requests HTTP package will be installed. However, you may not assume that any other package has been installed beyond the standard library.

Zip code assignment

The last two digits of your KSU ID should be in the first column. Please use the Zip code in the second column.

The purpose of this is so that your programs wont trip alarms at the web site when being tested.

ID zip code
04 30001
07 30002
08 30003
09 30004
10 30006
12 30011
14 30017
15 30019
16 30020
21 30021
22 30025
30 30026
33 30027
39 30028
46 30030
47 30038
49 30039
52 30048
59 30050
60 30052
63 30054
64 30055
66 30056
70 30057
72 30059
75 30070
78 30072
79 30074
80 30075
82 30079
84 30080
87 30083

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 Databases Questions!