Electricity Bill Generation



Electricity GIFs | Tenor


There are 1000 consumers of electricity in a locality. The consumers fall into either of the two categories:-
     (a) Domestic Consumer 
     (b) Industrial Consumer

Rate slab of Domestic consumer
        For first 100 units the charge is Rs.40.  For the next 200 units, the charges are 40 
        paise per unit. The further excess units are charged at 60 paise per unit.

 Rate slab of Industrial consumer
        For first 600 units the charge is 60 paise per unit. For the next 600 units, charges 
        are 80 paise per unit. The further excess units are charged at 90 paise per unit.

Taking Consumer Number, Name of Consumer, Category, Previous Reading and Current Reading as inputs- an electricity bill for a consumer is to be computed.

CODING 💻

def domestic(units):
    if(units<=100):
        amt=40.0
    if(units>100.0 and units<=300):
        amt=40.0+(units-100)*0.40
    if(units>300):
        amt=40.0+200*0.40+(units-300)*0.60
    return amt

def industrial(units):
    if(units<=600):
        amt=units*0.60
    if(units>600 and units<=1200):
        amt=(units-600)*0.80
    if(units>1200):
        amt=600*0.80+(units-1200)*0.90
    return amt

amt=0.0
cons=int(input("Consumer number  "))
name=input("Name of consumer  ")

pr=int(input("Previous reading  "))
cr=int(input("Current reading  "))
cat=input("Category: domestic/industrial  ")

units=cr-pr
if(cat=='domestic'):
    amt=domestic(units)
elif(cat=='industrial'):
    amt=industrial(units)

print("Consumer number" ,cons)
print("Name" ,name)
print("Previous reading" ,pr)
print("Current reading" ,cr)
print("Unit consumed" ,units)
print("Category" ,cat)
print("Amount" ,amt)


ELECTRICITY BILL💡

Consumer number  3754
Name  Shinjini Das
Previous reading  275
Current reading    400
Unit consumed  125
Category   domestic
Amount  50.0

Comments

Most Viewed Posts