answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
defon
2 years ago
3

Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program sh

ould first ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate twelve times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all the iterations, the program should display the number of months, the total inches of rainfall, and the average rainfall per month for the entire period.

Computers and Technology
1 answer:
Andreas93 [3]2 years ago
7 0

Answer:

Here is the Python program:

#prompts user to enter no of years

years = int(input('Enter the number of years: '))  

months = 12  # stores no of months in a year i.e. 12

sum = 0   # stores the total inches of rainfall

if years < 1: #if input year value is less than 1

    print("Invalid year")        #displays invalid year message

else:  #if input year value is greater than greater than 0

   for year in range(years):  #iterates once for every year

       print('For year: ', year + 1,' ')  #prints For year for each input year

       for month in range(months):   # iterates for each month 12 times

           print('Enter the inches of rainfall for month ', month + 1,' ')

#asks user for inches of rainfall for each of 12 months

           rainfall = int(input())  # takes value of rainfall inches for each month

           sum = sum + rainfall  # stores total rainfall inches

           

   total_months = years * months  #stores number of months

   average_rainfall = sum / total_months  #store average rainfall per month

       

print('Total inches of rainfall: ', sum) # prints total rainfall inches

print('Number of months: ', total_months)  #print total months

print('Average rainfall per month: ', format(average_rainfall, '.3f'), 'inches')

#prints the value of average rainfall per month up to 3 decimal places

Explanation:

This program uses nested loops to take data from user and calculate average rainfall over a period of years. The program prompts user to enter the number of years and the outer loop iterates for each year entered by the user. For example if user entered 3 then the outer loop iterates 3 times for each year 1, year 2 and year 3. The inner loop asks user for inches of rainfall for each of the 12 months so it iterates 12 times. For example for 3 years and 12 months in each year the inner loop asks the user 36 times to enter rainfall inches. Every time the rainfall inches are given by user that value is added to the total value (sum) at every iteration. Then the total_months value is calculated by multiplying input year with months. If input year is 3 then total_months= 3 * 12 = 36. The average rainfall is calculated by dividing value of sum to value of total_months. Finally these values are displayed on output screen using print(). The program along with output is attached.

You might be interested in
If you were investigating login issues on a Windows computer, which portion of the Event Viewer logs would be a good place to st
USPshnik [31]

Answer:

If we are investigating login issues then we have to start with 'security logs' in 'windows logs' portion of Event viewer.

Explanation:

Much information about login issues is contained in log files which are related to security because it is mostly security issue. Some it is also better to start with 'system logs' portion of windows logs portion of Event viewer when there may be system problems instead of security issues. But in most cases there is security issues so 'security logs' is better option overall

6 0
2 years ago
Which of the following option is correct about HCatalog?
adell [148]

Answer:

Option (3) is the correct answer of this question.

Explanation:

  • HCatalog makes available Hive metadata to users of other Hadoop applications, such as Pig, MapReduce and Hive. it offers interfaces for MapReduce and Pig so that users can read data from and write data to the Hive warehouse.
  • This means users don't have to care about where or in what format their data is stored. So we know this way that Hcatalog makes sure our data is secure.
  • Others option does not belong to Hcatalog so these options are incorrect .

8 0
2 years ago
Which features should a study schedule include? Check all that apply.
Ivenika [448]

Answer: time of day, duration, due dates

Explanation: I am awsome

7 0
2 years ago
Read 2 more answers
The hostel in which you plan to spend the night tonight offers very interesting rates, as long as you do not arrive too late. Ho
faust18 [17]

Answer:

Answered below

Explanation:

// Python implementation

incrementAmount = 5

basePrice = 10

price = 0

arrivalHour = int(input("Enter arrival hour 0-12: ")

if arrivalHour < 0 or arrivalHour > 12:

print ("Invalid hour")

if arrivalHour == 0:

price = basePrice

else:

price = arrivalHour * incrementAmount

totalPrice = price + basePrice

if totalPrice > 53:

totalPrice = 53

print ("Your bill is $totalPrice")

4 0
2 years ago
A customer wants to increase his storage capacity by 25gb
Tom [10]

The answer is "SSD-25GB", and its further calculation can be defined as follows:

  • The <u><em>current generation of computer storage devices</em></u> is a hard drive (SSD).
  • It uses a flash memory that is substantially faster than a conventional mechanical disc.
  • The user does not require Storage or GPU, Video Card cannot be used.
  • RAM is a memory volatile that cannot be utilized as storage media.
  • SSD is better than magnetic HDD in terms of speed and performance.
  • SSD has become substantially quicker than USB 3.0.

That's why the answer is "SSD-25GB".

Learn more:

brainly.com/question/14411313

7 0
1 year ago
Other questions:
  • What are common names for some primary discrete components used on circuit boards?
    13·1 answer
  • A company wants to publish Knowledge articles to its Customer Community. The articles should be organized for easy navigation by
    6·1 answer
  • Convert to octal. Convert to hexadecimal. Then convert both of your answers todecimal, and verify that they are the same.(a) 111
    12·1 answer
  • The term Electronic Privacy Information Center (EPIC) refers to a form of the digital subscriber line technology, which enables
    6·1 answer
  • Write a script named numberlines.py. This script creates a program listing from a source program. This script should: Prompt the
    7·1 answer
  • 1.the following code example would print the data type of x, what data type would that be?
    12·1 answer
  • Show how the recursive multiplication algorithm computes XY, where X = 1234 and Y = 4321. Include all recursive computations.
    11·1 answer
  • Find the sum of the squares of the integers from 1 to MySquare, where MySquare is input by the user. Be sure to check that the u
    6·1 answer
  • 5.16 *zyLab: Hello IDE The goal of this problem is learn how to use Eclipse or IntelliJ. Submit the source code files (.java) be
    12·1 answer
  • Which of the following statements best describes the relative amount of content held by digital libraries vs. the amount held by
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!