ASSIGNMENT
Q.8
Q.8 Write a Python program to calculate the monthly electricity bill of a customer based on the number of units consumed.
For first 50 units Rs. 0.50/unit
For next 100 units Rs. 0.75/unit
For next 100 units Rs. 1.20/unit
For unit above 250 Rs. 1.50/unit
An additional surcharge of 20% is added to the billĀ
units = float(input("Enter the number of units consumed: ")) if units <= 50: bill = units * 0.50 elif units <= 150: bill = (50 * 0.50) + ((units - 50) * 0.75) elif units <= 250: bill = (50 * 0.50) + (100 * 0.75) + ((units - 150) * 1.20) else: bill = (50 * 0.50) + (100 * 0.75) + (100 * 1.20) + ((units - 250) * 1.50) total_bill = bill + (bill * 0.20) print("Electricity Bill (Before Surcharge): Rs.", round(bill, 2)) print("Surcharge (20%): Rs.", round(bill * 0.20, 2)) print("Total Electricity Bill: Rs.", round(total_bill, 2))


