In this program, we will calculate the electricity bill of a consumer.
Steps to solve the program
- Take the units consumed by a user as input.
- Calculate the number of units consumed in each category (i.e. given in the question) using for loop.
- Calculate the amount for each category according to the units consumed.
- Calculate the total of all categories and add an additional surcharge of 17%.
- 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