Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
66 views

Pythoncode

This Python code defines functions for an airline ticket reservation system. It connects to a MySQL database and defines functions for registering customers, viewing class types and menus, calculating ticket and luggage prices, and displaying a menu for users to select these options. The main loop displays the menu and runs the selected function, allowing users to make reservations, view details, and re-run the program multiple times.

Uploaded by

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

Pythoncode

This Python code defines functions for an airline ticket reservation system. It connects to a MySQL database and defines functions for registering customers, viewing class types and menus, calculating ticket and luggage prices, and displaying a menu for users to select these options. The main loop displays the menu and runs the selected function, allowing users to make reservations, view details, and re-run the program multiple times.

Uploaded by

SAI KUN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

import mysql.

connector
import os
import platform

mydb = mysql.connector.connect(user="root", password="lmao@1234#$",


host="localhost", database="air")
mycursor = mydb.cursor()

def registercust():
L = []
name = input('Enter name: ')
L.append(name)
addr = input("Enter address: ")
L.append(addr)
jr_date = input("Enter date of journey: ")
L.append(jr_date)
source = input("Enter source: ")
L.append(source)
destination = input("Enter destination: ")
L.append(destination)

cust = tuple(L)
sql = "INSERT INTO pdata (custname, addr, jrdata, source, destination) VALUES
(%s, %s, %s, %s, %s)"
mycursor.execute(sql, cust)
mydb.commit()

def classtypreview():
print("Do you want to see class types available? Enter 1 for yes:")
ch = int(input('Enter your choice: '))
if ch == 1:
sql = "SELECT * FROM classtype"
mycursor.execute(sql)
rows = mycursor.fetchall()
for i in rows:
print(i)

def ticketprice():
print("We have the following rooms for you:-")
print("1. Type First class -> Rs 6000 PN")
print("2. Type Business class -> Rs 4000 PN")
print("3. Type Economy class -> Rs 2000 PN")

x = int(input('Enter your choice: '))


n = int(input("No of passengers: "))

if x == 1:
print("You have opted First class")
s = 6000 * n
elif x == 2:
print("You have opted Business class")
s = 4000 * n
elif x == 3:
print("You have opted Economy class")
s = 2000 * n
else:
print("Please choose a class type")

print("Your room rent is", s)


def menuview():
print("Do you want to see the menu available? Enter 1 for yes.")
ch = int(input("Enter your choice: "))
if ch == 1:
sql = "SELECT * FROM food"
mycursor.execute(sql)
rows = mycursor.fetchall()
for x in rows:
print(x)

def orderitem():
# Your order item logic goes here
pass

def lugagebill():
global z
print("Do you want to see rates for luggage? Enter 1 for yes.")
ch = int(input("Enter your choice: "))
if ch == 1:
sql = "SELECT * FROM lugage"
mycursor.execute(sql)
rows = mycursor.fetchall()
for x in rows:
print(x)
y = int(input("Enter the weight of extra luggage: "))
z = y * 1000
print("Your luggage bill is", z)

def ib():
print(z)

def res():
print(s)

def ticketamount():
a = input("Enter customer name: ")
print("Customer name:", a)
print("Luggage bill:", z)
print("Food bill: total amount")

def Menuset():
print("AIR TICKET RESERVATION")
print("1. Enter customer data")
print("2. View class")
print("3. Ticket amount")
print("4. View food menu")
print("5. Order item")
print("6. Luggage bill")
print("7. Complete amount")
print("8. Exit")

try:
while True:
Menuset()
userinput = int(input("Enter your choice: "))
if userinput == 1:
registercust()
elif userinput == 2:
classtypreview()
elif userinput == 3:
ticketprice()
elif userinput == 4:
menuview()
elif userinput == 5:
orderitem()
elif userinput == 6:
lugagebill()
elif userinput == 7:
ticketamount()
elif userinput == 8:
quit()
else:
print("Enter correct choice")

except ValueError:
exit("\nHi, that's not a number")

def runagain():
runagn = input("\nWant to run again? (y/n): ")
while runagn.lower() == 'y':
if platform.system() == "windows":
os.system('cls')
else:
os.system('clear')
Menuset()
runagn = input("\nWant to run again? (y/n): ")

runagain()

You might also like