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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Step 1

According to the information given:-

We have to follow the instruction in order to get the desired outcome.

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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education