Write a program to load the Syracuse weather data from Dec 2015 in JSON format into a Python list of dictionary.
The file with the weather data is: "NYC5-syr-weather-dec-2015.json"
You should load this data into a Python list of dictionary using the json
package.
After you load this data, loop over the list of weather items and record each of the different weather events (found under the "Events"
) key into another Python dictionary, talling the different types of weather events across the 31 days of December.
When done correctly your output should be:
{'Rain': 14, None: 7, 'Fog': 2, 'Snow': 2, 'Fog-Rain': 3, 'Rain-Snow': 3}
Write the dictionary to a Python file called dec-2015-events.json
.
This is a conceptually difficult problem and the solution is classic Python: 10 lines of code and quite cryptic looking. The best approach is to use problem simplifcation to once again arrive at the answer. This program is too complicated to write all at once! Let's break it up into parts.
Parts:
"NYC5-syr-weather-dec-2015.json"
into a python list of dict variable named weather
weather
variable print all the `"Events" keys. There should be 31 weather events one for each day in Decemberevents
where the value is the number of occurences of the eventevents
Python dictionary as JSON to a file called dec-2015-events.json
.NOTE: In the problem analysis sections, the inputs and outputs are provided, but you must write the algorithms.
In [12]:
# Part 1 : Step 2 Write Code
In [13]:
# part 2: step 2 write code
Now that you know how to write the loop, modify the loop to add keys to another dictionary events
where the value is the number of occurences of the event
Inputs: weather
variable from previous step, empty dictionary named events
Outputs: events
dictionary where they keys are the event names and the value is the number of times the event occured in December
Algorithm (Steps in Program):
In [14]:
# Part 3: Step 2 write code
In [15]:
# Part 4: Step 2: write code
In [16]:
# part 5 re-write code here
Answer:
NYC5-syr-weather-dec-2015.json
?Answer:
Answer:
Reflect upon your experience completing this assignment. This should be a personal narrative, in your own voice, and cite specifics relevant to the activity as to help the grader understand how you arrived at the code you submitted. Things to consider touching upon: Elaborate on the process itself. Did your original problem analysis work as designed? How many iterations did you go through before you arrived at the solution? Where did you struggle along the way and how did you overcome it? What did you learn from completing the assignment? What do you need to work on to get better? What was most valuable and least valuable about this exercise? Do you have any suggestions for improvements?
To make a good reflection, you should journal your thoughts, questions and comments while you complete the exercise.
Keep your response to between 100 and 250 words.
--== Write Your Reflection Below Here ==--
In [ ]:
# RUN THIS CODE CELL TO TURN IN YOUR WORK!
from ist256.submission import Submission
Submission().submit()