0% found this document useful (0 votes)
19 views20 pages

Car Showroom Management Project in Python

Uploaded by

Shreyansh Singh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views20 pages

Car Showroom Management Project in Python

Uploaded by

Shreyansh Singh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

SECTOR-9 VRINDAVAN YOJNA

(Affiliated to C.B.S.E.)
SESSION: 2025-26

COMPUTER SCIENCE

Prepared By: Submitted to:


Gaurav Singh Verma Mr. Ravi Ojha
CLASS: XII
AISSCE Roll No:
CERTIFICATE

THIS IS TO CERTIFY THAT Gaurav Singh


Verma OF CLASS XII HAS COMPLETED computer
science PROJECT file AS PER CBSE GUIDELINES.

INTERNAL EXAMINER EXTERNAL


EXAMINAR
SIGNATURE_________
SIGNATURE__________

PRINCIPAL SIGNATURE
_______________
Acknowledgment
It is my great pleasure that I find myself penning
down the lines to express my sincere thanks to all those
people who helped me a long way in completing this
project.
The harmonious climate in our school provided proper
atmosphere for preparing the project. It was a privilege
to have been guided by Mr. Ravi Ojha.
I am also grateful to my classmates who helped me
doing the finalization.

Gaurav Singh Verma


CONTENTS
___________________________

1. SYSTEM REQUIREMENT
2. ABOUT THE PROJECT
3. SOURCE CODE
4. OUTPUT
5. BIBLIOGRAPHY

SYSTEM REQUIREMENT
 Hardware Required

 Processor: Dual Core 2.0 GHz or advanced


 Ram: 2 GB or more

 software Required

 Operating system: Windows 8/10/11 or Linux


 IDE: Python 3.6/3.7/3.9/3.10/3.11
 DBMS: MySQL
 Other Software: MS Word, notepad, Web
Browser
 Code Editor: Visual Studio Code

ABOUT THE PROJECT


This project is about a car showroom
management program, it is a Python-based
program designed to efficiently maintain and
organize the essential details of vehicles
available in a showroom. Built with a MySQL
database interface, this program allows users
to perform a variety of tasks such as adding
new car entries, updating stock levels,
recording sales, and deleting outdated or sold-
out records. With an intuitive menu-driven
interface, it enables showroom administrators
to seamlessly manage key aspects like vehicle
names, prices, stock availability, and sales
data.

Code
import [Link]

def connect_to_database():
"""Establishes connection with the MySQL database."""
return [Link](
host="localhost", # Replace with your MySQL server host
user="root", # Replace with your MySQL username
password="1234", # Replace with your MySQL password
database="car_showroom" # Ensure this database exists
)

def create_table():
"""Creates the cars table if it does not already exist."""
conn = connect_to_database()
cursor = [Link]()
[Link]("""
CREATE TABLE IF NOT EXISTS cars (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50),
price FLOAT,
stock INT,
sales INT DEFAULT 0
)
""")
[Link]()
print("Table created successfully.")

def add_car(name, price, stock):


"""Adds a new car to the database."""
conn = connect_to_database()
cursor = [Link]()
[Link]("INSERT INTO cars (name, price, stock) VALUES
(%s, %s, %s)", (name, price, stock))
[Link]()
[Link]()
print("Car added successfully.")

def view_cars():
"""Displays all cars in the database."""
conn = connect_to_database()
cursor = [Link]()
[Link]("SELECT * FROM cars")
records = [Link]()
[Link]()
print("\nCurrent Cars in Showroom:")
for row in records:
print(f"ID: {row[0]}, Name: {row[1]}, Price: {row[2]}, Stock:
{row[3]}, Sales: {row[4]}")

def update_stock(car_id, new_stock):


"""Updates the stock of a specific car."""
conn = connect_to_database()
cursor = [Link]()
[Link]("UPDATE cars SET stock = %s WHERE id = %s",
(new_stock, car_id))
[Link]()
[Link]()
print("Stock updated successfully.")

def delete_car(car_id):
"""Deletes a car from the database."""
conn = connect_to_database()
cursor = [Link]()
[Link]("DELETE FROM cars WHERE id = %s", (car_id,))
[Link]()
[Link]()
print("Car deleted successfully.")

def record_sale(car_id, quantity):


"""Records a sale and updates stock and sales count."""
conn = connect_to_database()
cursor = [Link]()
[Link]("SELECT stock, sales FROM cars WHERE id = %s",
(car_id,))
result = [Link]()
if result:
stock, sales = result
if stock >= quantity:
new_stock = stock - quantity
new_sales = sales + quantity
[Link]("UPDATE cars SET stock = %s, sales = %s
WHERE id = %s", (new_stock, new_sales, car_id))
[Link]()
print("Sale recorded successfully.")
else:
print("Insufficient stock to complete the sale.")
else:
print("Car ID not found.")
[Link]()

def main():
"""Main function to interact with the car showroom
database."""
create_table()
while True:
print("\nCar Showroom Management")
print("1. Add Car")
print("2. View Cars")
print("3. Update Stock")
print("4. Delete Car")
print("5. Record Sale")
print("6. Exit")
choice = int(input("Enter your choice: "))

if choice == 1:
name = input("Enter car name: ")
price = float(input("Enter car price: "))
stock = int(input("Enter car stock: "))
add_car(name, price, stock)
elif choice == 2:
view_cars()
elif choice == 3:
car_id = int(input("Enter car ID to update stock: "))
new_stock = int(input("Enter new stock value: "))
update_stock(car_id, new_stock)
elif choice == 4:
car_id = int(input("Enter car ID to delete: "))
delete_car(car_id)
elif choice == 5:
car_id = int(input("Enter car ID for sale: "))
quantity = int(input("Enter quantity sold: "))
record_sale(car_id, quantity)
elif choice == 6:
print("Exiting program. Goodbye!")
break
else:
print("Invalid choice. Please try again.")
if __name__ == "__main__":
main()

Output of Different Functions


1. Adding a Car:

2. Viewing all Cars:

3. Updating Stock:
4. Delete Car:

[Link] Sale:
[Link]:
DBMS
Tables:

All Records:
``

BIBLIOGRAPHY

1. Sumita Arora (Computer Science with Python)


2. Preeti Arora (Computer Science with Python)

You might also like