Write a Python program to check if a water tank is full, half-full, or empty based on the water level and tank capacity.
Ask the user for the tank’s name and store it in a variable called tank_name
.
Ask for the water level in the tank (in liters) and store it in a variable called water_level
(as a float).
Ask for the tank’s total capacity (in liters) and store it in a variable called tank_capacity
(as a float).
Calculate the fill percentage using the formula:
fill_percentage = (water_leveltank / capacity) × 100Use an if-elif-else
structure to check the water level:
"Warning, [tank_name]! Your tank is full or overflowing! Stop adding water!"
"Good, [tank_name]! Your tank is more than half full."
"Caution, [tank_name]! Your tank is less than half full. Consider refilling soon!"
"Empty, [tank_name]! Your tank is completely empty. Please refill!"
"Error: Tank capacity cannot be zero. Please check the input values for [tank_name]."
We’re always looking for international STEM educators to join our team. If you are interested, please send us a mail and we’ll get back to you!
If you have any questions, kindly send us a mail. Don’t forget to follow and like all our social accounts to get updates on competitions!