Question: New to coding and need help implementing this function I cannot import any other libraries beside the one I was given which is import json.

New to coding and need help implementing this function I cannot import any other libraries beside the one I was given which is import json.

import json

def read_json(filename): """ Returns the contents read from the JSON file filename. This function reads the contents of the file filename, and will use the json module to covert these contents into a Python data value. This value will either be a a dictionary or a list. Parameter filename: The file to read Precondition: filename is a string, referring to a file that exists, and that file is a valid JSON file """ pass # Implement this function

Below are the 2json files I was given

{ "2018-01-01T00:00:00-05:00": { "visibility": { "prevailing": 1.75, "units": "SM" }, "wind": { "speed": 13.0, "crosswind": 5.0, "units": "KT" }, "temperature": { "value": -15.0, "units": "C" }, "sky": [ { "cover": "clouds", "type": "broken", "height": 1200.0, "units": "FT" }, { "type": "overcast", "height": 1800.0, "units": "FT" } ], "weather": [ "light snow", "mist" ], "code": "201801010456Z" }, "2017-12-31T23:00:00-05:00": { "visibility": { "prevailing": 1.75, "units": "SM" }, "wind": { "speed": 13.0, "crosswind": 5.0, "units": "KT" }, "temperature": { "value": -15.0, "units": "C" }, "sky": [ { "cover": "clouds", "type": "broken", "height": 1300.0, "units": "FT" }, { "type": "overcast", "height": 2200.0, "units": "FT" } ], "weather": [ "light snow", "mist" ], "code": "201801010356Z" }, "2017-12-31T22:00:00-05:00": { "visibility": { "prevailing": 3.0, "units": "SM" }, "wind": { "speed": 11.0, "crosswind": 7.0, "units": "KT" }, "temperature": { "value": -15.0, "units": "C" }, "sky": [ { "type": "overcast", "height": 1300.0, "units": "FT" } ], "weather": [ "light snow", "mist" ], "code": "201801010317Z" }, "2017-12-31T21:00:00-05:00": { "visibility": { "prevailing": 10.0, "units": "SM" }, "wind": { "speed": 10.0, "crosswind": 7.0, "units": "KT" }, "temperature": { "value": -16.1, "units": "C" }, "sky": [ { "type": "overcast", "height": 1700.0, "units": "FT" } ], "code": "201801010156Z" } }

JSon file 2

[ { "cover": "clouds", "type": "broken", "height": 1200.0, "units": "FT" }, { "type": "overcast", "height": 1800.0, "units": "FT" } ]

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!