Vehicle Inventory System in Python with Source Code

Vehicle Inventory System in Python with Source Code

The Vehicle Inventory System in Python is developed in python programming language and it is a console based system.

This system is created using tkinter. The Vehicle Inventory System is free to download the open source code.

Vehicle Inventory System is a basic framework that can include, eliminate, and alter vehicle things.

Likewise, the framework is helpful as a model of how to build a basic stock framework inside Python. This basic task has a book document to store the current stock information.

The task record contains a python content (vehicle.py). Discussing the framework of Vehicle Inventory System, it permits the client to include and erase vehicles from stock, see the stock, update a vehicle in stock, and fare the current stock to a book document.

While adding vehicles to stock things, the client needs to enter the vehicle name, its model, year, shading, and mileage.

The framework shows the stock record in a rundown see. Additionally, the client effectively erase any stock things.

The client can look for a thing as it contains a hunt work as well.

So, this activities essentially center around CRUD with an inquiry work.

Anyway if you want level up your knowledge in programming especially games in python, try this new article I’ve made for you Code For Game in Python: Python Game Projects With Source Code

Before you start creating this  Vehicle Inventory System in Python, make sure that you have PyCharm IDE installed in your computer.

Steps on how to create Vehicle Inventory System in Python

Vehicle Inventory System in Python with Source Code

  1. Step 1: Create a project name.

    First when you finished installed the Pycharm IDE in your computer, open it and then create a “project name” after creating a project name click the “create” button.Creating project Name in Vehicle Inventory System in python with Source Code

  2. Step 2: Create a python file.

    Second after creating a project name, “right click” your project name and then click “new” after that click the “python file“.Creating Python File Name in Vehicle Inventory System in python with Source Code

  3. Step 3: Name your python file.

    Third after creating a python file, Name your python file after that click “enter“.Naming Python File Name in Vehicle Inventory System in python with Source Code

  4. Step 4: The actual code.

    This is the actual coding on how to create Vehicle Inventory System in Python, and you are free to copy this code and download the full source code given below.

This module is for the class inventory

In the code given below. which is for the function for inventory of a car.((Vehicle Inventory System in Python))

class Car_Inventory:
def __init__(self):
self.cars = []
def add_car(self):
vehicle = car()
if vehicle.add_car() == True:
self.cars.append(vehicle)
print ()
print('This vehicle has been added, Thank you')
def Display_Car_Inventory(self):
print('\t'.join(['', 'Make', 'Model', 'Year', 'Color', 'Mileage']))
for idx, vehicle in enumerate(self.cars):
print(idx + 1, end='\t')
print(vehicle)

inventory = Car_Inventory()

This module is for the vehicle class

In the code the given below, which is for the function for class use in the system and also you can add new vehicle. (Vehicle Inventory System in Python)

class Vehicle_Screen:
def __init__(self):
self._make = ''
self._model = ''
self._year = 0
self._color = ''
self._mileage = 0
def add_car(self):
try:
self._make = input('Enter vehicle make: ')
self._model = input('Enter vehicle model: ')
self._year = int(input('Enter vehicle year: '))
self._color = input('Enter vehicle color: ')
self._mileage = int(input('Enter vehicle mileage: '))
return True
except ValueError:
print('Please try entering vehicle information again using only whole numbers for mileage and year')
return False
def __str__(self):
return '\t'.join(str(a) for a in [self._make, self._model, self._year, self._color, self._mileage])

This module is for the user choice

In the code given below, which is for the function of user to choose the options. Like the user can add, delete, view, update, export and can quit to the system.(Vehicle Inventory System in Python)

print('Choice 1: Add Vehicle to Inventory')
print('Choice 2: Delete Vehicle from Inventory')
print('Choice 3: View Current Inventory')
print('Choice 4: Update Vehicle in Inventory')
print('Choice 5: Export Current Inventory')
print('Choice 6: Quit')
User_Choice=input('Please Enter your Choice from one of the above options: ')
if User_Choice== "1":
#add a vehicle
inventory.add_car()
elif User_Choice== '2':
#delete a vehicle
if len(inventory.cars) < 1:
print('Sorry there are no vehicles currently in inventory')
continue
inventory.Display_Car_Inventory()
Products = int(input('Please enter the number associated with the vehicle to be removed: '))
if Products - 1 > len(inventory.cars):
print('This is an invalid number')
else:
inventory.cars.remove(inventory.cars[Products - 1])
print ()
print('This vehicle has been removed')
elif User_Choice == '3':
#list all the vehicles
if len(inventory.cars) < 1:
print('Sorry there are no vehicles currently in inventory')
continue
inventory.Display_Car_Inventory()
elif User_Choice == '4':
#edit vehicle
if len(inventory.cars) < 1:
print('Sorry there are no vehicles currently in inventory')
continue
inventory.Display_Car_Inventory()
Products = int(input('Please enter the number associated with the vehicle to be updated: '))
if Products - 1 > len(inventory.cars):
print('This is an invalid number')
else:
auto_vehicle = Vehicle_Screen()
if auto_vehicle.add_car() == True :
inventory.cars.remove(inventory.cars[Products - 1])
inventory.cars.insert(Products - 1, auto_vehicle)
print ()
print('This vehicle has been updated')
elif User_Choice == '5':
#export inventory to file
if len(inventory.cars) < 1:
print('Sorry there are no vehicles currently in inventory')
continue
file = open('vehicle_inventory.txt', 'w')
file.write('\t'.join(['Make', 'Model', 'Year', 'Color', 'Mileage']))
file.write('\n')
for car_v in inventory.cars:
file.write('%s\n' % car_v)
file.close()
print('The vehicle inventory has been exported to a file')
elif User_Choice == '6':
#exit the loop
print('Goodbye')
break
else:
#invalid user input
print('This is an invalid input. Please try again.')

