Question

Write a beginner's Python program to determine how many gallons of water it would take to...

Write a beginner's Python program to determine how many gallons of water it would take to fill your pool, or your garage (if it were perfectly rectangular; ignore curves and cutouts), then calculate your water bill. In this challenge, you must choose your own input variables, variable names, and design your own tests to verify the program operation. The water used should be placed in an output variable called "gallons_used" and the cost should be placed in a variable called "water_cost"

When you click the Run Button, your program will be executed, and the value of the "gallons_used" and "water_cost" variables will be printed below.

Homework Answers

Answer #1

Code:

length=int(input("Enter the Length of Pool in Feets : ")) #asking user to enter the length of pool in feets

breadth=int(input("Enter the Breadth of Pool in Feets : ")) #asking user to enter breadth of the pool in feets

depth=float(input("Enter the Depth of Pool in Feets : ")) #asking user to enter the depth of pool in feets
  
cost_of_gallon=3 #Assume cost of one gallon is 3 dollars

pool_volume=length*breadth*depth #finding volume of pool by multiplying length,breadth and depth

gallons_used=pool_volume*7.5 #7.5 is the multiplicating factor to calculate the no of gallons for rectangular and square type of pools

water_cost=gallons_used*cost_of_gallon #multiply cost_of_gallong with no_of_gallons

print("No of Gallons of water to fill the pool " + str(gallons_used)) #print the no of gallons of water required to fill the pool

print("Cost of water is $" + str(water_cost)) #print the cost of water

Code and Output Screenshots:

Note : Here the program has implemented in such a way that all values should be entered by user. The multiply factor 7.5 is used to calculate volume in gallons for square and rectangular type of pools.

Note : if you have any queries please post a comment thanks a lot..always available to help you..

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Please do the following in python: Write a program (twitter_sort.py) that merges and sorts two twitter...
Please do the following in python: Write a program (twitter_sort.py) that merges and sorts two twitter feeds. At a high level, your program is going to perform the following: Read in two files containing twitter feeds. Merge the twitter feeds in reverse chronological order (most recent first). Write the merged feeds to an output file. Provide some basic summary information about the files. The names of the files will be passed in to your program via command line arguments. Use...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
Write a Python 3 program called “parse.py” using the template for a Python program that we...
Write a Python 3 program called “parse.py” using the template for a Python program that we covered in this module. Note: Use this mod7.txt input file. Name your output file “output.txt”. Build your program using a main function and at least one other function. Give your input and output file names as command line arguments. Your program will read the input file, and will output the following information to the output file as well as printing it to the screen:...
Use Python 3.8: Problem Description Many recipes tend to be rather small, producing the fewest number...
Use Python 3.8: Problem Description Many recipes tend to be rather small, producing the fewest number of servings that are really possible with the included ingredients. Sometimes one will want to be able to scale those recipes upwards for serving larger groups. This program's task is to determine how much of each ingredient in a recipe will be required for a target party size. The first inputs to the program will be the recipe itself. Here is an example recipe...
In this assignment you will write a program that compares the relative strengths of two earthquakes,...
In this assignment you will write a program that compares the relative strengths of two earthquakes, given their magnitudes using the moment magnitude scale. Earthquakes The amount of energy released during an earthquake -- corresponding to the amount of shaking -- is measured using the "moment magnitude scale". We can compare the relative strength of two earthquakes given the magnitudes m1 and m2 using this formula: f=10^1.5(m1−m2) If m1>m2, the resulting value f tells us how many times stronger m1...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT