DIGIT-ARC read-only archive · snapshot: July 23, 2026

Pybiller-My first python prog to calc elec bill

4 posts · originally from https://geek.digit.in/community/threads/pybiller-my-first-python-prog-to-calc-elec-bill.118136/

G
gopi_vbboy Original post #1
Jun 8, 2009 at 9:15 AM
Code:
#gopi_vbboy-8/06/09
#Pybiller:Billing for A.P.DCL Tarrif
#change as per ur tarrif
#  0-50       145
#  51-100     280
# 101-200     305
# 201-300     475
#Above 300     550

#slabs
s1=51
s2=101
s3=201
s4=301




#cost for each slabs
a=1.45
b=2.8
c=3.05
d=4.75
e=5.5


print("Enter Net Units")

kwh=int(input())

if kwh<s1:
    print("Cost Rs",kwh*a)
elif kwh<s2:
    print("Cost Rs",(s1-1)*a+(kwh-s1)*b)
elif kwh<s3:
    print("Cost Rs",(s1-1)*a+(s2-s1)*b+(kwh-s2+1)*c)
elif kwh<s4:
    print("Cost Rs",(s1-1)*a+(s2-s1)*b+ (s3-s2)*c+(kwh-s3+1)*d)
elif kwh>s4:
    print("Cost Rs",(s1-1)*a+(s2-s1)*b+ (s3-s2)*c+(s4-s3)*d+(kwh-s4+1)*e)

print("+25-40rs tax/charges")
pls comment...my first python prog... learning now..:-D
Nawab
Nawab #2
Jun 9, 2009 at 10:15 AM
nice try... its good you r also following indentation

it'll help in larger code debugging... keep it up
unni
unni #3
Jun 9, 2009 at 11:08 AM
Python looks more like C without semicolons. :)
Disc_Junkie
Jun 9, 2009 at 12:39 PM
Good Useful program...