PYTHON PROGRAMMING - CODE THE PROGRAM BASED ON THE INSTRUCTIONS AND ALGORITHM PROVIDED
home / study / engineering / computer science / questions and answers / python programming - code the program based on ...
Your question has been answered! Rate it below.
Let us know if you got a helpful answer.
Question: PYTHON PROGRAMMING - CODE THE PROGRAM BASED ON THE...
Bookmark
PYTHON PROGRAMMING - CODE THE PROGRAM BASED ON THE INSTRUCTIONS AND ALGORITHM PROVIDED
Rainfall Algorithm
Declare and initialize variables and constants
int numYears, numMonths
float monthlyRain, totalRain, averageRain
Intro
while numYears < 1:
prompt for numYears
if numYears < 1:
Display Invalid
for year in range(1,numYears + 1):
for month range(1,13):
while monthlyRain <= 0:
Prompt for monthlyRain
if monthlyRain <= 0:
Display Invalid
Add to accumulator
totalRain += monthlyRain
Calculate numMonths
numMonths = numYears * 12
Calculate averageRain
averageRain = totalRain / numMonths
Display numMonths, totalRain, averageRain
# Variables need to be created to reference total rainfall, monthly rainfall, # average rainfall, the number of years, and the total number of months total_rainfall = 0.0 monthly_rainfall = 0.0 average_rainfall = 0.0 years = 0 total_months = 0 # Ask the user for the number of years years = int(input('Enter the number of years: ')) # Write a for loop and incorporate an accumulator variable to keep a running total for years in range(years): print('For year:', years + 1) for month in range(12): monthly_rainfall = float(input('Enter the inches of rainfall for the month: ')) total_months += 1 # Add to the total rainfall month total_rainfall += monthly_rainfall # Calculate average rain fall for the total period average_rainfall = total_rainfall / total_months print('For', total_months, 'months') print('Total rainfall: ', format(total_rainfall, '.2f'), 'inches') print('Average monthly rainfall: ', format(average_rainfall, '.2f'), 'inches')
PYTHON PROGRAMMING - CODE THE PROGRAM BASED ON THE INSTRUCTIONS AND ALGORITHM PROVIDED home / study...
Write them in python IDLE ***** 5. Average Rainfall Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should 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 iterations,...
qbasic is the programming language Chapter 8 Do Programming Exercise 8-3 om page 414. Create a string array to hold the months of the year. Call it anything you want to just make sure it's a string array is at the end of the name, e.g. months). Create a DATA statement that holds the month names: DATA "jan","Feb", "Mar" etc. Next you'll need a FOR loop to READ the DATA into the array, Call a SUB to get the rainfall...
the code is in visual basic 376 Chapter 6 Loop Structures Case Programming Assignments con Most Rainfall in the USA USE CASE DEFINITION e Windows application opens with the heading "Most Rainfall in US - Kauai," a ListBox object that displays the monthly rainfall amounts, an i amounts in inches mage, and a Button object that allows the user to begin entering their rainfall 2. A menu bar displays the File menu, which has two menu items: Clear and Exit....
Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should prompt the user for the number of years. Be sure to ask for each months average rainfall for each year. The outer loop will iterate once for each year while the inner loop will iterate 12 times(one time per month) prompting for the months average rainfall on each iteration. Display the number of months, the total inches...
Python Programming 4th Edition: Write a program that asks the user for the number of feet. The program converts those feet to inches by using the formula ’12 * feet’. Hint: Define main () program Get the number of feet from the user Define variables Call a function feet_to_inches(feet) The function receives the number of feet and returns the number of inches in that many feet. The output should look like as follows: Enter the number of feet: If the...
(PYTHON) Write a program that displays the following menu:. , Write Algorithm for Code Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your choice (1 - 4): If the user enters 1, the program should ask for the radius of the circle and then display its area. If the user enters 2, the program should ask for the length and width of...
Data Programming l: PYTHON 1. Write a program that computes your gross pay. Your code should get two numbers: hours and rate per hour. You should give the employee 1.75 times the hourly rate for hours worked above 40 hours. Output: Your gross pay is $487.5 2. Rewrite the previous program using try and except so that your program handles non-numeric inputs gracefully by printing a message and exiting the program. The following shows two executions of the program with...
Hello I am taking an Introduction to Programming class and I need help coming up with a Psuedocode for an algorithm. Here is the assignment: 1. Use an array to prompt the user to enter a credit card account number 2. Use the sequential search algorithm to locate the credit card number entered by the user 3. If the credit card number is NOT in the array, display a message indicating the number is invalid 4. If the credit card...
Write a python program where you create a list (you an create it in code you do not have to use input() statements) that represents the total rainfall for each of 12 months (assume that element 0 is January and element 11 is December). The program should calculate and display the: 1) total rainfall for the year; 2) the average monthly rainfall; 3) the months with the highest and lowest amounts. You need to figure out how to access each...
Python program. Character-Analysis Program Problem Statement: Design a program - IN PYTHON - that asks the user to enter a string. The string will then be displayed back to the user. This is followed by determining the number of alphabetic characters, numeric characters, lower_case letters, upper_case letters, whitespace characters, and then displaying them. The user should be given additional chances to enter additional strings, and each time a string is entered, the above process is to be performed. The inputting...