Computer Project
Computer Project
SUPERMARKET
MANAGEMENT SYSTEM
1|Page
ACKNOWLEDGEMENT
2|Page
I would like to thank God Almighty for giving me the
strength and perseverance to complete this project.
3|Page
CONTENTS
4|Page
SL. NO. TITLE PAGE NO.
1 OBJECTIVE AND SCOPE 6
2 SYSTEM REQUIREMENTS 8
HARDWARE
SOFTWARE
3 INTRODUCTION TO PYTHON 10
4 DESIGN OF THE PROGRAM 12
VARIABLES USED
MODULES USED
FUNCTION USED
FILES USED
5 PROGRAM CODE 18
6 SAMPLE OUTPUTS 28
7 CONCLUSION 33
8 BIBLIOGRAPHY 35
5|Page
OBJECTIVE AND
SCOPE
6|Page
The objective of a computer science project
focused on a supermarket purchase, stock
management, and billing system is to design and
develop a comprehensive software application
that streamlines and automates various aspects of
supermarket operations. This project aims to
provide efficient management of inventory,
simplify the billing process. The scope of the
project encompasses the development of a robust
software application tailored to the needs of a
supermarket. The project creates a
comprehensive computer application that
enhances the efficiency and effectiveness of
supermarket.
7|Page
SYSTEM
REQUIREMENTS
8|Page
HARDWARE
Processor : Intel(R) Core(TM) i5-1035G1
CPU @ 1.00GHz 1.19 GHz
SOFTWARE
Operating System : Windows 11
9|Page
INTRODUCTION TO
PYTHON
10 | P a g e
Python is a high-level, interpreted, general purpose
programming language. Python is dynamically typed
and an Object-Oriented Programming language. It
was developed by Dutch Programmer, Guido Von
Rossum in 1991. Now, it is currently being
maintained and developed by the Python Foundation.
Python is a human-readable programming language
with a clearly defined syntax a simple structure. It is
portable and platform independent, which allows it to
be run on different operating systems and hardware.
Python is always growing with a large number of
available libraries and an active community of
programming enthusiasts.
11 | P a g e
DESIGN OF THE
PROGRAM
12 | P a g e
The code is designed as a menu – driven program
which executes a set of pre – defined functions
according to user’s choice. It displays a set of
functions and the corresponding choice to be entered.
13 | P a g e
VARIABLES USED
•f
• i
• item_name
• item_price
• qty
• net_price
• doc
• total_payable
• ch
• k
• z
•m
• Iname
• c
• p
14 | P a g e
• Q
• rec
• Found
• supplier
• Item
• d
• a
• x
MODULES USED
➢ sys
➢ os
➢ pickle
15 | P a g e
FUNCTION USED
▪ billing()
▪ view()
▪ add_record()
▪ search()
▪ show()
▪ stocks()
▪ purchase()
▪ show_purchase()
▪ delete()
▪ modify()
16 | P a g e
FILES USED
❖ bill.dat
❖ supermarket.dat
❖ spmcopy.dat
17 | P a g e
PROGRAM CODE
18 | P a g e
import os
import pickle
import sys
def billing():
f = open('bill.dat', 'wb+')
i = 1
total_payable = 0
while True:
item_name = input('item name : ')
item_price = float(input('enter price : '))
qty = int(input('enter quantity : '))
net_price = item_price * qty
doc = [i, item_name, item_price, qty, net_price]
pickle.dump(doc, f)
total_payable += net_price
ch = input('over ? (y/n) : ')
i += 1
if ch.lower() in ['Y', 'y', 'yes']:
break
f.close()
#billing-view function
def view():
f = open('bill.dat', 'rb+')
k, z = 0, 0
total_payable = 0
try:
print('-' * 10, 'PRIME-CHOICE MART', '-' * 10)
print('SI.no', '\titem', '\tprice', '\tqty',
'\tnet')
while True:
m = pickle.load(f)
print(m[0], '\t', m[1], '\t', m[2], '\t', m[3],
'\t', m[4])
19 | P a g e
total_payable += m[4]
k = total_payable
if k >= 1500:
z = (total_payable) * 0.03
except EOFError:
f.close()
print('=' * 39)
print('net payable = ', k)
print('discount = ', -z)
print('net sum : ', k - z)
print("")
#stocks-add function
def add_record():
f = open("supermarket.dat", "ab")
iname = input("enter item name:")
c = input("enter company:")
p = int(input("enter price:"))
q = int(input("enter quantity:"))
rec = [iname, c, p, q]
print("record added successfully")
pickle.dump(rec, f)
f.close()
#stocks-search function
def search():
f = open('supermarket.dat', 'rb+')
k = input('item to be searched : ')
found = False
try:
while True:
m = pickle.load(f)
20 | P a g e
if str(m[0]) == k:
print(m[0], m[1], m[2], m[3],
sep='\t\t')
found = True
break
except EOFError:
f.close()
if found == False:
print('Record not found!')
#stocks-view function
def show():
f = open("supermarket.dat", "rb")
try:
print('itemname', 'company', 'price', 'qty',
sep='\t\t')
while True:
m = pickle.load(f)
print(m[0], m[1], m[2], m[3], sep='\t\t')
except EOFError:
f.close()
#stocks function
def stocks():
print('enter choice : ')
while True:
ch = int(
input(
'1 : add record, 2 : search, 3 : delete,
4 : show, 5 : modify , 6 : exit '
))
if ch == 1:
21 | P a g e
add_record()
k = input('do you want to continue ? (y/n) :
')
if k.lower() == 'n':
print('exiting the program', '\n', 'THANK
YOU')
break
elif ch == 2:
search()
k = input('do you want to continue ? (y/n) :
')
if k.lower() == 'n':
print('exiting the program', '\n', 'THANK
YOU')
break
elif ch == 3:
delete()
k = input('do you want to continue ? (y/n) :
')
if k.lower() == 'n':
print('exiting the program', '\n', 'THANK
YOU')
break
elif ch == 4:
show()
k = input('do you want to continue ? (y/n) : ')
if k.lower() == 'n':
print('exiting the program', '\n', 'THANK
YOU')
break
elif ch == 5:
modify()
k = input('do you want to continue ? (y/n) :
')
if k.lower() == 'n':
print('exiting the program', '\n', 'THANK
YOU')
break
22 | P a g e
elif ch == 6:
print()
print('exiting the screen')
print()
print('THANK YOU')
break
else:
print('Invalid choice!')
return
#purchase function
def purchase():
f = open('bill.dat', 'wb+')
i = 1
total_payable = 0
while True:
supplier = input('enter supplier name : ')
item = input('item name : ')
price = float(input('enter price : '))
qty = int(input('enter quantity : '))
net_price = price * qty
doc = [i, item, supplier, qty, net_price]
pickle.dump(doc, f)
total_payable += net_price
ch = input('over ? (y/n) : ')
i += 1
if ch.lower() == 'y':
break
f.close()
#purchase-view function
def show_purchase():
23 | P a g e
f = open('bill.dat', 'rb+')
total_payable = 0
try:
print('-' * 10, 'PRIME CHOICE MART', '-' * 10)
print('SI.no', 'item', 'supplier ', 'qty'
'net',sep='\t')
while True:
m = pickle.load(f)
print(m[0], m[1], m[2], m[3],sep='\t')
total_payable += m[4]
except EOFError:
f.close()
print('=' * 31)
print('Total payable = ', total_payable)
#stocks-delete
def delete():
iname = input("Enter item name to be deleted: ")
found = 0
try:
with open("supermarket.dat", "rb") as f,
open("spmcopy.dat", "wb") as f1:
while True:
try:
d = pickle.load(f)
if d[0] != iname:
pickle.dump(d, f1)
else:
found = 1
except EOFError:
break
os.remove("supermarket.dat")
os.rename("spmcopy.dat", "supermarket.dat")
if found == 0:
print("Item not found.")
24 | P a g e
else:
print("Item deleted successfully.")
except FileNotFoundError:
print("File 'supermarket.dat' not found.")
return
# modify
def modify():
iname = input("Enter item name to modify: ")
found = 0
try:
with open("supermarket.dat", "rb") as f,
open("spmcopy.dat", "wb") as f1:
while True:
try:
d = pickle.load(f)
if d[0] != iname:
pickle.dump(d, f1)
else:
found = 1
a = d
a[0] = input("Enter new name: ")
a[1] = input("Enter new company name: ")
a[2] = int(input("Enter new price: "))
a[3] = int(input("Enter new quantity
number: "))
pickle.dump(a, f1)
except EOFError:
break
os.remove("supermarket.dat")
os.rename("spmcopy.dat", "supermarket.dat")
if found == 0:
print("Item not found.")
else:
print("Item modified successfully.")
25 | P a g e
except FileNotFoundError:
print("File 'supermarket.dat' not found.")
return
#supermarket UI
27 | P a g e
SAMPLE OUTPUTS
28 | P a g e
29 | P a g e
30 | P a g e
31 | P a g e
32 | P a g e
CONCLUSION
33 | P a g e
In conclusion of this project, I gained valuable
knowledge and skills in software development,
database management, user interface design, and
system integration. We deepened our understanding
of Python programming and leveraged various
libraries and frameworks to build a robust and user-
friendly solution.
34 | P a g e
BIBLIOGRAPHY
35 | P a g e
• Computer Science with Python – Textbook for
CBSE Class XII, 2023 Edition, Sultan Chand &
Sons (P) Ltd.
• https://replit.com/~
• www.wikipedia.org
• www.w3resource.com
36 | P a g e