This Python program reads the volume of water consumed (in cubic meters) and the type of usage—residential, commercial, or industrial.
Based on the input, it calculates the total payable amount according to the following rules:
def calculate_water_bill(volume, usage_type):
if usage_type == "residential":
if volume < 80:
rate = 2500
elif volume <= 120:
rate = 3000
else:
rate = 3500
elif usage_type == "commercial":
if volume < 150:
rate = 4000
else:
rate = 4500
elif usage_type == "industrial":
rate = 5000
else:
print("Invalid usage type.")
return None
total = volume * rate
return total
# Run the program
volume = float(input("Enter water consumption (m³): "))
usage_type = input("Enter usage type (residential, commercial, industrial): ")
bill = calculate_water_bill(volume, usage_type)
if bill is not None:
print(f"Total payable amount: {bill:.0f} Rials")
Total payable amount: 300000 Rials
- The program reads the water volume and usage type from the user
- It applies the correct rate based on the usage category and volume
- Residential rates are tiered; commercial rates are split into two bands; industrial has a flat rate
- The final bill is calculated and displayed in Rials