Cs Project
Cs Project
Index 1
Introduction To Python 2
Features Of Python 2
Requirements 6
Mysql Overview 7
Project Criteria 8
Source Code 9
Output 20
Conclusion 23
INTRODUCTION TO PYTHON
It is used for:
Python was designed for readability, and has some similarities to the
English language with influence from mathematics. Python uses new
lines to complete a command, as opposed to other programming
languages which often use semicolons or parentheses. Python relies
on indentation, using whitespace, to define scope; such as the scope
of loops, functions and classes. Other programming languages often
use curly-brackets for this purpose.
2
FEATURES OF PYTHON
2. Easy to code
Python is a high-level programming language. Python is very easy to
learn the language as compared to other languages like C, C#,
Javascript, Java, etc. It is very easy to code in the Python language
and anybody can learn Python basics in a few hours or days. It is also
a developer-friendly language
3. Easy to Read
Learning Python is quite simple. Python’s syntax is really
straightforward. The code block is defined by the indentations rather
than by semicolons or brackets.
4. Object-Oriented Language
3
One of the key features of Python is Object-Oriented programming.
Python supports object-oriented language and concepts of classes,
object encapsulation, etc.
6. High-Level Language
Python is a high-level language. When we write programs in Python,
we do not need to remember the system architecture, nor do we
need to manage the memory.
7. Extensible feature
Python is an Extensible language. We can write some Python code
into C or C++ language and also we can compile that code in C/C++
language.
8. Easy to Debug
Excellent information for mistake tracing. You will be able to quickly
identify and correct the majority of your program’s issues once you
understand how to interpret Python’s error traces. Simply by
4
glancing at the code, you can determine what it is designed to
perform.
5
every single thing. There are many libraries present in Python such
as regular expressions, unit-testing, web browsers, etc.
6
REQUIREMENTS
Operating system Windows 7 or above
RAM 512MB+
MySQL OVERVIEW
7
created for personal usage from mSQL based on the low-level
language ISAM, which the creators considered too slow and
inflexible. They created a new SQL interface, while keeping the
same API as mSQL. MySQL Server 5.5 was generally available (as of
December 2010). Enhancements and features include:
Advantages Of MySQL
1. Open Source
2. Data Security
3. Scalability On Demand
8
4. Higher Efficiency
5. 24×7 Server Uptime
PROJECT CRITERIA
SOURCE CODE
USE airsys;
9
INSERT INTO FLIGHTS VALUES("LF007","LUFTHANSA","TOKYO","WISCONSIN",70000,"2019-06-07",80000);
CREATE TABLE BOOKINGS (BNO varchar (5) primary key , FNO varchar(5) not null ,PASSENGER_NAME
varchar(25),GENDER char(1), AGE int(2));
PYTHON PROGRAM
#FEW FUNCTIONS FOR CODE-
def bo():
while True:
import mysql.connector
r=input("Enter FNO (Flight Number): ")
db=mysql.connector.connect(host='localhost',user='root',password='ann
ie@MySQL2023',database='airsys')
cursor=db.cursor()
Query1=("select * from flights where FNO='%s'" %(r))
cursor.execute(Query1)
res=cursor.fetchall()
if not res:
print("No such flight exists")
cursor.close()
else:
print("Enter passenger details: ")
s=input("Enter your name: ")
while True:
t=int(input("Enter your age: "))
10
if t>100 or t<=0:
print("Enter age 0 to 100")
else:
break
while True:
u=input("Enter your gender(F/M): ")
if not (u=="F" or u=="M"):
print("Enter only F or M")
else:
break
if o!="Y":
break
else:
for i in result:
tbno=int(i[0])
l=tbno+1
Query=("insert into
bookings(BNO,FNO,PASSENGER_NAME,AGE,GENDER) values(%s,%s,%s,%s,%s)")
data=(l,r,s,t,u)
cursor.execute(Query,data)
db.commit()
print("Your booking has been confirmed.\n")
print("This is your booking-","YOUR BOOKING NO:",l,",
FNO:",r,", PASSENGER_NAME:",s,", AGE:",t,", GENDER:",u,end='\n')
cursor.close()
11
break
def db():
import mysql.connector
db=mysql.connector.connect(host='localhost',user='root',password='ann
ie@MySQL2023',database='airsys')
cursor=db.cursor()
Query1=("select * from bookings where BNO='%s'" %(r))
cursor.execute(Query1)
res=cursor.fetchall()
if not res:
else:
f=input("Are you sure you want to delete this booking (Y/N):
")
if f=='Y':
Query=("delete from bookings where BNO='%s'" %(r))
cursor.execute(Query)
db.commit()
cursor.close()
def af():
12
import mysql.connector
db=mysql.connector.connect(host='localhost',user='root',password='ann
ie@MySQL2023',
database='airsys')
cursor=db.cursor()
cursor.execute("select * from flights")
result=cursor.fetchall()
print("{0:10}{1:12}{2:14}{3:15}{4:7}{5:13}{6:12}".format("===","=====
===","======","===========","====","===========","==========="))
print("{0:10}{1:12}{2:14}{3:15}{4:7}{5:13}{6:12}".format("FNO","AIRLI
NES","SOURCE","DESTINATION","FARE","FLIGHT_DATE","FLIGHT_TIME"))
print("{0:10}{1:12}{2:14}{3:15}{4:7}{5:13}{6:12}".format("===","=====
===","======","===========","====","===========","==========="))
for x in result:
print
("{0:10}{1:12}{2:14}{3:13}{4:6}".format(x[0],x[1],x[2],x[3],x[4]),"
",x[5]," ",x[6])
cursor.close()
def anf():
import mysql.connector
db=mysql.connector.connect(host='localhost',user='root',password='ann
ie@MySQL2023',
database='airsys')
cursor=db.cursor()
13
Query1=("select * from flights where FNO='%s'" %(h))
cursor.execute(Query1)
res=cursor.fetchall()
if not res:
cursor.close()
else:
def ef():
import mysql.connector
r=input("Enter flight number: ")
db=mysql.connector.connect(host='localhost',user='root',password='ann
ie@MySQL2023',database='airsys')
cursor=db.cursor()
14
Query1=("select * from flights where FNO='%s'" %(r))
cursor.execute(Query1)
res=cursor.fetchall()
if not res:
cursor.close()
else:
print("MENU OF
FIELDS","\n","1.AIRLINES","\n","2.SOURCE","\n","3.DESTINATION","\n","
4.FARE","\n","5.FLIGHT_DATE","\n","6.FLIGHT_TIME")
m=int(input("Enter your choice of field which you wish to
update: "))
o={1:'AIRLINES',2:'SOURCE',3:'DESTINATION',4:'FARE',5:'FLIGHT_DATE',6
:'FLIGHT_TIME'}
q=o.get(m)
n=input("Enter new value: ")
cursor.close()
def df():
import mysql.connector
15
db=mysql.connector.connect(host='localhost',user='root',password='ann
ie@MySQL2023',database='airsys')
cursor=db.cursor()
Query1=("select * from flights where FNO='%s'" %(r))
cursor.execute(Query1)
res=cursor.fetchall()
if not res:
else:
query2=("select count(*) from bookings where FNO='%s'" %(r))
cursor.execute(query2)
rs=cursor.fetchall()
if (rs[0][0])>0:
else:
f=input("Are you sure you want to delete this flight
(Y/N): ")
if f=='Y':
Query=("delete from flights where FNO='%s'" %(r))
cursor.execute(Query)
db.commit()
cursor.close()
16
def vb():
import mysql.connector
db=mysql.connector.connect(host='localhost',user='root',password='ann
ie@MySQL2023',
database='airsys')
cursor=db.cursor()
cursor.execute(" select
BOOKINGS.FNO,BNO,PASSENGER_NAME,GENDER,AGE,AIRLINES,SOURCE,DESTINATIO
N,FARE,FLIGHT_DATE,FLIGHT_TIME from FLIGHTS,BOOKINGs where
FLIGHTS.FNO=BOOKINGS.FNO")
reesult=cursor.fetchall()
print("{0:10}{1:10}{2:15}{3:8}{4:5}{5:12}{6:14}{7:15} {8:8}
{9:13}{10:13}".format("===","===","==============","=====","===","===
======","=====","============"," ====","===========","==========="))
print("{0:10}{1:10}{2:15}{3:8}{4:5}{5:12}{6:14}{7:15} {8:8}
{9:13}{10:13}".format("FNO","BNO","PASSENGER_NAME","GENDER","AGE","AI
RLINES","SOURCE","DESTINATION"," FARE","FLIGHT_DATE","FLIGHT_TIME"))
print("{0:10}{1:10}{2:15}{3:8}{4:5}{5:12}{6:14}{7:15} {8:8}
{9:13}{10:13}".format("===","===","==============","=====","===","===
======","=====","============"," ====","===========","==========="))
for xx in reesult:
age=xx[4]
fare=xx[8]
print("{0:10}{1:10}{2:15}{3:6}{4:5}
{5:12}{6:14}{7:15}{8:8}".format(xx[0],xx[1],xx[2],xx[3],age,xx[5],xx[
6],xx[7],fare)," ",xx[9]," ",xx[10])
cursor.close()
#MAIN CODE-
17
import getpass
while True:
if a=="C":
while True:
try:
print("--------------------------------\nCustomer
Menu:\n-------------------------------- \n 1. Available
flights","\n","2. Book a flight","\n","3. Cancel Booking","\n","4.
Exit from Customer Menu","\n","5. Exit from Airline System","\n")
if b==1:
af()
elif b==2:
bo()
elif b==3:
db()
elif b==4:
break
elif b==5:
print("Goodbye")
quit()
else:
print("Enter a number between 1 to 4 only")
18
except(ValueError,TypeError,NameError):
print("Enter correct values")
elif a=="A":
while True:
pwrd=input("Enter password: ")
if pwrd=="admin09":
print("\n","Welcome Administrator!","\n")
while True:
try:
print("-----------------------------------\nAdmin Menu:
\n----------------------------------- \n 1. Available
flights","\n","2. Add a new flight","\n","3. Edit a flight","\n","4.
Delete a flight","\n","5. View all bookings","\n","6. Exit from Admin
Menu","\n","7. Exit from Airline System","\n")
c=int(input("Enter your choice:
(1/2/3/4/5/6/7) \n"))
if c==1:
af()
elif c==2:
anf()
elif c==3:
ef()
elif c==4:
df()
elif c==5:
vb()
elif c==6:
break
elif c==7:
19
print("Goodbye")
quit()
else:
print("Enter a number between 1 to 7
only")
except(ValueError,TypeError,NameError):
print("enter correct values")
break
else:
print("Incorrect password.","\n")
else:
print("Enter only A or C")
OUTPUT
20
21
22
CONCLUSION
23