Complete Source Code for Vehicle Inventory System in Python

#This is a simple inventory program for a small car dealership.
print('Vehicle Inventory')
class Vehicle_Screen:
def __init__(self):
self._make = ''
self._model = ''
self._year = 0
self._color = ''
self._mileage = 0
def add_car(self):
try:
self._make = input('Enter vehicle make: ')
self._model = input('Enter vehicle model: ')
self._year = int(input('Enter vehicle year: '))
self._color = input('Enter vehicle color: ')
self._mileage = int(input('Enter vehicle mileage: '))
return True
except ValueError:
print('Please try entering vehicle information again using only whole numbers for mileage and year')
return False
def __str__(self):
return '\t'.join(str(a) for a in [self._make, self._model, self._year, self._color, self._mileage])

class Car_Inventory:
def __init__(self):
self.cars = []
def add_car(self):
vehicle = Vehicle_Screen()
if vehicle.add_car() == True:
self.cars.append(vehicle)
print ()
print('This vehicle has been added, Thank you')
def Display_Car_Inventory(self):
print('\t'.join(['', 'Make', 'Model', 'Year', 'Color', 'Mileage']))
for idx, vehicle in enumerate(self.cars):
print(idx + 1, end='\t')
print(vehicle)

inventory = Car_Inventory()
while True:

print('Choice 1: Add Vehicle to Inventory')
print('Choice 2: Delete Vehicle from Inventory')
print('Choice 3: View Current Inventory')
print('Choice 4: Update Vehicle in Inventory')
print('Choice 5: Export Current Inventory')
print('Choice 6: Quit')
User_Choice=input('Please Enter your Choice from one of the above options: ')
if User_Choice== "1":
#add a vehicle
inventory.add_car()
elif User_Choice== '2':
#delete a vehicle
if len(inventory.cars) < 1:
print('Sorry there are no vehicles currently in inventory')
continue
inventory.Display_Car_Inventory()
Products = int(input('Please enter the number associated with the vehicle to be removed: '))
if Products - 1 > len(inventory.cars):
print('This is an invalid number')
else:
inventory.cars.remove(inventory.cars[Products - 1])
print ()
print('This vehicle has been removed')
elif User_Choice == '3':
#list all the vehicles
if len(inventory.cars) < 1:
print('Sorry there are no vehicles currently in inventory')
continue
inventory.Display_Car_Inventory()
elif User_Choice == '4':
#edit vehicle
if len(inventory.cars) < 1:
print('Sorry there are no vehicles currently in inventory')
continue
inventory.Display_Car_Inventory()
Products = int(input('Please enter the number associated with the vehicle to be updated: '))
if Products - 1 > len(inventory.cars):
print('This is an invalid number')
else:
auto_vehicle = Vehicle_Screen()
if auto_vehicle.add_car() == True :
inventory.cars.remove(inventory.cars[Products - 1])
inventory.cars.insert(Products - 1, auto_vehicle)
print ()
print('This vehicle has been updated')
elif User_Choice == '5':
#export inventory to file
if len(inventory.cars) < 1:
print('Sorry there are no vehicles currently in inventory')
continue
file = open('vehicle_inventory.txt', 'w')
file.write('\t'.join(['Make', 'Model', 'Year', 'Color', 'Mileage']))
file.write('\n')
for car_v in inventory.cars:
file.write('%s\n' % car_v)
file.close()
print('The vehicle inventory has been exported to a file')
elif User_Choice == '6':
#exit the loop
print('Goodbye')
break
else:
#invalid user input
print('This is an invalid input. Please try again.')

Downloadable Source Code Below

I have here the list of Best Python Project with Source code free to download for free, I hope this can help you a lot.

Summary

That’s how you create Vehicle Inventory System in Python in your projects.

You can always expand and try different ways in implementing the Vehicle Inventory System in Python in your Python projects. 

In this Vehicle Inventory System in Python is free to download and it is a console based system.

This project is good for the student who want to learn python programming because this project contains a Graphical User Interface (GUI) and a users friendly.

It is easy to understand and manipulate this project and use for education purpose only.

Related Articles

Inquiries

If you have any questions or suggestions about Vehicle Inventory System in Python, please feel free to leave a comment below.

Leave a Comment