Task:
Write functions for each container type.
Prompt the end-user to enter the volume of water for the pool, then produce a report with the number needed of each container.
Given a swimming pool with a specific volume of water tell me how many of each do I need to empty the pool, and if anything remains, how much? Each container has to be filled to it's maximum capacity. For example a 74 gallon pool will fill 2 garbage cans and 1 bucket, with nothing remaining.
Volumes
Garbage can = 32 gallons
Bucket = 5 gallons
Pail = 1 gallon
Quart = .25 gallons
Pint = .125 gallons
Cup = .0625 gallons
Be able to write this in python
Python code:
# Defining findVolume function
def findVolume(volume):
# if volume is greater than or equal to 32
gallons.
if(volume >=32):
n = volume//32
print(int(n),'Garbage can') # display Garbage
cans.
st = n*32
volume = volume-st # Remaining volume.
# if volume is greater than or equal to 5
gallons.
if(volume >=5):
n = volume//5
print(int(n),'Bucket')
st = n*5
volume = volume -st # Remaining volume.
# if volume is greater than or equal to 1
gallons.
if(volume >=1):
n = volume//1
print(int(n),'Pail')
st = n*1
volume = volume-st # Remaining volume.
# if volume is greater than or equal to 0.25
gallons.
if(volume >=0.25):
n = volume//0.25
print(int(n),'Quart')
st = n*0.25
volume = volume-st
# if volume is greater than or equal to 0.125
gallons.
if(volume >=0.125):
n = volume//0.125
print(int(n),'Pint')
st = n*0.125
volume = volume-st # Remaining volume.
# if volume is greater than or equal to 0.0625
gallons.
if(volume >=0.0625):
n = volume//0.0625
print(int(n),'Cup')
s = n*0.0625
volume = volume - st # Remaining volume.
# display the Remaining volume
print('Remaining volume:',round(volume,3))
# __name__
if __name__=="__main__":
# Taking the user input and storing it in variables name
volume.
volume=float(input('Enter the volume of water for the pool:
'))
# display the message
print(volume,'gallon pool will fill: ')
# Calling the findVolume method with 1
parameter.
findVolume(volume)
Python code screenshot:


OUTPUT:

Task: Write functions for each container type. Prompt the end-user to enter the volume of water...