An electric power distribution company charges its domestic consumers as follows:

Consumption UnitsRate of Charges
0-100Rs. 1 per unit
101-300Rs. 100 plus Rs. 1.25 per unit in excess of 100
301-500Rs. 350 plus Rs. 1.50 per unit in excess of 300
500 and aboveRs. 650 plus Rs. 1.75 per unit in excess of 500

Below is a program that read the customer number & power consumed and prints the amount to be paid by the customer. You will note that output is also well formatted. Let’s start below


customerNo=int(input("Enter customer number : "))
units=int(input("Enter the power consumed :"))

if units>0 and units<=100 :
 billAmt=units*1
elif units>100 and units<=300 :
 billAmt=100+(units-100)*1.25
elif units>300 and units<=500 :
 billAmt=350+(units-300)*1.50
elif units>500: 
 billAmt=650+(units-500)*1.75
else:
    print("Invalid Input, please try again. ")

print("~"*60)
print("\t\t\t PSPCL BILL ")
print("~"*60)
print("\t\tPayable Bill Amount :INR " +str(billAmt))
print("-"*60)

Python program for domestic electricity bill

Output:

Python program for domestic electricity bill

Explore More

f-strings in Python

Python offers a powerful feature called f-strings (formatted string literals) to simplify string formatting and interpolation. f-strings is introduced in Python 3.6 it provides a concise and intuitive way to embed expressions and variables

end and sep in Python

end in Python The end is a parameter in Python’s built-in print() function/method that controls what character(s) are printed at the end of the printed text.  Syntax : Output :

Python tutorials

We are starting a Python Tutorials Series for Beginners and Professionals. In these Python Tutorials, we will cover all the features of Python. You will learn from basic to advanced-level features