Please let me know the code for this as I am not able to upload the JSON file
The JSON file
provided, climate.json contains monthly climate data of over one hundred destinations and includes average high and low temperature, dry days, snow days, and rainfall, for every month.
Program Tasks
Write a program display Climate.py that performs the following functionalities
a. reads the JSON file climate.json
b. displays the cities as a list
c. prompts the user to enter a city or cities
d. searches for the relevant data and display (
(i) the average rainfall for each month as a list
(ii) minimum and maximum rainfall per year.
(iii) the average rainfall per year.
A brief introduction to the JSON file
Structure of the climate JSON file:
• JSON data works just like python dictionary and you can access the value using
dictionaryName[key]
• The JSON file contains a list of 104 dictionary items and each dictionary item has 4 keys.
• The monthlyAvg key has a list as its value, which in return contains 12 dictionary items representing each month in a year.
• You may use the website https://codebeautify.org/jsonviewer and load the file into its editor. The website will display the structure and details of this JSON file. Alternatively, you can view this file using any text editor.
• A snapshot of the structure of this file is shown on the following page.
Loading a JSON file:
with open('climate.json', 'r') as f:
# convert a json object into a readable python object
data = json.load(f)
[
{
"id": 1,
"city": "Amsterdam",
"country": "Netherlands",
"monthlyAvg": [
{
"high": 7,
"low": 3,
"dryDays": 19,
"snowDays": 4,
"rainfall": 68
},
{
"high": 6,
"low": 3,
"dryDays": 13,
"snowDays": 2,
"rainfall": 47
},
{
"high": 10,
"low": 6,
"dryDays": 16,
"snowDays": 1,
"rainfall": 65
},
{
"high": 11,
"low": 7,
"dryDays": 12,
"snowDays": 0,
"rainfall": 52
},
{
"high": 16,
"low": 11,
"dryDays": 15,
"snowDays": 0,
"rainfall": 59
},
{
"high": 17,
"low": 11,
"dryDays": 14,
"snowDays": 0,
"rainfall": 70
},
{
"high": 20,
"low": 12,
"dryDays": 14,
"snowDays": 0,
"rainfall": 74
},
{
"high": 20,
"low": 12,
"dryDays": 15,
"snowDays": 0,
"rainfall": 69
},
{
"high": 17,
"low": 10,
"dryDays": 14,
"snowDays": 0,
"rainfall": 64
},
{
"high": 14,
"low": 9,
"dryDays": 16,
"snowDays": 0,
"rainfall": 70
},
{
"high": 9,
"low": 6,
"dryDays": 20,
"snowDays": 1,
"rainfall": 82
},
{
"high": 7,
"low": 1,
"dryDays": 19,
"snowDays": 1,
"rainfall": 85
}
]
},
{
"id": 2,
"city": "Athens",
"country": "Greece",
"monthlyAvg": [
{
"high": 12,
"low": 7,
"dryDays": 21,
"snowDays": 1,
"rainfall": 53
},
{
"high": 12, ..............
Do NOT use __main__ anywhere in your program code.
Output : After user input
Enter 0 to terminate input.
Enter City to check rain fall data: Vancouver
Enter City to check rainfall data: Calgary
Enter city to check rain fall data: 0
Average monthly rain fall in mm for Vancouver:[232,122.8,154,116.4,91.7,79,41.2,54.2,67.8,158.9,250.8,208.5]
Min : 41.2 mm
Max: 250.8 mm
Average 131.44 mm
Average monthly rain fall in mm for Calgary: [11.4,10.5,17.1,28.9,60.6,113.3,59.3,58.6,35.9,17,15.8,11.2]
Min: 10.5 mm
Max: 113.3 mm
Average: 36.3 mm
Would you like to continue? press Y or N:
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images
- BAGGINS Trucking maintains a trip file in which each record contains the following data:DRIVER nameMILES driven on tripHOURS driven on trip Design an application that inputs records from the file (until reaching "eof") and, for each record, displays the DRIVER's name and the average Miles-per-Hours (MPH) for the trip where MPH is calculated by dividing the MILES by the HOURS. The program should also accumulate a GRAND total of the MILES driven. At the end, the program should display the GRAND total of the MILES driven. For example, if the trip file contained the following:Smith, 300, 5Williams, 750, 10Jones, 880, 11 then the program should display:Smith averaged 60 mphWilliams averaged 75 mphJones averaged 80 mphGrand total of miles is 1,930 Pseudocode:arrow_forward2 of 4 Automatic Zoom View as Text Download >> LAB ASSIGNMENTS IMPORTANT: you should complete the PDP thinking process for each program. Turn in items: 1) book_list.py: you can adapt your Chapter 4 book_list.py Lab program. The program summarizes costs of a book list. It uses all of our standard mipo_ex features. This program summarizes a book list. Enter the number of books that you need: In this version of the program you must use pylnputPlus functions to perform all the input validation and for the main() loop decision. Please enter a whole number: three Enter a number greater than 0: 3 Enter the name of book #1: The Mueller Report Enter cost of The Mueller Report, to the nearest dollar: Please enter a whole number: 18 Enter the name of book #2: Educated: A Memoir Enter cost of Educated: A Memoir, to the nearest dollar: Please enter a whole number: 24 08 Adjust your program to allow book prices to include $ and cents. Restrict individual book prices to $100 maxium. Enter the name of…arrow_forward# convert_revised_1.py # We will try to print a table without using "string formatting"def main():print("celsius", "fahrenheit") for celsius in range (-20, 110, 10):fahrenheit = 9/5 * celsius + 32print(celsius, fahrenheit)main() Your turn: Please revise the above program convert_revised_1.py with "string formatting" and try to print a better-formatted table(required width for Celsius value is 35, width Fahrenheit value is 45, both should be center-aligned/justified)arrow_forward
- Modify the code below the #S11icq Q5 comment as you enter code for this task. Modify the code that creates the variable sf to assign the value in index position 2 of the list fish Modify the loop to repeat exactly four times . Click on the Run Current Script function (use menu at top of Thonny). Match the following: 1. 18500967 2. 237233811 updated value of sm 3. 35 updated value of sg_h 4. 44 updated value of sg_c 5. 2 6. 3 6arrow_forwardAdd comments for Program 04arrow_forwardC programarrow_forward
- Code in C language. Please provide code for 3 different files. One header file and two .C files. I need the code for each file. Please provide photos of the output and source code for each file (3). Please follow All instructions in the photo provided. Use the provided input.txt file provided below. A1, A2 20294 Lorenzana Dr Woodland Hills, CA 91364 B1, B2 19831 Henshaw St Culver City, CA 94023 C1, C2 5142 Dumont Pl Azusa, CA 91112 D1, D2 20636 De Forest St Woodland Hills, CA 91364 A1, A2 20294 Lorenzana Dr Woodland Hills, CA 91364 E1, E2 4851 Poe Ave Woodland Hills, CA 91364 F1, F2 20225 Lorenzana Dr Los Angeles, CA 91111 G1, G2 20253 Lorenzana Dr Los Angeles, CA 90005 H1, H2 5241 Del Moreno Dr Los Angeles, CA 91110 I1, I2 5332 Felice Pl Stevenson Ranch, CA 94135 J1, J2 5135 Quakertown Ave Thousand Oaks, CA 91362 K1, K2 720 Eucalyptus Ave 105 Inglewood, CA 89030 L1, L2 5021 Dumont Pl Woodland Hills, CA 91364 M1, M2 4819 Quedo Pl Westlake Village, CA 91362 I1, I2 5332 Felice Pl…arrow_forwardPYTHON PROGRAMMING LANGUAGE Create a new text document called names.txt (this is done by hand - not using programming) with the following names: Adam, Bryan, Charlie. Each name should be followed by a hard return (do not store them in a list). Main Function. Write a program where the user enters a name. Using the read function, check to see if the name is in the text document. If it is, respond back to the user the name is found within the list. Read Function. The read function should return the contents of the text document as a list. Write Function. The write function should take the list and override the file with the new names list in reverse alphabetical order with a hard return after each name. EXAMPLEPlease enter a name: AdamAdam is found in the list.Enter another name (Y/N): YPlease enter a name: AndrewSorry, Andrew was not found in the list. Would you like to add it? (Y/N): YAndrew has been added to the list.Enter another name (Y/N): N LIST EXAMPLEadambryancharlie Final…arrow_forwardDefine the following data structures: Record File Array Stringarrow_forward
- Two of the menu options (#2 and #3) are unfinished, and you need to complete the code necessary to write to and read from a binary file. You will need to read through the code to find the functions that are called by these options, and then supply the missing code. Please help me get menu 2 and 3 to display properly.the .cpp and .h have the information:.cpp file: // Corporate Sales Data Outputusing namespace std; #include <iostream>#include <fstream>#include <stdlib.h>#include "HeaderClassActivity1.h" int main() { Sales qtrSales[NUM_QTRS]; while (true) { cout << "Select an option: " << endl; cout << "1. Input data" << endl; cout << "2. Write data to file" << endl; cout << "3. Read data from file" << endl; cout << "4. Display sales" << endl; cout << "99. End program" << endl; int menuItem; cin >> menuItem; if (menuItem ==…arrow_forwardC. d. ne: ID: A 7. A summer camp offers a morning session and an afternoon session. The list morningList contains the names of all children attending the morning session, and the list afternoonList contains the names of all children attending the afternoon session. Only children who attend both sessions eat lunch at the camp. The camp director wants to create lunchList. which will contain the names of children attending both sessions. The following code segment is intended to create lunchList, which is initially empty. It uses the procedure IsFound (list, name), which returns true if name is found in list and returns false otherwise. FOR EACH child IN morningList Which of the following could replace so that the code segment works as intended? IF (ISFound (lunchList, child)) IF (IsFound (afternoonList, child)) APPEND (afternoonList, child) APPEND (lunchList, child) a. IF ((Is Found (morningList, child)) OR (IsFound (afternoonList, child) )) IF (IsFound (morningList, child)) APPEND…arrow_forwardaoeiqeo Python please.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education