LAB ASSIGNMENTS, CONT. avg rainfall.py: Write a program that collects rainfall data and calculates the average rainfall for a user-defined number of years. Ask the user for the number of years in their study - use a small number to test, like 2, because you have to collect 12 months of data for each year! The outer loop will run once for each year (hint: use range function). The inner loop will run once for each of 12 months, and ask the user for a rainfall amount for that month. The inner loop will accumulate a total for each year. The outer loop will finish by calculating average monthly rainfall for that year. At the end of each year, display the total for the year and the average. Challenge: add a feature to show the total and average rainfall for the entire study period (multi-year figures).

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter7: File Handling And Applications
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
LAB ASSIGNMENTS, CONT.
How many years are in your rainfall sample? 2
Rainfall info for year #1:
Enter rain for month # 1: 2
Enter rain for month # 2: 2
Enter rain for month # 3: 2
avg_rainfall.py: Write a program that collects rainfall data and calculates
the average rainfall for a user-defined number of years.
Enter rain for month # 4: 2
Enter rain for month # 5: 2
Enter rain for month # 6: 2
Enter rain for month # 7: 2
Ask the user for the number of years in their study - use a small number
to test, like 2, because you have to collect 12 months of data for each
year!
Enter rain for month # 8: 2
Enter rain for month # 9: 2
Enter rain for month #10: 2
Enter rain for month #11: 2
Enter rain for month #12: 2
Total rain in inches for year #1 = 24.0
Year #1 Monthly Avg Rainfall = 2.00
Rainfall info for year #2:
The outer loop will run once for each year (hint: use range function).
Enter rain for month # 1: 1
The inner loop will run once for each of 12 months, and ask the user for a
rainfall amount for that month. The inner loop will accumulate a total for each
Enter rain for month # 2: 1
Enter rain for month # 3: 1
Enter rain for month # 4: 1
year.
Enter rain for month # 5: 1
Enter rain for month # 6: 1
Enter rain for month # 7: 1
The outer loop will finish by calculating average monthly rainfall for that
Enter rain for month # 8: 1
Enter rain for month # 9: 1
year.
Enter rain for month #10: 1
Enter rain for month #11: 1
At the end of each year, display the total for the year and the average.
Enter rain for month #12: 1
Total rain in inches for year #2 = 12.0
Year #2 Monthly Avg Rainfall = 1.00
Challenge: add a feature to show the total and average rainfall for the
entire study period (multi-year figures).
Total rain, all years = 36.0 inches
Average monthly rain, all years = 1.5 inches
Thanks for using the program
Transcribed Image Text:LAB ASSIGNMENTS, CONT. How many years are in your rainfall sample? 2 Rainfall info for year #1: Enter rain for month # 1: 2 Enter rain for month # 2: 2 Enter rain for month # 3: 2 avg_rainfall.py: Write a program that collects rainfall data and calculates the average rainfall for a user-defined number of years. Enter rain for month # 4: 2 Enter rain for month # 5: 2 Enter rain for month # 6: 2 Enter rain for month # 7: 2 Ask the user for the number of years in their study - use a small number to test, like 2, because you have to collect 12 months of data for each year! Enter rain for month # 8: 2 Enter rain for month # 9: 2 Enter rain for month #10: 2 Enter rain for month #11: 2 Enter rain for month #12: 2 Total rain in inches for year #1 = 24.0 Year #1 Monthly Avg Rainfall = 2.00 Rainfall info for year #2: The outer loop will run once for each year (hint: use range function). Enter rain for month # 1: 1 The inner loop will run once for each of 12 months, and ask the user for a rainfall amount for that month. The inner loop will accumulate a total for each Enter rain for month # 2: 1 Enter rain for month # 3: 1 Enter rain for month # 4: 1 year. Enter rain for month # 5: 1 Enter rain for month # 6: 1 Enter rain for month # 7: 1 The outer loop will finish by calculating average monthly rainfall for that Enter rain for month # 8: 1 Enter rain for month # 9: 1 year. Enter rain for month #10: 1 Enter rain for month #11: 1 At the end of each year, display the total for the year and the average. Enter rain for month #12: 1 Total rain in inches for year #2 = 12.0 Year #2 Monthly Avg Rainfall = 1.00 Challenge: add a feature to show the total and average rainfall for the entire study period (multi-year figures). Total rain, all years = 36.0 inches Average monthly rain, all years = 1.5 inches Thanks for using the program
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Constants and 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
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,