You are on page 1of 16

Ad Location Intelligence

MediaTek Open

Source Code
ans=" Y"
def guest () :

print ("\nl. show all the records of guest \n2.


add records of guest \n3. search records \n4. delete
records of guest \n5. Graphical representation \n6.
update the records")
x—int (input ("Enter the choice of no: )
if
showallrecords ( )

e lif
addrecords ( )

el if x==3:
search ()
el if x==4:
delete ( )

el if x==5:
guestgr ( )

el if x==6:
changerecord ( )

el if x
print INPUT")
def guestgr () :

print ("I. Rooms booked \n 2. Source of booking")


x—int (input ("enter the no: )
if x==l:
roomgraph ( )

el if x—=2:
sobgraph ( )
Ad Location Intelligence
MediaTek Open

— S SCRIBD Search

print ("INVAILD INPUT")


def roomgraph () :

import pymysql
import matplotlib .pyplot as pit

dl=pymysql .connect (host=" local host " ,user=" root " ,pas sw

cl=dl . cursor ( )

quer— from guest where


type of room=" single"
cl .execute (quer)
x=cl . fetchone ( )

Ist=list (x)
quer=' ' 'select count (* ) from guest where
type of ''
cl .execute (quer)
y=cl . fetchone ( )

Istl—list (y)
quer ' ' 'select count (* ) from guest where
type of
cl .execute (quer)
z=cl . fetchone ( )

1st2 list (z)


quer=' 'select count (* ) from guest where
type of
cl .execute (quer)
a—cl . fetchone ( )

1st3=1ist (a)
1stt=1st+1st1+1st2+1st3
["single" "double" , "triple" ,"quad" ]
PI t .bar (y, 1st t, width—O. 50)
plt.xlabel ("types of rooms")
PI t . ylabel ( "no . of rooms " )

PI t. show ()
def sobgraph () :

import pymysql
import matplotlib .pyplot as p It

dl=pymysql .connect (host=" local host 't


,user=" root " ,passw

cl=dl . cursor ( )

quer=' select count (* ) from guest where


source of booking="online";
cl .execute (quer)
x=cl . fetchone ( )

Ist=list (x)
quer="select count (* ) from guest where
source of booking='offline'

Download
S SCRIBD
Ad Location Intelligence
MediaTek Open

cl .execute (quer)
y=cl . fetchone ( )

1st I—list (y)


Istt=lst+lstl
Y = ["online" , "offline"]
plt.bar (y, 1st t, width—O .50)
plt.xlabel ("source of booking")
PI t . y label ( "no . of rooms ")
PI t. show ()
def showallrecords () :

import pymysql
import pandas as pd
pd. set option ('display .expand frame repr' ,False)

dl=pymysql .connect (host—" local host ",user=" root " ,passw


d=
cl=dl . cursor ( )

query "select * from guest; "


df=pd.read sql (query, dl)

df=df .rename ({ "guestid" :"id" "nameofguest" :"name" , "ty


pe of room" :"type of
room " , "noofdays" : "days ,

in " . "check
out " room no" :" room " , " source of booking " :" source of
booking" , "netpay" :"net payment " } ,axis—I)
print (df)
def addrecords () :

import pymysql
import pandas as pd

— root " ,passw


dl=pymysql .connect (host "local host", user—"

cl=dl . cursor ( )

ansl=" yes "


while
for i in range (1,201) :
x=i
quer2=" select * from guest where

cl .execute (quer2)
if cl .rowcount

break
y=input ("Enter the guest name :
an— " yes "
while an==" yes
v=input ("enter the type of room: ")
If v— single" •

Download
Deliver a smarter
Ad Location Intelligence x
MediaTek Open

SCRIBD Search

an="no
elif :
an="no
el if :
an="no
el if :
an=" no

print ("invaild input")


r=int (input ("enter the no. of days. ) )
ci=input ("enter the check in date: ")
co=input ("entr the check out date: ")
ans3="yes'
while yes
a—input ("Enter the source of booking: " )

ans3="nooo'
elif a=—

print ("invaild input"

if :
while ans2=="
for i in range (1, 51) :
c=i
quer2=" select * from guest where
room no=%d"
cl .execute (quer2)
if cl .
ans2="no"
break
el if double" :
while ans2=="ye
for i in range (51,101) :

quer2—" select * from guest where


room no=%d"
cl .execute (quer2)
if cl .
ans2—"no"
break
el if :
while ans2——"
for i in range (101,151) :
c—i
quer2 "select * from guest where
room no=%d"
cl .execute (quer2)

Download
— S SCRIBD Search
if cl .
ans2="no"
break
el if :
while ans2=="
for i in range (151,201) :
c=i
quer2=" select from guest where
room
cl .execute (quer2)
if cl
ans2="no"
break
if v — single"

el if double" :

el if v — "triple" :

el if quad" :

quer—"lnsert into guest


values (%d, '*s' %d, '96s'
co, c, a, b)
cl .execute (quer)
dl . commit ( )

print ("Record Added")


f=input ("Want to see the added record: " )
if

pd. set option ( 'display. expand frame repri ,False)


quer=" select * from guest where

df=pd. read sql (quer, dl)

dfl=df .rename ( { "guestid" : " i d" "nameofguest": "name" , "t


ype_of room" :"type of
room" , "noofdays " : "days " , "cidate" •

in "
out" 'room no" : " room " , " source of booking " : ''source of
booking" , "netpay" :"net payment" } ,axis=l)
print (dfl)
else:
print ("Thank You")
def search () :

import pymysql
import pandas as pd

Read without ads. SubscribeDownload


dl=pymysql .connect (user=" root" ,host=" local host " ,passw

cl=dl . cursor ( )

print ("I. Id \n2. Name \n3. Source of booking


\n4. Room no. \n5. date \n6. Type of room")
cho=int (input ("enter the no. )
if :

pd. set option ( 'display. expand frame repr' ,False)


x=int (input ("enter the i d: )
quer="select * from guest where
guestid=' 96d' • "
df=pd. read sql (quer, dl)

dfl=df . rename ( { "guestid" : " i d" "nameofguest" : "name" , "t

ype_of room" :"type of


room" , "noofdays " : "days" , "cidate" •

in", Cl-leck
out" 'room no" :"room " , "source of booking " source of
booking" ,"netpay" :"net payment") ,axis—I)
print (dfl)
el if cho—=2:

pd. set option ('display. expand frame repr' ,False)


x—input ("enter the name:
quer=" select * from guest where
nameofguest=' % s '

df=pd. read sq I (quer, d I)

dfl=df . rename ( { "guestid" : " i d" , "nameofguest" : "name " , "t

ype of room" :"type of


room " , "noofdays " : "days" ,

in "
out" room no" :"room " , "source of booking" :" source of
booking" ,"netpay" :"net payment " },axis=l)
print (dfl)
el if cho==3:

pd. set option ('display. expand frame repr' ,False)


x=input ("enter the source of booking:
quer=" select * from guest where
source of booking—
df=pd. read sql (quer, dl)

dfl=df .rename ( { "guestid" : " id" "nameofguest" : "name" , "t


ype of room" :"type of
room " , "noofdays " c i date" • C I-leck

in" , "codate" : "check

Download
S SCRIBD
out" 'room no" :"room " , "source of booking" :" source of
booking " "netpay": "net payment"), axis=l)
print (dfl)
elif

pd. set option ('display. expand frame repr' ,False)


x—int (input ("enter the room no: )
quer=" select * from guest where
room no=' •"
df=pd. read sqI (quer, d I)

dfl=df . rename ( { "guest i d" : " i d" "nameofguest" : "name" , "t

ype of room" :"type of


room " , "noofdays
in "
out " room no" : " room " , " source of booking ": " source of
booking" , "netpay": n payment") ,axis=l)
print (dfl)
el if cho==5:

pd. set option ('display. expand frame repr' ,False)


x=input ("enter the date: ")
from guest where cidate='

df=pd. read sqI (quer,dl)

dfl=df . rename ( { "guestid" : " i d" "nameofguest" : "name

ype of room" :"type of


room " , "noofdays " : "days" ,
' " , " codate" :

out" , "room no' 'room" 'source of booking" :" source of


booking" , "netpay" :"net payment") ,axis=l)
print (dfl)
el if cho==6:

pd. set option ('display. expand frame repr' ,False)


x=input ("enter the type of room: " )
quer=" select * from guest where
type of '"
df=pd. read sqI (quer, d I)

dfl=df .rename ( { "guestid" : "i d" "nameofguest" : "name" , "t


ype of room" :"type of
room " , "noofdays " : "days" , "cidate" :

" room no" : "room" , " source of booking source of


booking" , "netpay" :"net payment" } , axis—I)
print (dfl)
def delete () :

Download
Lisez sans publicité. Soescrire
import pymysql

dl=pymysql .connect (host=" local host" ,user=" root " ,passw

cl=dl . cursor ( )

x=int (input ("enter the i d: )


quer="delete from guest where "
rowcount=cl .execute (quer)
if rowcount>O:
dl . commit ( )

print ("Record Deleted")


else:
print ("NO RECORD FOUND")
def changerecord () :

import pymysql
import pandas as pd
pd. set option ('display. expand frame repr' ,False)

dl=pymysql .connect (user=" root" ,host=" localhost " ,pas sw

cl=dl . cursor ( )

guid=int (input ("enter the id: )


quer=" select * from guest where guestid=%d" %
guid
cl .execute (quer)
if cl .rowcount>O:
row=list (cl . fetchone ( ) )

df=pd. read sq] (quer, dl)


print (df)
print \n I. nameofguest \n2. source of
booking \n3. date \n4. type of room")
cr=int (input ("enter the no: )
if :
y=input ("enter the new name of guest:
guest set nameofguest='
where guestid=%d" % (Y' guid)
cl .execute (quer)
dl . commit ( )

print ("RECORD CHANGED")


el if cr==2:
y=input ("enter the new source guest: ")
guest set
source of booking=' where % (y,guid)
cl .execute (quer)
dl . commit ( )

print ("RECORD CHANGED" )


el if cr==3:
y=input ("enter the new date:

Download
Read without ads.
quer="update guest set cidate— where
guestid=%d" % (y,guid)
cl execute (quer)
dl . commit ( )

print ("RECORD CHANGED" )


elif cr==4:
y=input ("enter the new type of room: " )
guest set type_of room= '
where guestid=%d" % (Y'guid)
cl .execute (quer)
dl . commit ( )

quer4="se1ect nofdays from guest where


guestid=%d" % (guid)
cl .execute (quer4)
r=list (cl . fetchone )

If y— single":
while
for i in range (1, 51) :

quer2=" select * from guest


where room
cl .execute (quer2)
if cl .rowcount
ans2="no'
break
el if :
while ans2=="ye" :
for i in range (51,101) :

quer2=" select * from guest


where room
cl .execute (quer2)
if cl .

break
el if :
while ans2=="
for i in range (101,151) :
c=i
quer2=" select * from guest
where room no=%d"
cl .execute (quer2)
if cl .
ans2="no"
break
el if 'quad" :
while :
for i in range (151,201) :

Download
— g SCRIBD Search
quer2—” selece * from guest
where room
CI .execute (quer2)
if cl

break
guest set zoom rıo—'
where % (c, guid)
cl .execute (querl)
dl . commit ( )

if single” :
b-2000*r [0]+ [0]*9/50)
elif double” •
b-4000*r [0]+ [0]*9/50)
elif :
[0] *9/50)
elif y— ”quad” :

quer2 "update guest set where


guestid % (b, guid)
cl .execute (quer2)
dl . commit ( )

print ("RECORD CHANGED")


elif er
print (”INVAILD INPUT”)
elif CI .
print ("NO RECORD FOUND TO CHANGE”)
def staff() :
print (”Xn1. show all the records of staff Xn2.
add records of staffXn3. search records of staff Xn4.
del ete records of staff Xn5. Graphical representation
Xn6. update the records”)
x—int (input ("Enter the choice of no.
if
allrecords ( )

elif
addrecordss ( )

elif
searchrec ( )

elif
deleterec ( )

elif
staffgr ( )

elif
changerec ( )

elif
print (”XtXt1NVAILD INPUT”)
def staffgr() :

Download
Save 10% on Offical Exam Prep x
Hurry—offerends 15 Decenter SAVE NOW>

print ("1. Department \n2. Salary")


x=int (input ("enter the no: )
if
deptgraph ( )

el if
salgraph ( )

def deptgraph () :

import pymysql
import matplotlib .pypLot as PI t

dl =pymysql .connect (host=" local host" ,user—" root " passw

cl=dl . cursor ( )

quer=" select count (* ) from staff where


dept— managment ;"
cl .execute (quer)
x=cl . fetchone ( )

1 st—list (x)
quer=" select count (* ) from staff where
dept—' cleaning' ; "
cl .execute (quer)
y=cl . fetchone ( )

Istl=list (y)
quer=" select count (* ) from staff where dept—'food
and beverages '; "
cl .execute (quer)
z=cl . fetchone ( )

1st 2=1 ist (z)


1stt 1st+1st1+Ist2
Y— ["managment" , "cleaning" , " food & beverages"]
PI t .bar (y, 1st t)
PI t . xlabeL ( " department " )

pit .y label ("no .ofstaff" )


put. show ()
def salgraph() :
import pymysqL
import matplotlib .pyplot as PI t

dl=pymysql .connect (host=" local host" ,user=" root " ,passw


d
cl=dl . cursor ( )

quer=" select count (* ) from staff where sal=2000; "


cl .execute (quer)
x=cl . fetchone ( )

Ist=list (x)
quer=" select count (* ) from staff where sal=4000; "
cl .execute (quer)
y=cl . fetchone ( )

1st ist (y)

Read without ads. Subscribe M Download


Save 10% on Offical Exam Prep x
Hurry—offer ends 15 SAVENOW>

Read without ads. with a free trial

quer "select count (* ) from staff where sal=6000; "


cl .execute (quer)
z=cl . fetchone ( )

1st2=1ist (z)
Istt 1st+IstI+Ist2
Y ["2000" "4000" " 6000"]
put. bar (y,Istt)
PI t. x label salary" )
pit .ylabel ("no .ofstaff" )
put. show ()
def addrecordss () :

import pymysql

dl=pymysql .connect (host=" localhost" ,user=" root " ,passw


d=
cl=dl . cursor ( )

print ("\nl. cleaning \n2. food and beverages \n 3.


managment " )

print (
yes "
while ansl=="yes
for i in range (1,201) :

* from staff where

cl . execute (guer2 )
if cl . :
ansl—"no"
break
y=input ("Enter the name: ")
a—input ("Enter the department: ")
If a"" cleaning" :
j=2000
el if and beverages" :
j=4000
elif a "managment "•
j=6000
z input ("Enter the hiredate: ")
quer—"lnsert into staff
values (*d, '*s'
cl .execute (guer)
dl . commit ( )

print ("Record Added" )


f=input ("Want to see the added record: ")
if :
quer=" select * from staff where
cl .execute (quer)
rec=cl . fetchone ( )

Sid, sname, dept, sal, Hdate=rec


ox x
Save on Offical Exam Prep
Hurry—offerends 15 SAVE NOW>

— S SCRIBD Search

print ("staff id= "staff name=


"depatment= "salary=
"hireDate= %s"%Hdate, sep="\n")
else:
print ("THANK YOU")
def deleterec() :
import pymysql

dl=pymysql .connect (host=" local host " ,user=" root " ,pas sw

cl=dl . cursor ( )

x—int (input ("enter the i d: )


quer="delete from staff where " %x
rowcount=cl .execute (quer)
if rowcount>O:
dl . commit ( )

print ("Record Deleted")


else:
print ("NO RECORD FOUND")
def searchrec() :
import pymysql
import pandas as pd

dl=pymysql .connect (host=" local host " ,user=" root " ,pas sw
d=' " database="hotel")
cl=dl . cursor ( )

print ("\nl. id \n2. name \n3. dept \n4. salary


\n5. hiredate")
cho=int (input ("enter the no. )
if cho==l:

pd. set option ('display. expand frame repr' ,False)


x=int (input ("enter the id: )
* from staff where id=' ;"
df=pd. read sql (quer,dl)
print (df)
el if cho==2:

pd. set option ('display. expand frame repr' ,False)


x=input ("enter the name: ")
quer=" select * from staff where name='

df=pd. read sqI (quer,dl)


print (df)
el if cho==3:

pd. set option ('display. expand frame repr' ,False)


x=input ("enter the dept: " )

Download
ox x
Save on Offical Exam Prep
Hurry—offerends 15 SAVE NOW>

— S SCRIBD Search

quer="select * from staff where dept='

df=pd. read sql (quer,dl)


print (df)
elif cho==4:

pd. set option( 'display. expand frame repr' ,False)


x—int (input ("enter the salary: )
quer="select * from staff where
df=pd. read sq 1 (quer,dl)
print (df)
elif cho==5:

pd. set option( 'display. expand frame repr' ,False)


x=input ("enter the hire date:
quer="select * from staff where
"
hiredate='%s' ;

df=pd. read sql (quer,dl)


print (df)
el if cho!=[
print ("invaild input")
def changerec () :

import pymysql
import pandas as pd

dl=pymysql .connect (user=" root " ,host=" local host " ,passw

cl=dl . cursor ( )

sid=int (input ("enter the id: " ) )


quer="select * from staff where % sid
dfgg=pd. read sq] (quer, dl)
print (dfgg)
cl .execute (quer)
if cl.rowcount>O:
print ("1. id \n2. name \n3. department .
hire date")
cr=int (input ("enter the no: )
if cr==l:
ansl=" yes"
while ansl=="yes
y=int (input ("enter the id: )
querl=" select * from staff where

cl . execute (querl )
if cl .rowcount>O:
print ("DUPLICATE INPUT")
e lif cl .
ansl="no"

Download
x
Save on Offical Exam Prep
Hurry—offerends 15 SAVENOW»

— g SCRIBD Search

querz”update staff set where


% (y, si d)
cl .execute (quer)
dl . commit ( )

print ("RECORD UPDATED")


elif
y—input ("enter the name: " )
staff set name—' where
% (Y' sid)
cl .execute (quer)
dl . commit ( )

print ("RECORD UPDATED”)


elif
y—input ("enter the deparment: " )
staff set where
id-%d” % (Y' sid)
cl .execute (quer)
dl . commit ( )

if Y¯—z”cleaning” :
j-2000
elif and beverages” :
j-4000
elif :
j-6000
staff set sal—' where
id-%d” % (j, sid)
cl .execute (querl)
dl . commit ( )

print ("RECORD UPDATED”)


elif
y—input ("enter the hiredate: " )
staff set hiredate—' %s
where id-z%d” % (Y, sid)
cl .execute (quer)
dl . commit ( )

print ("RECORD UPDATED” )


elif CI.
print ("invalid input”)
def allrecords () :

import pymysql
import pandas as Pd

dl—pyrnysql .connect (host—” loca I host " ,user—” root " ,pas sw
da taba se—" hotel ” )
cl—dl . ()

quer—” select * from staff; ”


df—pd. read sql (quer,dl)
print (df)
while ans——” y'

Download
ox x
Save on Offical Exam Prep
Hurry—offerends 15 Decente SAVE NOW>

print (

print (

print •k

print ( •k

print ("1.Guest records .Staff records


\n3 .Exit" )
x—int (input ("enter the no: )
if x==l:
guest ( )

el if x==2:
staff ( )

el if x==3:
quit ( )

elif x! =
print INPUT")
ans=input ("want to continue: ")

Output Screens:
Guest Data handling
I. Show all the records:

Download
2. Add record of guest:

You might also like