15,901,205 members
See more:
You are given the number of units of electricity consumed, you have to write a program to calculate the final electricity bill (in Rs) as per the following slabs.

1 - 65 units: 50 paise per unit
66 - 200 units: 65 paise per unit
201 - 475 units: Rs. 1.2 per unit
Above 475 units: Rs. 2 per unit
Additionally a surcharge of 25% is levied on the total bill. Take the number of units consumed as input from the user.

Example: U=225 units

Total bill= 65*0.5+135*0.65+25*1.2= 150.25 Rs

Final bill = 150.25 + 25% of 150.25

= 150.25 + 37.5625

= 187.8125 Rs

What I have tried:

I don't know to write finalbill as summation of total bill can anyone help me with this?

Python
```U=int(input())
def TotalBill(U) :
if (U <= 65):
return U * 0.5
elif (U <= 200):
return ((65 * 0,5) + (U - 65) * 0.65)
elif (U <= 475):
return ((65 * 0.5) +(135 * 0.65) + (U - 200) * 1.2)
elif (U > 475):
return ((65 * 0.5) +(135 * 0.65) +(275 * 1.2) +(U - 475) * 2)
else :
return 0

print(TotalBill)
FinalBill = "TotalBill" + 0.25 * TotalBill```
Posted
Updated 19-Apr-22 6:47am
v2
Richard Deeming 19-Apr-22 12:35pm
Is your username supposed to be ironic? You clearly DON'T love studying, since you've posted at least five demands for other people to do your homework for you in the last eight hours. đź¤¦â€Ťâ™‚ď¸Ź

## Solution 1

Well, you are almost there...
Python
```def TotalBill(U) :
if (U<=0):
return 0
elif(U <= 65):
return U * 0.5
elif (U <= 200):
return ((65 * 0,5) + (U - 65) * 0.65)
elif (U <= 475):
return ((65 * 0.5) +(135 * 0.65) + (U - 200) * 1.2)
else:
return ((65 * 0.5) +(135 * 0.65) +(275 * 1.2) +(U - 475) * 2)

U=int(input())
totalBill = TotalBill(U)
print("total bill", totalBill)
finalBill = (1.25) * totalBill
print("final bill", finalBill)```