Create a Vehicle Parking Management Project in Python

Create a Vehicle Parking Management in Python

Introduction

Hello friends, welcome to copyassignment.com. In this tutorial, we are going to Create a Vehicle Parking Management in Python. This project helps maintain the details of the vehicle owner, number, type, date, and the amount of time the vehicle is parked in the area. Accordingly, the bill generates for the particular vehicle parked in the area. This information is useful for all those who want to maintain the database of the individual who has parked their vehicles in the surroundings.

We are providing the complete code and detailed information about this project in this article.

Let us understand this project

1. Import Function and Initializing the variables

#Import Time
import time

Vehicle_Number=['XXXX-XX-XXXX']
Vehicle_Type=['Bike']
vehicle_Name=['Intruder']
Owner_Name=['Unknown']
Date=['22-22-3636']
Time=['22:22:22']
bikes=100
cars=250
bicycles=78

In this code block, we are importing the time module to implement its methods and function in the project. We have initialized the variables vehicle number, vehicle type, vehicle name, owner name date, and time to some default value. As well as bikes, cars, and bicycles with some initial value.

2. Create a while loop block to display the options in Vehicle Parking Management Project

def main():
    global bikes,cars,bicycles
    try:
        while True:
            print("-----------------------------------------------------")
            print("\t\tParking Management System")
            print("-------------------------------------------------------")
            print("1.Vehicle Entry")
            print("2.Remove Entry" )
            print("3.View Parked Vehicle ")
            print("4.View Left Parking Space ")
            print("5.Amount Details ")
            print("6.Bill")
            print("7.Close Programme ")
            print("+---------------------------------------------+")
            ch=int(input("\tSelect option:"))

In this code block, we have initialized the bikes, cars, and bicycles as global variables. They are accessible through the entire main block. Here we are providing the options to choose the service options from the list, for the vehicle parking management system.

Now we will understand each service option in detail.

Code for vehicle number entry

if ch==1:
    no=True
    while no==True:
        Vno=input("\tEnter vehicle number (XXXX-XX-XXXX) - ").upper()
        if Vno=="":
            print("###### Enter Vehicle No. ######")
        elif Vno in Vehicle_Number:
            print("###### Vehicle Number Already Exists")
        elif len(Vno)==12:
            no=not True
            Vehicle_Number.append(Vno)
        else:
            print("###### Enter Valid Vehicle Number ######")

Ch is for choice, Once we select the ch option as 1 which is for vehicle entry number, then we provide the while loop. while the number(no is True). We will store the vehicle number in Vno. If the vno is empty i.e vno==“”.The user asks to enter the vehicle number, else If the vno entered is already present in the vehicle number then it prints the vehicle number already exists. Else if len(vno)==12, It will ask to append the info to the vehicle number variable.

Code to enter the vehicle type

typee=True
while typee==True:
    Vtype=str(input("\tEnter vehicle type(Bicycle=A/Bike=B/Car=C):")).lower()
    if Vtype=="":
        print("###### Enter Vehicle Type ######")
    elif Vtype=="a":
        Vehicle_Type.append("Bicycle")
        bicycles-=1
        typee=not True
    elif Vtype=="b":
        Vehicle_Type.append("Bike")
        bikes-=1
        typee=not True
    elif Vtype=="c":
        Vehicle_Type.append("Car")
        cars-=1
        typee=not True
    else:
        print("###### Please Enter Valid Option ######")

Here we have to initialize the typee variable to true. While the condition is True, the system asks to enter the vehicle type i.e a,b, or c which will accept the input in the lower case. Here A is for bicycle, B is for Bike and C is for Car. Any vehicle type you enter is stored in the variable Vtype. If the Vtype==””(empty). It will ask to enter the vehicle type.  According to the type of variable you enter the vehicle type will be stored in the variable and typee variable is set to not True.

Code to enter the vehicle name

