Python Program To Calculate Electricity Bill – Programming Code Examples
Python

Python Program To Calculate Electricity Bill2 min read

Python Program To Calculate Electricity Bill

In this tutorial, we will discuss the Python program to calculate electricity bill

In this post, we will learn how to calculate electricity bill using if condition in the Python programming language




We can calculate monthly consumed electric power usage in many ways.

In this tutorial, we will explain two programs calculating electricity bill in the Python language.

Before we discuss a program to calculate the electricity bill, we must understand electricity charges and rates.

This program can explain as follows

  • Declare total unit consumed by the customer using the variable unit.
  • If the unit consumed less or equal to 100 units, calculates the total amount of consumed =units*1.5
  • If the unit consumed between 100 to 200 units, calculates the total amount of consumed=(100*1.5)+(unit-100)*2.5)
  • If  unit consumed between 200 to 300 units ,calculates total amount ofconsumed=(100*1.5)+(200-100)*2.5+(units-200)*4
  • If unit consumed between 300-350 units ,calculates total amount of consumed=(100*1.5)+(200-100)*2.5+(300-200)*4+(units-350)*5
  • If the unit consumed above 350 units, fixed charge – 1500/=
  • additional charges
  1. if units<=100 – 25.00
  2. if 100< units and units<=200 – 50.00
  3. if 200 < units and units<=300 – 75.00
  4. if 300<units and units<=350 – 100.00
  5. if units above 350 – No additional charges

Electricity bill calculation – with out and operator

program 1

When the above code is  executed, it produces the following results

Case 1

Case 2

Case 3

Case 4

Electricity bill calculation – with  and operator

Program 2

When the above code is  executed, it produces the following results

Leave a Comment