Question
Instructions Please write a simplealgorithmand then code it inpythonfor the following problem: Hurricane Preparedness A program is needed to determine how many gallons of water
Instructions
Please write a simplealgorithmand then code it inpythonfor the following problem:
Hurricane Preparedness
A program is needed to determine how many gallons of water a family will need to have on hand for a hurricane, assuming 1 gallon per person per day. The program must ask the user how many people and how many days reserve will be needed. Display the results back to the user.
Make sure to:
-define a main function
-have header comments
-use variables that are descriptive (declare and initialize them too)
-use a constant to represent the gallons per person per day
-have your algorithm copied into the program as the comments
-introduce your program
-make code readable
-make output user friendly (using blank lines, spacing, and understandable questions)
================================================================
can someone tell me where I went wrong?
"""
Algorithm: 1.)Find out how many people need water 2.)Ask how many days reserve will be needed 3.)Display the results back to the user """ def main(): #Prompt and read the number of persons in the family numberOfPersons = int(input("How many persons are there in the family?")) #Prompt and read the number of days reserve is needed numberOfDays = int(input("How many days the reserve is needed?")) #Compute the water reserve needed waterRequired = numberOfPersons * numberOfDays #Display the result to the user print(" For{}days,a family of {} persons need to have {} gallons of water reserved for a hurricane.",format(numberOfDays, numberOfPersons, waterRequired))
main()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started