name=True
while name==True:
    vname=input("\tEnter vehicle name - ")
    if vname=="":
        print("########Please Enter Vehicle Name ########")
    else:
        vehicle_Name.append(vname)
        name=not True

Here we have set the name== True. While the name == True i.e until we enter the name.vname store the value i.e. vehicle name.  if the vname is empty system asks to enter the vehicle name, else it will store the name using the append function to the vehicle name variable The name variable is initialized to not True.

Code to enter the owners name

o=True
while o==True:
    OName=input("\tEnter owner name - ")
    if OName=="":
        print("###### Please Enter Owner Name ######")
    else:
        Owner_Name.append(OName)
        o=not True

O is initialized to True. While the condition satisfies the Owner’s name is stored in the OName variable. If the OName is empty it system asks to enter the owner name else it will store the Owner name in the owner name variable. O is now initialized to Not True.

Code enter the date and time

d=True
while d==True:
    date=input("\tEnter Date (DD-MM-YYYY) - ")
    if date=="":
        print("###### Enter Date ######")
    elif len(date)!=10:
        print("###### Enter Valid Date ######")
    else:
        Date.append(date)
        d=not True
t=True
while t==True:
    time=input("\tEnter Time (HH:MM:SS) - ")
    if t=="":
        print("###### Enter Time ######")
    elif len(time)!=8:
        print("###### Please Enter Valid Time ######")
    else:
        Time.append(time)
        t=not True
