Python Program to Calculate Electricity Bill
Write a Program in Python to Calculate Electricity Bill.
Output
Calculate Electricity Bill - with AND Operator
Example: Code Program
Output
The
rates of Electricity Per Unit are as follows
If the unit consumed <= 100, then the rate of unit is 2 =
unit * 2
If the unit consumed >100 and <=200, then the rate of
unit is 4 (100<unit <=200) = unit * 4
If the unit consumed>200 and <=300, then the rate of
unit is 8 (200<unit<=300) = unit *8
If the unit consumed>300 and <=400, then the rate of
unit is 12 (300<unit<=400) = unit *12
If the unit consumed exceed 400 then then rate of unit is 16
(unit > 400) = unit * 16
Additional Charges:
Line Rent 200 is also Added to the total bill
If total bill exceeds 2000 then 5% Tax is added in total
bill
Example: Code Program
unit = int(input("Enter Units consumed"))
if unit >400:
bill = unit*16
elif unit>300:
bill = unit*12
elif unit>200:
bill = unit*8
elif unit>100:
bill = unit*4
else:
bill = unit*2
bill = bill+200
print("bill is:", bill)
if bill>200:
bill =bill+int(bill*.05)
print("Total Bill is:",bill)
else:
print("Total Bill is:", bill)
if unit >400:
bill = unit*16
elif unit>300:
bill = unit*12
elif unit>200:
bill = unit*8
elif unit>100:
bill = unit*4
else:
bill = unit*2
bill = bill+200
print("bill is:", bill)
if bill>200:
bill =bill+int(bill*.05)
print("Total Bill is:",bill)
else:
print("Total Bill is:", bill)
Output
Calculate Electricity Bill - with AND Operator
Example: Code Program
unit = int(input("Enter Units consumed:")) if unit >400: bill = unit*16 elif unit>300 and unit <=400: bill = unit*12 elif unit>200 and unit <=300: bill = unit*8 elif unit>100 and unit<=200: bill = unit*4 else: bill = unit*2 bill = bill+200 print("Bill Per Unit and Lane Rent is:", bill) if bill>2000: bill =bill+(bill*.05) print("Total Bill is:",bill) else: print("Total Bill is:", bill)
Post a Comment