eatherReport.txt" which contains a table summarizing the data where each h its low, high, and average temperatures, and its weather condition {Hot, Id, Freezing, Extreme}. Each line in the input file contains the city name, fo aperature readings taken during the day. Samples of input and output files are g quirements: e program must have at least 2 functions: 1. The main function: It reads the data from the input file, stores it in a list, t the data in a table with the weather condition for each city. It must call weatherCondition to find the condition. It may also call other functions if 2. The weatherCondition(low, high, average) function: It takes three parar high, and average temperatures), and returns the condition of the weathe according to the following table:

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
Write a Python program that analyses temperature information of some cities given in an
input file named "temperature.txt". The program outputs a
"WeatherReport.txt" which contains a table summarizing the data where each city is listed
with its low, high, and average temperatures, and its weather condition {Hot, Warm, Nice,
Cold, Freezing, Extreme}. Each line in the input file contains the city name, followed by 5
temperature readings taken during the day. Samples of input and output files are given below.
text file named
Requirements:
The program must have at least 2 functions:
1. The main function: It reads the data from the input file, stores it in a list, then displays
the data in a table with the weather condition for each city. It must call the function
weatherCondition to find the condition. It may also call other functions if needed.
2. The weatherCondition(low, high, average) function: It takes three parameters (low,
high, and average temperatures), and returns the condition of the weather as a string
according to the following table:
Temperature
Low (L)
Weather
Average (A)
High (H)
Η 240
H< 40
Condition
L>0
Hot
A> 25
L>0
Warm
20 2A2 25
L>0
H< 40
Nice
L>0
H< 40
Cold
A< 20
H< 40
Freezing
Extreme
LS0
Otherwise
For example, if the average temperature is 21 and it always stays between 0 and 40
during the day, then the weather condition is Nice. (Hint: Study the table carefully and
think of the best approach to find the condition. This will save your coding time later).
You program must be well-documented and work for any number of cities in general. All file
access (reading and writing) must be done in the main function. Both functions should be
optimized (using loops and lists to reduce the number of lines whenever possible).
Sample of Input file: temperature.txt (you can copy/paste and save below data as text
file for input)
Makkah
Almadina
Riyadh
Jeddah
33.3 30.1 35
20.5 30
15
44.9 41.5
38
40
40
30
35
35
25
16
8.5
15
-4
27
20
17
20
1
35
30
25
25
3.5
32
32
21
23
7
29
22
16
21.5
1.2
Dammam
Abha
Alhada
Tabouk
Transcribed Image Text:Write a Python program that analyses temperature information of some cities given in an input file named "temperature.txt". The program outputs a "WeatherReport.txt" which contains a table summarizing the data where each city is listed with its low, high, and average temperatures, and its weather condition {Hot, Warm, Nice, Cold, Freezing, Extreme}. Each line in the input file contains the city name, followed by 5 temperature readings taken during the day. Samples of input and output files are given below. text file named Requirements: The program must have at least 2 functions: 1. The main function: It reads the data from the input file, stores it in a list, then displays the data in a table with the weather condition for each city. It must call the function weatherCondition to find the condition. It may also call other functions if needed. 2. The weatherCondition(low, high, average) function: It takes three parameters (low, high, and average temperatures), and returns the condition of the weather as a string according to the following table: Temperature Low (L) Weather Average (A) High (H) Η 240 H< 40 Condition L>0 Hot A> 25 L>0 Warm 20 2A2 25 L>0 H< 40 Nice L>0 H< 40 Cold A< 20 H< 40 Freezing Extreme LS0 Otherwise For example, if the average temperature is 21 and it always stays between 0 and 40 during the day, then the weather condition is Nice. (Hint: Study the table carefully and think of the best approach to find the condition. This will save your coding time later). You program must be well-documented and work for any number of cities in general. All file access (reading and writing) must be done in the main function. Both functions should be optimized (using loops and lists to reduce the number of lines whenever possible). Sample of Input file: temperature.txt (you can copy/paste and save below data as text file for input) Makkah Almadina Riyadh Jeddah 33.3 30.1 35 20.5 30 15 44.9 41.5 38 40 40 30 35 35 25 16 8.5 15 -4 27 20 17 20 1 35 30 25 25 3.5 32 32 21 23 7 29 22 16 21.5 1.2 Dammam Abha Alhada Tabouk
Expert Solution
steps

Step by step

Solved in 3 steps with 5 images

Blurred answer
Knowledge Booster
User Defined DataType
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
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