COMPUTER
SCIENCE
Project File
Electricity Billing System
Python MYSQL
Name : Amit Kumar
Class : XII 'A'
Roll No.:
Student ID : 20180210581
Subject teacher's name : Bajrang Yadav
School : S.B.V No.1 Palam village
CERTIFICATE
This is to certify that Amit kumar of class XII 'A' has
completed his Computer Science project titled
Electricity billing System under the guidance of
Bajrang yadav for the academic year 2024-25. The
certified student has been dedicated throughout
his research and completed his work before the
given deadline without missing any important
details from the project. It is also certified that this
project is the individual work of the student and
Teacher’s Signature Examiner:’s Signature
ACKNOWLEDGEMENT
I wish to sincerely thank my computer lab instructor, Bajrang
Yadav, for the guidance and assistance provided while I
worked on my school computer project. Their support was
invaluable in enabling me to explore this topic and expand
my abilities.
Additionally, I appreciate that my principal, KC Shrma ,
facilitated an environment at school where I could delve into
this project.
My family deserves considerable thanks as well, for
bolstering me with their unwavering encouragement during
each step of this undertaking. The vital knowledge and
talents cultivated will undoubtedly assist me in surmounting
future obstacles.
I am honored for the chance to present my efforts to my
classmates, feeling pride in contributing to the scholastic
climate. The backing received from all mentioned has been
pivotal, for which I am abundantly grateful.
CONTENTS
S.N. DESCRIPTION
01 ACKNOWLEDGEMENT
02 INTRODUCTION
03 OBJECTIVES OF THE PROJECT
04 PROPOSED SYSTEM
05 SYSTEM DEVELOPMENT LIFE CYCLE (SDLC)
06 PHASES OF SYSTEM DEVELOPMENT LIFE CYCLE
07 FLOW CHART
08 SOURCE CODE
09 OUTPUT
10 TESTING
11 HARDWARE AND SOFTWARE REQUIREMENTS
12 BIBLIOGRAPHY
ELECTRICITY BILLING SYSTEM
INTRODUCTION
The Electric Billing System is designed to automate the process of
generating electricity bills for consumers. The project simplifies
billing operations, reduces manual errors, and improves efficiency.
This system calculates electricity usage based on input parameters
like consumer ID, previous meter reading, and current meter
reading. The calculated bill can be printed or saved for future
reference
OBJECTIVES OF THE PROJECT
To automate the process of generating electricity bills.To reduce
errors associated with manual calculations.To provide an efficient
and user-friendly interface for data input and bill generation.To
ensure data storage and retrieval for consumer records.To integrate
features for bill calculation, viewing, and printing.
PROPOSED SYSTEM
The proposed Electric Billing System is designed to handle the
following functionalities:Input consumer details such as ID, name,
and meter readings.Automatically calculate electricity charges based
on the tariff.Generate detailed bills that include consumer
information, units consumed. charges.Store and manage consumer
records securely.Enable administrators to access and update tariff
details.
SYSTEM DEVELOPMENT LIFE CYCLE (SDLC)
The development of this project follows the SDLC framework to
ensure systematic and efficient execution. The primary phases are:
PHASES OF SYSTEM DEVELOPMENT LIFE CYCLE
Requirement Analysis: Identify the system requirements, including
hardware, software, and user needs.
System Design: Design the interface, database schema, and
workflows.Implementation: Develop the system using
programming languages and database tools.
Testing: Perform unit, integration, and system testing to identify
and fix issues.
Deployment: Install the system in a production environment.
Maintenance: Provide ongoing support and updates.
Flow chart
SOURCE CODE
import mysql.connector
db1 = None
def connect():
global db1
db1 = mysql.connector.connect(host="localhost",user="root",
password="root",
database = "electricity"
def showusers():
c1 = db1.cursor()
c1.execute("select * from users")
res = c1.fetchall()
#print(res)
print("List of Users ")
for val in res:
print("UserName = "+val[0] + " Password = " + val[1])
def login():
print("-" * 50)
print("\t Electricity Bill Generation System")
print("-" * 50)
print("\t LOGIN")
un = input("Enter User Name : ")
pw = input("Enter Password : ")
q = "select * from users where username = %s and passw = %s"
val = (un,pw)
c2 = db1.cursor()
c2.execute(q,val)
res = c2.fetchall()
print("-" * 50)
if len(res) == 0:
print("Invalid User Name or Password ")
print("-" * 50)
return False
else:
print("Access Granted !!!")
print("-" * 50)
return True
def delcustomer():
print("*" * 50)
print("\tDELETING A CUSTOMER")
print("*" * 50)
cid = input("Enter Customer Id : ")
cursor1 = db1.cursor()
q = "delete from customer where cid='" + cid + "'"
cursor1.execute(q)
db1.commit()
print("Customer Deleted Successfully")
def addcustomer():
print("*" * 50)
print("\tWelcome to Electricity Management")
print("*" * 50)
cid = input("Enter Customer Id : ")
cname = input("Enter Customer Name : ")
addr = input("Enter Address : ")
phone = input("Enter Phone Number : ")
email = input("Enter Email :")
mtr = input("Enter meter no : ")
cursor1 = db1.cursor()
q = "insert into customer values (%s,%s,%s,%s,%s,%s)"
val = (cid,cname,addr,phone,email,mtr)
cursor1.execute(q,val)
db1.commit()
print("Customer Added Successfully")
def showcustomers():
cursor1 = db1.cursor()
cursor1.execute("Select * from Customer")
res = cursor1.fetchall()
print("-" * 50)
print(" CUSTOMER DETAILS ")
print("-" * 50)
print("Id Name Email Phone Meter")
for k in res:
print(k[0]," ",k[1]," ",k[3]," ",k[4],"\t",k[5])
def generatebill():
mtr = input("Enter Meter No .: ")
dt = input("Enter the date of Bill Generation : ")
cunits = int(input("Enter Current Units on Meter : "))
punits = int(input("Enter Previous Units of Meter : "))
consumed = cunits - punits
if consumed < 200:
bill = 4 * consumed
elif consumed <400:
bill = 6 * consumed
else:
bill = 8 * consumed
print("Total Units Consumed ",consumed)
print("Total Amount to be paid ",bill)
duedt = input("Enter the Due Date of Payment : ")
q = "insert into bill values(%s,%s,%s,%s,%s,%s,%s,'No')"
val =(mtr,dt,cunits,punits,consumed,bill,duedt)
c2 = db1.cursor()
c2.execute(q,val)
print("Bill Generated Successfully !!!")
db1.commit()
def showunpaid():
cursor1 = db1.cursor()
cursor1.execute("Select * from bill where paid='No'")
res = cursor1.fetchall()
print(" LIST OF UNPAID BILLS ")
print("-" * 40)
print("MeterNo. BillDate Amount")
for k in res:
print(k[0],"\t",k[1],"\t",k[5])
def paybill():
mtr = input("Enter Meter No .: ")
cursor1 = db1.cursor()
cursor1.execute("Select * from bill where paid='No' and
meterno='"+mtr+"'")
res = cursor1.fetchall()
print("Following Bills are unpaid for the given meter no ")
print("-" * 40)
print("MeterNo. BillDate Amount DueDate")
for k in res:
print(k[0],"\t",k[1],"\t",k[5],"\t",k[6])
bdate = input("Enter the bill date for the bill to be paid : ")
q = "update bill set paid='Yes' where billdate='" + bdate + "' and
meterno='" + mtr + "'"
cursor1.execute(q)
db1.commit()
mp=input("Please Select the mode of
Payment(Cash/Cheque/Card):")
print("Transaction Complete !!!")
connect()
print("Connected")
if login():
while True:
print("-" * 50)
print("\t CHOOSE AN OPERATION ")
print("-" * 50)
print("Press 1 - Add a New Customer")
print("Press 2 - Delete an Existing Customer")
print("Press 3 - Show all Customers")
print("Press 4 - Generate the Bill")
print("Press 5 - Mark the Bill as Paid")
print("Press 6 - Show All Unpaid Bills")
print("Press 7 - Quit")
ch = int(input("Enter Your Choice : "))
if ch == 1:
addcustomer()
elif ch == 2:
delcustomer()
elif ch == 3:
showcustomers()
elif ch == 4:
generatebill()
elif ch == 5:
paybill()
elif ch == 6:
showunpaid()
elif ch == 7:
break
OUTPUT
Sample Input:
Enter Consumer ID: C123
Enter Consumer Name: Amit
Enter Previous Meter Reading: 1200
Enter Current Meter Reading: 1350
Enter Rate per Unit: 5.5
Sample Output:
Consumer ID: C123
Name: Amit
Units Consumed: 150
Total Bill Amount: INR 825.0
TESTING
Unit Testing: Verify individual functions like unit calculation and bill
generation.Integration Testing: Ensure seamless interaction between
modules like data input, calculation, and display.System Testing: Test
the complete system for accuracy and reliability.
HARDWARE AND SOFTWARE REQUIREMENTS
Hardware:Processor: Intel Core i3 or above
RAM: 4 GB or more
Hard Disk: 500 GB or more
Monitor: Any standard display
SOFTWARE:
Operating System: Windows
Language: Python 3.8 or above
Editor/IDE: Visual Studio Code, PyCharm, or any text
editorDatabase: MySQL
BIBLIOGRAPHY
Computer science With Python - Class XII By : SumitaArora
A Project Report On Blood Bank Management System (BBMS)
Website: https://www.w3resource.com
4. https://github.com
5. https://chatgpt.com/