Calculate the electricity bill of a consumer.

In this program, we will calculate the electricity bill of a consumer.

Steps to solve the program
  1. Take the units consumed by a user as input.
  2. Calculate the number of units consumed in each category (i.e. given in the question) using for loop.
  3. Calculate the amount for each category according to the units consumed.
  4. Calculate the total of all categories and add an additional surcharge of 17%.
  5. Print the output.
				
					x=int(input("Total units consumed= "))
b=c=d=e=0
p=q=r=s=0

for i in range(1,x+1):
    if i<51:
        p += 1        
    b = p*0.5
    if i>50 and i<151:
        q += 1        
    c = q*0.75
    if i>150 and i<251:
        r += 1        
    d = r*1.25
    if i>250:
        s += 1
    e = s*1.50
y = b+c+d+e
z = y+y*0.17
print("Total Bill: ",z)
				
			

Output :

				
					Total units consumed= 350
Total Bill:  438.75
				
			

Calculate the bill according to the distance covered

calculate the sum of all odd numbers between 1-100

Leave a Comment