Program Instructions 1. All the functions should accept the weather dictionary data structure as follows: weather dictionary: key datetime as string (formatted as YYYYMMDDhhmmss) value readings dictionary readings dictionary for key : 't' value temperature as integer for key : 'h' value: humidity as integer for key : 'r' value rainfall as float 2. Create a weather module. i. Create a function named_read_data which receives a keyword parameter filename. a. The function should open the filename in read mode and return a dictionary of the JSON decoded contents of the file. b. If the file does not exist, the function should accept the FileNotFoundError and return an empty dictionary. ii. Create a function named write_data which receives a keyword parameter data and filename a. The function should open the filename in write mode and write the dictionary data into the file encoded as JSON. iii. Create a function named max_temperature which receives a keyword parameter data and date a. The function should return the maximum temperature for all dictionary data where the key contains the date as YYYYMMDD. iv. Create a function named min_temperature which receives a keyword parameter data and date a. The function should return the minimum temperature for all dictionary data where the key contains the date as YYYYMMDD. v. Create a function named max_humidity which receives a keyword parameter data and date a. The function should return the maximum humidity for all dictionary data where the key contains the date as YYYYMMDD. vi. Create a function named min_humidity which receives a keyword parameter data and date a. The function should return the minimum humidity for all dictionary data where the key contains the date as YYYYMMDD. vii. Create a function named tot_rain which receives a keyword parameter data and date a. The function should return the sum of rainfall for all dictionary data where the key contains the date as YYYYMMDD. viii. Create a function named report_daily which receives a keyword parameter data and date a. The function should return a single string which when passed to any print function will display on the screen formatted exactly as indicated in the example output below. You will most likely be appending strings together using a literal "\n" where a newline is desired. To get the month name, you can import the builtin calendar module and call the month_name function passing it the month as an integer. ix. Create a function named report_historical which receives a keyword parameter data a. The function should return a single string which when passed to any print function will display on the screen formatted exactly as indicated in the example output below. You will most likely be appending strings together using a literal "\n" where a newline is desired. To get the month name, you can import the builtin calendar module and call the month_name function passing it the month as an integer

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section7.4: Arrays As Arguments
Problem 7E: (Statistics) Write a program that includes two functions named calcavg() and variance(). The...
icon
Related questions
Question
100%
3. Create a main driver program to meet the following requirements:
i. Create a file named main.py.
ii. Import the weather module.
iii. Set a default filename to store the JSON data.
iv. Declare a dictionary to hold the weather data.
v. Implement a menu within a loop with following choices:
a. Set data filename
a. Prompt the user for a filename.
b. Call the weather read_data function.
c. Using the return value set the weather data dictionary.
b. Add weather data
a. Prompt the user for the date using the format YYYYMMDD.
b. Prompt the user for the time using the format hhmmss.
c. Prompt the user for the temperature.
d. Prompt the user for the humidity.
e. Prompt the user for the rainfall.
f. Add the above readings to the weather dictionary.
g. Call the weather write_data function.
c. Print daily report
a. Prompt the user for the date using the format YYYYMMDD.
b. Call the weather report_daily function.
c. Print out the return string.
d. Print historical report
a. Call the weather report_historical function.
b. Print out the return string.
e. Exit the program
Transcribed Image Text:3. Create a main driver program to meet the following requirements: i. Create a file named main.py. ii. Import the weather module. iii. Set a default filename to store the JSON data. iv. Declare a dictionary to hold the weather data. v. Implement a menu within a loop with following choices: a. Set data filename a. Prompt the user for a filename. b. Call the weather read_data function. c. Using the return value set the weather data dictionary. b. Add weather data a. Prompt the user for the date using the format YYYYMMDD. b. Prompt the user for the time using the format hhmmss. c. Prompt the user for the temperature. d. Prompt the user for the humidity. e. Prompt the user for the rainfall. f. Add the above readings to the weather dictionary. g. Call the weather write_data function. c. Print daily report a. Prompt the user for the date using the format YYYYMMDD. b. Call the weather report_daily function. c. Print out the return string. d. Print historical report a. Call the weather report_historical function. b. Print out the return string. e. Exit the program
Program Instructions
1. All the functions should accept the weather dictionary data structure as follows:
weather dictionary:
key datetime as string (formatted as YYYYMMDDhhmmss)
value readings dictionary
readings dictionary
for key : 't'
value: temperature as integer
for key 'h'
value: humidity as integer
for key: 'r'
value: rainfall as float
2. Create a weather module.
i. Create a function named _read_data which receives a keyword parameter filename.
a. The function should open the filename in read mode and return a dictionary of the JSON decoded
contents of the file.
b. If the file does not exist, the function should accept the FileNotFoundError and return an empty
dictionary.
ii. Create a function named write_data which receives a keyword parameter data and filename
a. The function should open the filename in write mode and write the dictionary data into the file
encoded as JSON.
iii. Create a function named max_temperature which receives a keyword parameter data and date
a. The function should return the maximum temperature for all dictionary data where the key contains
the date as YYYYMMDD.
iv. Create a function named min_temperature which receives a keyword parameter data and date
a. The function should return the minimum temperature for all dictionary data where the key contains
the date as YYYYMMDD.
v. Create a function named max_humidity which receives a keyword parameter data and date
a. The function should return the maximum humidity for all dictionary data where the key contains the
date as YYYYMMDD.
vi. Create a function named min_humidity which receives a keyword parameter data and date
a. The function should return the minimum humidity for all dictionary data where the key contains the
date as YYYYMMDD.
vii. Create a function named tot_rain which receives a keyword parameter data and date
a. The function should return the sum of rainfall for all dictionary data where the key contains the date
as YYYYMMDD.
viii. Create a function named report_daily which receives a keyword parameter data and date
a. The function should return a single string which when passed to any print function will display on the
screen formatted exactly as indicated in the example output below. You will most likely be appending
strings together using a literal "\n" where a newline is desired. To get the month name, you can
import the builtin calendar module and call the month_name function passing it the month as an
integer.
ix. Create a function named report_historical which receives a keyword parameter data
a. The function should return a single string which when passed to any print function will display on the
screen formatted exactly as indicated in the example output below. You will most likely be appending
strings together using a literal "\n" where a newline is desired. To get the month name, you can
import the builtin calendar module and call the month_name function passing it the month as an
integer.
Transcribed Image Text:Program Instructions 1. All the functions should accept the weather dictionary data structure as follows: weather dictionary: key datetime as string (formatted as YYYYMMDDhhmmss) value readings dictionary readings dictionary for key : 't' value: temperature as integer for key 'h' value: humidity as integer for key: 'r' value: rainfall as float 2. Create a weather module. i. Create a function named _read_data which receives a keyword parameter filename. a. The function should open the filename in read mode and return a dictionary of the JSON decoded contents of the file. b. If the file does not exist, the function should accept the FileNotFoundError and return an empty dictionary. ii. Create a function named write_data which receives a keyword parameter data and filename a. The function should open the filename in write mode and write the dictionary data into the file encoded as JSON. iii. Create a function named max_temperature which receives a keyword parameter data and date a. The function should return the maximum temperature for all dictionary data where the key contains the date as YYYYMMDD. iv. Create a function named min_temperature which receives a keyword parameter data and date a. The function should return the minimum temperature for all dictionary data where the key contains the date as YYYYMMDD. v. Create a function named max_humidity which receives a keyword parameter data and date a. The function should return the maximum humidity for all dictionary data where the key contains the date as YYYYMMDD. vi. Create a function named min_humidity which receives a keyword parameter data and date a. The function should return the minimum humidity for all dictionary data where the key contains the date as YYYYMMDD. vii. Create a function named tot_rain which receives a keyword parameter data and date a. The function should return the sum of rainfall for all dictionary data where the key contains the date as YYYYMMDD. viii. Create a function named report_daily which receives a keyword parameter data and date a. The function should return a single string which when passed to any print function will display on the screen formatted exactly as indicated in the example output below. You will most likely be appending strings together using a literal "\n" where a newline is desired. To get the month name, you can import the builtin calendar module and call the month_name function passing it the month as an integer. ix. Create a function named report_historical which receives a keyword parameter data a. The function should return a single string which when passed to any print function will display on the screen formatted exactly as indicated in the example output below. You will most likely be appending strings together using a literal "\n" where a newline is desired. To get the month name, you can import the builtin calendar module and call the month_name function passing it the month as an integer.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 7 images

Blurred answer
Knowledge Booster
Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT