class ElectricityBill:
def __init__(self, units_consumed):
self.units_consumed = units_consumed
def calculate_bill(self):
total_charge = self.base_charge + (self.units_consumed * self.rate_per_unit
return total_charge
def generate_bill(self):
print("Electricity Bill:")
print("Units consumed:", self.units_consumed)
print("Base Charge:", self.base_charge, "INR")
print("Charge per unit:", self.rate_per_unit, "INR")
print("Total Bill:", self.calculate_bill(), "INR")
class RuralElectricityBill(ElectricityBill):
def __init__(self, units_consumed):
super().__init__(units_consumed)
self.base_charge = 30 # Base charge for rural areas in INR
self.rate_per_unit = 5 # Rate per unit for rural areas in INR
class UrbanElectricityBill(ElectricityBill):
def __init__(self, units_consumed):
super().__init__(units_consumed)
self.base_charge = 50 # Base charge for urban areas in INR
self.rate_per_unit = 5 # Rate per unit for urban areas in INR
# Example usage
rural_units_consumed = float(input("Number of Units (KWH) for Rural: "))
urban_units_consumed = float(input("Number of Units (KWH) for Urban: "))
rural_electricity_bill = RuralElectricityBill(rural_units_consumed)
urban_electricity_bill = UrbanElectricityBill(urban_units_consumed)
print("\nRural Electricity Bill:")
rural_electricity_bill.generate_bill()
print("\nUrban Electricity Bill:")
urban_electricity_bill.generate_bill()