Python Forum

Full Version: float parameter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
An Olympic-size swimming pool is 25 meters wide and 50 meters long (rectangular). The minimum of depth of the pool is 2 meters. So I need to write a function that takes a float parameter (depth) and return the volume of the pool. If the depth does not meet the minimum depth requirement of Olympic-size pool, return zero.
here is my code:
def pool_volume(depth):
x=float(x)
if x<2 :
return 0
else:
return 25*50*x
What is the mistake?
def pool_volume(depth):
    
    if depth>=2:
        return 25*50*depth
    else:
        return 0