Question 27: If Elif Else

Write a Python program to check if a water tank is full, half-full, or empty based on the water level and tank capacity.

Instructions:

  1. Ask the user for the tank’s name and store it in a variable called tank_name.

  2. Ask for the water level in the tank (in liters) and store it in a variable called water_level (as a float).

  3. Ask for the tank’s total capacity (in liters) and store it in a variable called tank_capacity (as a float).

  4. Calculate the fill percentage using the formula:

    fill_percentage = (water_leveltank / capacity)
  5. Use an if-elif-else structure to check the water level:

    • If fill_percentage is 100% or more, print:
      "Warning, [tank_name]! Your tank is full or overflowing! Stop adding water!"
    • If fill_percentage is between 50% and 99%, print:
      "Good, [tank_name]! Your tank is more than half full."
    • If fill_percentage is between 1% and 49%, print:
      "Caution, [tank_name]! Your tank is less than half full. Consider refilling soon!"
    • If fill_percentage is 0%, print:
      "Empty, [tank_name]! Your tank is completely empty. Please refill!"
    • If tank_capacity is 0, print:
      "Error: Tank capacity cannot be zero. Please check the input values for [tank_name]."
Write what you are looking for, and press enter to begin your search!