Python program to find the electricity bill

In this python, if-else program, we will calculate the electricity bill according to the units consumed by a consumer. 

There are 4 different per unit electricity bill rate, that we have to consider to calculate the bill.

a). Up to 50 units consumption, the rate is 0.50 Rupee/per unit.
b). Up to 100 units consumption, the rate is 0.70 Rupee/per unit.
c). Up to 250 units consumption,  the rate is 1.25 Rupee/per unit.
d). Above 250 units of consumption, the rate is 1.25 Rupee/per unit.

And additional surcharge of 17% is added to the bill

Steps to solve the program
  1. Take the units consumed by a user as input through the user.
  2. Use for loop with the range function to iterate over units consumed by a user.
  3. Count the total number of units in each category (i.e 0-50,50-100,100-250,250- ) using if-else statements.
  4. Add respective units with their respective charges to bill_amount
  5. Find the sum and add an additional surcharge of 17% to the sum.
  6. Print the output.
				
					total_unit = int(input("Total units Consumed="))
bill_amount = 0

# If each unit we will add to rate amount in total bill amount
for bill_unit in range(1, total_unit+1):
    if bill_unit <= 50:
        bill_amount = bill_amount + 0.50
    elif bill_unit > 50 and bill_amount <= 100:
        bill_amount = bill_amount + 0.75
    elif bill_unit > 100 and bill_amount <= 250:
        bill_amount = bill_amount + 1.25
    elif bill_unit > 250:
        bill_amount = bill_amount + 1.5

# Addition 17% surcharge on total bill amount
bill_amount_sur = bill_amount + bill_amount * (17/100)
print("Bill amount with surcharge :", bill_amount_sur)
				
			

Output :

				
					Total units consumed : 350
Total Bill amount with 17% surcharge : 432.0225
				
			

Related Articles

print all the numbers from 10-15 except 13

check whether a given year is a leap or not.

Leave a Comment