Ad

Calculate Total Litres Required To Fill Carpark Using Python3

- 1 answer

I have to work out how many liters of concrete can fit into a park. Len park: 30.2m | wid of the park: 10m | liters per sq/m: 6.6. I have attempted this and am new to python and know how to calculate the total. (30.2 * 10 * 6.6 = total). But I'm struggling to print the result.

length = 30.2

width = 10

squared = 6.6

length = int(input('Length of park (m):'))

width = int(input('Width of park (m):'))

squared = int(input('Litres per square metre:'))

sum = length * width * squared # calculate total metres to get answer

print("Litres Required =",sum)

# print total amount of liters required 
Ad

Answer

"30.2" is a float since it has a decimal point, not an int.

sum is a keyword in python, so avoid using it as a variable name.

Try it online! (note, since this is a website, the output is different than you running it normally)

length = float(input('Length of park (m):'))

width = float(input('Width of park (m):'))

squared = float(input('Litres per square metre:'))

total = length * width * squared # calculate total metres to get answer

print("Litres Required =",total)

# print total amount of liters required 
Ad
source: stackoverflow.com
Ad