# BOOKING MANAGEMENT SYSTEM
# 1. View all Seats
# seats are from 1 to 50 only
# 2. Booking
# On Booking, the seat changes from 1 to B
# If seat is already booked, then display a message
# 3. Cancellation
# Change seat number from B to original number
# 4. Exit
print("\n\n\n-----------------------------------------------------------------------------")
print("------------------------- Welcome to Python Booking System ------------------")
Seats = []
allBookedSeats =[]
check = True
for seat in range(1,51):
Seats.append(seat)
while check:
print()
print("-------------------------------------------------------------------------------")
print('''\n Press
1. View All Seats
2. Book Your Seat
3. Cancel your Booking
4. Exit from System
''')
print("-------------------------------------------------------------------------------")
choice = int(input("Enter Your choice: "))
# 1. ------------------------------------ View ALL Seats
if choice==1:
for seat in Seats:
print(" ",seat, end=' ')
print()
# 2. -------------------------------------- Booking Seats
if choice==2:
show = 0
# Show All Booked Seats to User
print()
for book_seat in allBookedSeats:
print("Seat No.: ",book_seat+1," is Booked" )
show += 1
if show==0:
print("All seats are Empty")
# Booking Seats
print()
print("To book Your seat, Enter an Empty Seat Number: ")
seat_num = int(input())
if Seats.count(seat_num):
Seats[seat_num-1] = 'BOOKED'
allBookedSeats.append(seat_num-1)
print("Your Seat is Successfully Booked! ")
else:
print("Oops! Seat is already Booked")
# 3. ------------------------------------------ Cancel Booking
if choice==3:
cancel_seat = int(input("Enter Seat Number to cancel Your Booking: "))
if type(Seats[cancel_seat-1])==int:
print("This seat is already vacant ")
else:
Seats[cancel_seat-1] = cancel_seat
print("Seat is Successfully Cancelled! ")
# 4. ------------------------------------------ Exit
if choice==4:
check = False
Practicing Lists in Python – Employee Management System
# EMPLOYEE MANAGEMENT SYSTEM
# 1. View all the details of employees
# 2. Inserting a new Employee
# 3. Deleting details of an Employee
# 4. Updating
# 5. Searching
# 6. Exit
print("\n----------------------------------------------------------------")
print('''Press:
1 - View All Details of Employee
2 - Insert New Employee
3 - Delete an Employee
4 - Update Employee's info
5 - Search Details of an Employee
6 - Exit
''')
print("----------------------------------------------------------------")
emp_exit= True
Employee = []
while(emp_exit):
print("\n----------------------------------------------------------------")
choice = int(input("Enter Your Choice: "))
#--------------------------------- View all details of Employee
if choice==1:
if len(Employee)==0:
print("No Employees' details exists in the System")
else:
for employees in Employee:
print(employees)
#-------------------------------- Inserting New Employee
if choice==2:
print("You need to give Details Of Employee ")
emp_id = int(input("\tID: "))
# Checking Duplicate ID
dup_id = 'NO'
if len(Employee)!= 0:
inc = 0
for allemps in Employee:
if Employee[inc][0]==emp_id:
print("Oops! Employee with this ID already exists...")
dup_id='YES'
break
else:
inc += 1
if dup_id=='NO':
emp_name = input("\tName: ")
emp_dept_no = int(input("Department No.: "))
emp_salary = int(input("Salary: "))
employees = []
employees.append(emp_id)
employees.append(emp_name)
employees.append(emp_dept_no)
employees.append(emp_salary)
Employee.append(employees)
#--------------------------------- Deleting Employee
if choice==3:
if len(Employee)==0:
print("System contains 0 records...")
else:
inc = 0
print("Do you want to Delete an Employee from the system?")
ans = input("Yes/No ").upper()
if ans=="YES":
del_id = int(input("Enter ID of Employee which you want to Delete "))
for allemps in Employee:
if Employee[inc][0]==del_id:
del(Employee[inc])
inc += 1
else:
print("This Employee doesn't exist in the System")
break
else:
pass
# --------------------- Update Details of Emps
if choice==4:
if len(Employee)==0:
print("System contains 0 records...")
else:
print("Please give ID of the Employee whose info you want to Update... ")
updat_id = int(input("ID: "))
print('''Press
'N' for updating Name
'S' for updating Salary
'D' for updating Dept ID
''')
ans = input().upper()
inc = 0
id_match_found = False
for allemps in Employee:
if Employee[inc][0]==updat_id:
id_match_found = True
if ans=='N':
allemps[1] = input("Enter New Name of Employee ")
if ans=='S':
allemps[3]= int(input("Enter New Salary "))
if ans=='D':
allemps[2]= int(input("Enter New Dept. ID "))
else:
inc += 1
# if ID is wrongly entered, then a message is sent to the user
if not id_match_found:
print("Oops! No Employee with this ID exists...")
# ---------------------------- Searching an Employee
if choice== 5:
if len(Employee)==0:
print("System contains 0 records...")
else:
inc = 0
print("Enter ID to search an Employee ")
search_id = int(input())
for allemps in Employee:
if Employee[inc][0]==search_id:
print(allemps)
#------------------------------- Exit option
if choice==6:
emp_exit = False