print("\n............................................................Record 

Similarly, we have to create a while loop to enter the date and time initializing d and t to 0. Date variable stores the date and the time-variable stores time. The date and time variable checks the condition and accordingly execute further.

Code to remove the entry from the register

elif ch==2:
    no=True
    while no==True:
        Vno=input("\tEnter vehicle number to Delete(XXXX-XX-XXXX) - ").upper()
        if Vno=="":
            print("###### Enter Vehicle No. ######")
        elif len(Vno)==12:
            if Vno in Vehicle_Number:
                i=Vehicle_Number.index(Vno)
                Vehicle_Number.pop(i)
                Vehicle_Type.pop(i)
                vehicle_Name.pop(i)
                Owner_Name.pop(i)
                Date.pop(i)
                Time.pop(i)
                no=not True
                print("\n............................................................Removed Sucessfully..................................................................")
            elif Vno not in Vehicle_Number:
                print("###### No Such Entry ######")
            else:
                print("Error")
        else:
            print("###### Enter Valid Vehicle Number ######")

In this code block, we are writing the code to remove the particular entry of a vehicle from the database. Users have entered a valid vehicle number to Create a Vehicle Parking Management in Python. If the vehicle number is present in our database and if the length of the vehicle number is 12 then it uses a pop function to remove the particular entry.  Else if the vehicle number is not present in the database it will print “No such Entry” and asks to enter a valid vehicle number.

Code to display the vehicles present in the parking area

elif ch==3:
    count=0
    print("----------------------------------------------------------------------------------------------------------------------")
    print("\t\t\t\tParked Vehicle")
    print("----------------------------------------------------------------------------------------------------------------------")
    print("Vehicle No.\tVehicle Type        Vehicle Name\t       Owner Name\t     Date\t\tTime")
    print("----------------------------------------------------------------------------------------------------------------------")
    for i in range(len(Vehicle_Number)):
        count+=1
        print(Vehicle_Number[i],"\t  ",Vehicle_Type[i],"\t            ",vehicle_Name[i],"\t       ",Owner_Name[i],"      " ,Date[i],"          ",Time[i])
    print("----------------------------------------------------------------------------------------------------------------------")
    print("------------------------------------------ Total Records - ",count,"-------------------------------------------------------")
    print("--------------------------------------------------------------------

Here ch==3  is for displaying the parked vehicles in the parking area. For this, we have to use the for loop function. It counts the length of the vehicle number. This will display the whole information of the vehicles.

Code for spaces left in the parking area

elif ch==4:
    print("----------------------------------------------------------------------------------------------------------------------")
    print("\t\t\t\tSpaces Left For Parking")
    print("----------------------------------------------------------------------------------------------------------------------")
    print("\tSpaces Available for Bicycle - ",bicycles)
    print("\tSpaces Available for Bike - ",bikes)
    print("\tSpaces Available for Car - ",cars)
    print("---------------------------------------------------------------------

This block of code displays the spaces left for parking in the parking area.

Code for displaying the parking rate

elif ch==5:
    print("----------------------------------------------------------------------------------------------------------------------")
    print("\t\t\t\tParking Rate")
    print("----------------------------------------------------------------------------------------------------------------------")
    print("*1.Bicycle      Rs20 / Hour")
    print("*2.Bike         Rs40/ Hour")
    print("*3.Car          Rs60/ Hour")
    print("---------------------------------------------------------------------

It displays the parking rate of different types of vehicles.

Code to generate bills for different types of vehicles parked

elif ch==6:
    print(".............................................................. Generating Bill ..........................................................................")
    no=True
    while no==True:
        Vno=input("\tEnter vehicle number to Delete(XXXX-XX-XXXX) - ").upper()
        if Vno=="":
            print("###### Enter Vehicle No. ######")
        elif len(Vno)==12:
            if Vno in Vehicle_Number:
                i=Vehicle_Number.index(Vno)
                no=not True
            elif Vno not in Vehicle_Number:
                print("###### No Such Entry ######")
            else:
                print("Error")
        else:
            print("###### Enter Valid Vehicle Number ######")
    print("\tVehicle Check in time - ",Time[i])
    print("\tVehicle Check in Date - ",Date[i])
    print("\tVehicle Type - ",Vehicle_Type[i])
    inp=True
    amt=0
    while inp==True:
        hr=input("\tEnter No. of Hours Vehicle Parked - ").lower()
        if hr=="":
            print("###### Please Enter Hours ######")
        elif int(hr)==0 and Vehicle_Type[i]=="Bicycle":
            amt=20
            inp=not True
        elif int(hr)==0 and Vehicle_Type[i]=="Bike":
            amt=40
            inp=not True
        elif int(hr)==0 and Vehicle_Type[i]=="Car":
            amt=60
            inp=not True
        elif int(hr)>=1:
            if Vehicle_Type[i]=="Bicycle":
                amt=int(hr)*int(20)
                inp=not True
            elif Vehicle_Type[i]=="Bike":
                amt=int(hr)*int(40)
                inp=not True
            elif Vehicle_Type[i]=="Car":
                amt=int(hr)*int(60)
                inp=not True
    print("\t Parking Charge - ",amt)
    ac=18/100*int(amt)
    print("\tAdd. charge 18 % - ",ac)
    print("\tTotal Charge - ",int(amt)+int(ac))
    print("..............................................................Thank you for using our service...........................................................................")
    a=input("\tPress Any Key to Proceed - ")
elif ch==7:
    print("..............................................................Thank you for using our service...........................................................................")
    print("                                     **********(: Bye Bye :)**********")
    break
    quit

The billing section generates the bill for the vehicle parked. We have to enter the correct vehicle number and check the length of the vehicle number and the vehicle number present in the database. After this check the time and the type of vehicle. Depending upon the vehicle type the system calculates the charges. The last choice ch==7 is to come out of the service options and quit the program.

Complete Code to Create a Vehicle Parking Management Project in Python

#Import Time
import time

Vehicle_Number=['XXXX-XX-XXXX']
Vehicle_Type=['Bike']
vehicle_Name=['Intruder']
Owner_Name=['Unknown']
Date=['22-22-3636']
Time=['22:22:22']
bikes=100
cars=250
bicycles=78
def main():
    global bikes,cars,bicycles
    try:
        while True:
            print("----------------------------------------------------------------------------------------")
            print("\t\tParking Management System")
            print("----------------------------------------------------------------------------------------")
            print("1.Vehicle Entry")
            print("2.Remove Entry" )
            print("3.View Parked Vehicle ")
            print("4.View Left Parking Space ")
            print("5.Amount Details ")
            print("6.Bill")
            print("7.Close Programme ")
            print("+---------------------------------------------+")
            ch=int(input("\tSelect option:"))
            if ch==1:
                no=True
                while no==True:
                    Vno=input("\tEnter vehicle number (XXXX-XX-XXXX) - ").upper()
                    if Vno=="":
                        print("###### Enter Vehicle No. ######")
                    elif Vno in Vehicle_Number:
                        print("###### Vehicle Number Already Exists")
                    elif len(Vno)==12:
                        no=not True
                        Vehicle_Number.append(Vno)
                    else:
                        print("###### Enter Valid Vehicle Number ######")
                typee=True
                while typee==True:
                    Vtype=str(input("\tEnter vehicle type(Bicycle=A/Bike=B/Car=C):")).lower()
                    if Vtype=="":
                        print("###### Enter Vehicle Type ######")
                    elif Vtype=="a":
                        Vehicle_Type.append("Bicycle")
                        bicycles-=1
                        typee=not True
                    elif Vtype=="b":
                        Vehicle_Type.append("Bike")
                        bikes-=1
                        typee=not True
                    elif Vtype=="c":
                        Vehicle_Type.append("Car")
                        cars-=1
                        typee=not True
                    else:
                        print("###### Please Enter Valid Option ######")
                name=True
                while name==True:
                    vname=input("\tEnter vehicle name - ")
                    if vname=="":
                        print("########Please Enter Vehicle Name ########")
                    else:
                        vehicle_Name.append(vname)
                        name=not True
                o=True
                while o==True:
                    OName=input("\tEnter owner name - ")
                    if OName=="":
                        print("###### Please Enter Owner Name ######")
                    else:
                        Owner_Name.append(OName)
                        o=not True
                d=True
                while d==True:
                    date=input("\tEnter Date (DD-MM-YYYY) - ")
                    if date=="":
                        print("###### Enter Date ######")
                    elif len(date)!=10:
                        print("###### Enter Valid Date ######")
                    else:
                        Date.append(date)
                        d=not True
                t=True
                while t==True:
                    time=input("\tEnter Time (HH:MM:SS) - ")
                    if t=="":
                        print("###### Enter Time ######")
                    elif len(time)!=8:
                        print("###### Please Enter Valid Date ######")
                    else:
                        Time.append(time)
                        t=not True
                print("\n............................................................Record detail saved..................................................................")
            elif ch==2:
                no=True
                while no==True:
                    Vno=input("\tEnter vehicle number to Delete(XXXX-XX-XXXX) - ").upper()
                    if Vno=="":
                        print("###### Enter Vehicle No. ######")
                    elif len(Vno)==12:
                        if Vno in Vehicle_Number:
                            i=Vehicle_Number.index(Vno)
                            Vehicle_Number.pop(i)
                            Vehicle_Type.pop(i)
                            vehicle_Name.pop(i)
                            Owner_Name.pop(i)
                            Date.pop(i)
                            Time.pop(i)
                            no=not True
                            print("\n............................................................Removed Sucessfully..................................................................")
                        elif Vno not in Vehicle_Number:
                            print("###### No Such Entry ######")
                        else:
                            print("Error")
                    else:
                        print("###### Enter Valid Vehicle Number ######")
            elif ch==3:
                count=0
                print("----------------------------------------------------------------------------------------------------------------------")
                print("\t\t\t\tParked Vehicle")
                print("----------------------------------------------------------------------------------------------------------------------")
                print("Vehicle No.\tVehicle Type        Vehicle Name\t       Owner Name\t     Date\t\tTime")
                print("----------------------------------------------------------------------------------------------------------------------")
                for i in range(len(Vehicle_Number)):
                    count+=1
                    print(Vehicle_Number[i],"\t  ",Vehicle_Type[i],"\t            ",vehicle_Name[i],"\t       ",Owner_Name[i],"      " ,Date[i],"          ",Time[i])
                print("----------------------------------------------------------------------------------------------------------------------")
                print("------------------------------------------ Total Records - ",count,"-------------------------------------------------------")
                print("----------------------------------------------------------------------------------------------------------------------")
            elif ch==4:
                print("----------------------------------------------------------------------------------------------------------------------")
                print("\t\t\t\tSpaces Left For Parking")
                print("----------------------------------------------------------------------------------------------------------------------")
                print("\tSpaces Available for Bicycle - ",bicycles)
                print("\tSpaces Available for Bike - ",bikes)
                print("\tSpaces Available for Car - ",cars)
                print("----------------------------------------------------------------------------------------------------------------------")
            elif ch==5:
                print("----------------------------------------------------------------------------------------------------------------------")
                print("\t\t\t\tParking Rate")
                print("----------------------------------------------------------------------------------------------------------------------")
                print("*1.Bicycle      Rs20 / Hour")
                print("*2.Bike         Rs40/ Hour")
                print("*3.Car          Rs60/ Hour")
                print("----------------------------------------------------------------------------------------------------------------------")
            elif ch==6:
                print(".............................................................. Generating Bill ..........................................................................")
                no=True
                while no==True:
                    Vno=input("\tEnter vehicle number to Delete(XXXX-XX-XXXX) - ").upper()
                    if Vno=="":
                        print("###### Enter Vehicle No. ######")
                    elif len(Vno)==12:
                        if Vno in Vehicle_Number:
                            i=Vehicle_Number.index(Vno)
                            no=not True
                        elif Vno not in Vehicle_Number:
                            print("###### No Such Entry ######")
                        else:
                            print("Error")
                    else:
                        print("###### Enter Valid Vehicle Number ######")
                print("\tVehicle Check in time - ",Time[i])
                print("\tVehicle Check in Date - ",Date[i])
                print("\tVehicle Type - ",Vehicle_Type[i])
                inp=True
                amt=0
                while inp==True:
                    hr=input("\tEnter No. of Hours Vehicle Parked - ").lower()
                    if hr=="":
                        print("###### Please Enter Hours ######")
                    elif int(hr)==0 and Vehicle_Type[i]=="Bicycle":
                        amt=20
                        inp=not True
                    elif int(hr)==0 and Vehicle_Type[i]=="Bike":
                        amt=40
                        inp=not True
                    elif int(hr)==0 and Vehicle_Type[i]=="Car":
                        amt=60
                        inp=not True
                    elif int(hr)>=1:
                        if Vehicle_Type[i]=="Bicycle":
                            amt=int(hr)*int(20)
                            inp=not True
                        elif Vehicle_Type[i]=="Bike":
                            amt=int(hr)*int(40)
                            inp=not True
                        elif Vehicle_Type[i]=="Car":
                            amt=int(hr)*int(60)
                            inp=not True
                print("\t Parking Charge - ",amt)
                ac=18/100*int(amt)
                print("\tAdd. charge 18 % - ",ac)
                print("\tTotal Charge - ",int(amt)+int(ac))
                print("..............................................................Thank you for using our service...........................................................................")
                a=input("\tPress Any Key to Proceed - ")
            elif ch==7:
                print("..............................................................Thank you for using our service...........................................................................")
                print("                                     **********(: Bye Bye :)**********")
                break
                quit
    except:
        main()
main()

Output

Output of Create a Vehicle Parking Management in Python

Here we have successfully created the vehicle Parking Management system. For more articles on python, keep visiting the website.

Thank you for reading this article.

Vehicle Parking Management System Python

In this post, we talked about the vehicle parking management system python with complete source code and output, some people were also demanding the report for this project as they want this project to submit in their college project but to be honest if you will copy this you will be caught and your professor will fail you for plagiarism. So if you want a unique code with a report then WhatApp me at +919760648231


Also Read:

Share:
Avatar of pranjal dev

Author: pranjal dev