Electricity Bill Calculation
- For 0 to 100 units, the per unit is Zero
- For 0 to 200 units, for the First 100 unit the per unit cost is Zero and the next 100 units, the consumer shall pay Rs. 1.5 per unit.
- For 0 to 500 units, the consumer shall pay Rs. 0 for the first 100 units, for the next 100 units the consumer shall pay Rs. 2 per unit, for the next 300 units the unit cost is Rs.3 per unit
- For Above 500 units, the per unit cost is as shown in the table.
Program Code:
def des():
print("...........................................")
print('\t'"ELECTRICITY BILL CALCULATION")
print("...........................................")
def calc():
while(1):
print('\t'"Consumer Details")
print('\t'"~~~~~~~~~~~~~~~~")
num=int(input("Enter Service Number: "))
name=input("Enter Consumer Name: ")
cur=int(input("Enter Current Month Reading: "))
pre=int(input("Enter Previous Month reading: "))
print('\n'"`````````````````````````````````````")
print('\t'"Unit & Amount Calculation")
print('\t'"~~~~~~~~~~~~~~~~~~~~~~~~~")
units=cur - pre
print("Number of Unit Consumed:",cur,"-",pre,"=",units)
if(units<0):
print("Invalid Input")
exit(0)
else:
if(units>=0 and units<=100): #Scheme 1 (0 to 100)
Amount=units*0
print("Amount : Rs.",Amount)
fixedcharge=0.00
print("Fixed Amount: Rs.",fixedcharge)
elif(units>100 and units<=200): #Scheme 2 (0 to 200)
Amount=(100*0)+(units-100)*1.5
print("Amount : Rs.",Amount)
fixedcharge=20.00
print("Fixed Amount: Rs.",fixedcharge)
elif(units>200 and units<=500): #Scheme 3 (0 to 500)
Amount=(100*0)+(200-100)*2+(units-200)*3
print("Amount : Rs.",Amount)
fixedcharge=30.00
print("Fixed Amount: Rs.",fixedcharge)
else: #Scheme 4 (>500)
Amount=(100*0)+(200-100)*3.5+(500-200)*4.6+(units-500)*6.6
print("Amount : Rs.",Amount)
fixedcharge=50.00
print("Fixed Amount: Rs.",fixedcharge)
Total= Amount+fixedcharge
print("Total Amount:",Amount,"+",fixedcharge,"= Rs.",Total)
print("`````````````````````````````````````")
print('\n'"*******************************")
print('\t'"EB Bill Receipt")
print('\t'"~~~~~~~~~~~~~~~")
print("Service Number :",num)
print("Consumer Name :",name)
print("Units Consumed :",units)
print("Bill Amount : Rs.",Total)
print("*******************************")
ch=input("Do u want 2 Continue? y/n: ")
if ch=='n':
break
#Function Call
des()
calc()
Output:
Comments