Calculate the electricity bill by entering unit in Python

Calculate the electricity bill by entering unit Per unit calculation charges on the following condition
(1-100) Unit -Rs. 3
(101-500) Unit -Rs. 5
(501-1000) Unit -Rs. 8
(Greater than 1000) Unit -Rs. 10


Source Code

u=int(input(“Enter unit :”))

if u>=1 and u<100:

    pu=3

elif u>=100 and u<500:

    pu=5

elif u>=500 and u<1000:

    pu=8

elif u>=1000:

    pu=10

bill=u*pu

print(“Total units:”,u)

print(“Per unit rate:”,pu)

print(“Total Bill:”,bill)

Output

Enter unit :56
Total units: 56
Per unit rate: 3

Total Bill: 168

Leave a Comment

Your email address will not be published. Required fields are marked *