Skip to content

Instantly share code, notes, and snippets.

@jerinisready
Last active September 22, 2021 08:19
Show Gist options
  • Save jerinisready/d17f63032a74d72af8ca921ae44e3cfc to your computer and use it in GitHub Desktop.
Save jerinisready/d17f63032a74d72af8ca921ae44e3cfc to your computer and use it in GitHub Desktop.
CALCULATE The Electricity Power Consumption Rate you your personal electricity board, from the number of units consumed this month.

ELECTRICTY BILL

CALCULATE The Electricity Power Consumption Rate you your personal electricity board, from the number of units consumed this month.

Charges are as follows:

Units of Consumption Charges / UNIT
1-100 Rs 0.20 / unit in this slot
101-200 Rs. 0.35 / unit in this slot
201-350 Rs 0.50 / unit in this slot
351-400 Rs 0.75 / unit in this slot
401-500 Rs 1.0 /unit in this slot
501 AND ABOVE Rs 1.25 /unit in this slot

Additionally, you have to calculate Rs. 100 as meter charge and
an 18% GST on total amount.


Input Output calculation
50 units Rs. 10.0 (50 * 0.20)
120 units Rs. 27.0 (100 * 0.20) + (20 * 0.35)
480 units Rs. 247.50 (100 * 0.20) + (100 * 0.35) + (150 * 0.50) + (50 * 0.75) + (80 * 1.0)
__author__ = "@jerinisready"
__doc__ = """Calculate the electricity bill."""
METER_CHARGE = 100.00
def main():
no_of_unit_as_input = input("Enter number of units consumed : ")
no_of_unit = int(no_of_unit_as_input)
amount = 0.0
if 0 < no_of_unit <= 100:
amount = no_of_unit * 0.20
elif 101 <= no_of_unit <= 200:
amount = (100 * 0.20) + ((no_of_unit-100) * 0.35)
elif 201 <= no_of_unit <= 350:
amount = (100 * 0.20) + (100 * 0.35) + ((no_of_unit - 200) * 0.50)
elif 351 <= no_of_unit <= 400:
amount = (100 * 0.20) + (100 * 0.35) + (150 * 0.50) + ((no_of_unit - 350) * 0.75)
elif 401 <= no_of_unit <= 500:
amount = (100 * 0.20) + (100 * 0.35) + (150 * 0.50) + (50 * 0.75) + ((no_of_unit - 400) * 1.0)
else:
amount = (100 * 0.20) + (100 * 0.35) + (150 * 0.50) + (50 * 0.75) + (100 * 1.0) + ((no_of_unit - 500) * 1.25)
print('=' * 60)
print("Unit Consumption Charge \t: \tRs.", amount, "/-")
print("Meter Charge \t\t\t: \tRs. 100.00/- ")
print('-' * 60)
amount = amount + METER_CHARGE # adding meter charge.
print("Total \t\t\t\t: \tRs.", amount, "/- ")
tax_amount = (amount * 18) / 100
print("TAX \t\t\t\t: \tRs.", tax_amount, "/- ")
print('=' * 60)
net_amount = amount + tax_amount
print("Amount to be paid \t\t: \tRs.", net_amount, "/- ")
if __name__ == "__main__":
"Run Main Program"
main()
@jerinisready
Copy link
Author

Screenshot from 2021-09-22 13-48-50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment