~3 min read • Updated Oct 11, 2025
Program Overview
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:
Pricing Rules:
- Residential:
- If volume < 80 → 2500 Rials per m³
- If 80 ≤ volume ≤ 120 → 3000 Rials per m³
- If volume > 120 → 3500 Rials per m³
- Commercial:
- If volume < 150 → 4000 Rials per m³
- If volume ≥ 150 → 4500 Rials per m³
- Industrial:
- Flat rate → 5000 Rials per m³
Python Code:
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")
Sample Output (input: 100 m³, usage type: residential):
Total payable amount: 300000 Rials
Step-by-Step Explanation:
- 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
Written & researched by Dr. Shahin Siami