In This Tutorials how to calculate to Calculate Electricity Bill with an example.
Python Program to find Electricity Bill with source code
In this example how to find Electricity Bill in python with usage to meter reading.
Python Program to Calculate Electricity Bill
units = int(input(" Please enter Number of Units you Consumed : "))
if(units < 50):
amount = units * 2.60
surcharge = 25
elif(units <= 100):
amount = 130 + ((units - 50) * 3.25)
surcharge = 35
elif(units <= 200):
amount = 130 + 162.50 + ((units - 100) * 5.26)
surcharge = 45
else:
amount = 130 + 162.50 + 526 + ((units - 200) * 8.45)
surcharge = 75
total = amount + surcharge
print("\nElectricity Bill = %.2f" %total)
Here the Python electricity program output
PS F:\Python\python program> python -u "f:\Python\python program\tempCodeRunnerFile.python"
Please enter Number of Units you Consumed : 100
Electricity Bill = 411.00
PS F:\Python\python program> python -u "f:\Python\python program\tempCodeRunnerFile.python"
Please enter Number of Units you Consumed : 500
Electricity Bill = 3950.00
PS F:\Python\python program> python -u "f:\Python\python program\tempCodeRunnerFile.python"
Please enter Number of Units you Consumed : 300
Electricity Bill = 2400.00
PS F:\Python\python program> python -u "f:\Python\python program\tempCodeRunnerFile.python"
Please enter Number of Units you Consumed : 1000
Electricity Bill = 9735.00