DELHI PUBLIC SCHOOL, WHITEFIELD
Academic Year 2023-2024
Project Report On
Quiz Game
FOR AISSCE 2024 EXAMINATION
[AS A PART OF THE COMPUTER SCIENCE COURSE (083)]
Name Class Section Roll No
Vaibhavi Mittal 12 A
Swara Wankhede 12 A
Page 1 of 46
CERTIFICATE
This is to certify that the Project/ Dissertation
entitled Quiz Game is a Bonafede work done by
Vaibhavi Mittal and Swara Wankhede of Class XII
Session 23-24 in partial fulfilment of CBSE's
AISSCE Examination 2024 and has been carried
out under my direct supervision and guidance.
………………………… ……………………………..
Signature of Principal Signature of Teacher
………………………… ……………………………..
Signature of Examiner Signature of Student
Page 2 of 46
ACKNOWLEDGEMENT
Apart from the efforts of the members of this team,
the success of any project depends largely on the
encouragement and guidelines of many others. We
take this opportunity to express our gratitude to the
people who have been instrumental in the
successful completion of this project.
We express a deep sense of gratitude to almighty
God for giving us strength for the successful
completion of the project.
We express our heartfelt gratitude to our parents
for their constant encouragement while carrying
out this project. We gratefully acknowledge the
contribution of the individuals who contributed to
bringing this project up to this level, who continues
to look after us despite our flaws.
Our sincere thanks to Ms. Pavithra NR, a guide and
a mentor, who critically reviewed our project and
helped in
solving every problem, that occurred during the
implementation of the project.
Page 3 of 46
Table of Contents
CERTIFICATE.............................................................2
ACKNOWLEDGEMENT..............................................3
INTRODUCTION.......................................................5
OBJECTIVE AND PROJECT DEFINITION....................6
HARDWARE AND SOFTWARE REQUIREMENTS......7
MODULES.................................................................8
Tkinter..........................................................8
Pillow...........................................................8
MYSQL Connector........................................9
Code and Output......................................................9
Database Description...................................9
Project code files.........................................10
Text files for question bank..........................10
[Link]................................................11
[Link]...................................................13
[Link]................................................16
[Link]..................................................19
[Link].................................................27
[Link]................................................30
BIBLOGRAPHY...........................................................33
Page 4 of 46
INTRODUCTION
Quiz
Game:
Games are essential for development of the
students. It nurtures the competitive sprit in
students. This quiz game will enhance the
knowledge of the students on different subject.
Page 5 of 46
OBJECTIVE AND PROJECT
DEFINITION
In this project we have used many
programming features that we learned
throughout the year.
We have used File management as Question
bank for all the subjects.
We are using Database to store the user
Information to allow user to login and to save
their scores.
We have used TKinter to make the GUI of the
application.
We have used Pillow to show the image on the
screen.
We have used list extensively to load the
question bank and show random questions.
Page 6 of 46
HARDWARE AND SOFTWARE
REQUIREMENTS
1. PC with Intel core i5 with 64 GB RAM and 64
bit OS
2. MS Windows 11 OS
3. Python 5.5
4. IDLE (Python 5.5)
5. Python Libraries
a. TKinter
b. Pillow
c. MySQL Connector
6. MySQL DB
Page 7 of 46
MODULES
Tkinter
Tkinter is a useful tool for creating a wide
variety of graphical user interfaces, including
windows, dialog boxes, and custom widgets. It
is particularly well-suited for building desktop
applications and adding a GUI to command-line
programs. It is indeed one of the fastest and
easiest ways to build GUI applications.
Moreover, Tkinter is cross-platform, hence the
same code works on macOS, Windows, and
Linux.
To install Tkinter: pip install Tk
Pillow
The Pillow library in Python contains all the
basic image processing functionality. We can
rotate, resize and transform an image. In this
code, the Pillow module has been used in
defining the backgrounds that appear as the
output.
To install Pillow: pip install pillow
Page 8 of 46
MYSQL Connector
MySQL Connector/Python enables Python
programs to access MySQL databases, using an
API that is compliant with the python.
Code and Output
Database Description:
Tables:
Page 9 of 46
Project code files:
[Link]. File Name Description
1 [Link] Main window of the project gives user all the
options provided by the
application
2 [Link] This window of the application allow user to add new
user
3 [Link] This window allows user to login to play the quiz
4 [Link] This is the window to show the questions and
receive the answers
5 [Link] After the quiz it shows the score
6 [Link] To delete a user from DB only Admin can delete the
user
Text files for question bank
1. GK_ques.txt
2. GK_ans.txt
3. Comp_ques.txt
4. Comp_ans.txt
5. Math_ques.txt
6. Math_ans.txt
7. Sci_ques.txt
8. Sci_ans.txt
Image file for main window
1. [Link]
Page 10 of 33
[Link]:
from random import randint
from tkinter import messagebox
from tkinter import *
import tkinter as tk
import os
from flIL import ImageTk, Image
from LoginGame import *
from ewUser import *
from deleteUser import *
Main_window = Tk()
Main_window.title("Game")
shight =
Main_window.winfo_screenheight()
swidth =
Main_window.winfo_screenwidth()
Main_window.geometry("%dx%d" %(swidth,shight))
Adding background
bkImg =
[Link]("[Link]") img =
[Link](bkImg)
Canvas1=Canvas(Main_window)
Canvas1.create_image(300,300,image=img)
[Link] (bg="Green",width=swidth,height=shight)
[Link](expand=True,fill=BOTH)
headingFrame1 = Frame(Main_window,bg=" FFBB00",bd=5)
[Link](relx=0.2,rely=0.1,relwidth=0.6,relheight=0.16)
headingLabel = Label(headingFrame1, text=" Welcome to \nWorld of Quiz",
bg='black', fg='white',font=('Century 15 bold'))
[Link](relx=0,rely=0, relwidth=1, relheight=1)
btn1 = Button(Main_window,text="login to fllay",bg='black', fg='white',
command=login2game,font=('Century 15'))
[Link](relx=0.28,rely=0.4, relwidth=0.45,relheight=0.1)
btn2 = Button(Main_window,text=" ew User",bg='black', fg='white',
command=newu,font=('Century 15'))
[Link](relx=0.28,rely=0.5, relwidth=0.45,relheight=0.1)
btn3 = Button(Main_window,text="Delete User",bg='black', fg='white',
command=adminl,font=('Century 15'))
[Link](relx=0.28,rely=0.6, relwidth=0.45,relheight=0.1)
btn4 = Button(Main_window,text="Quit",bg='black', fg='white',
command=Main_window.destroy,font=('Century 15'))
[Link](relx=0.28,rely=0.7, relwidth=0.45,relheight=0.1)
Main_window.mainloop()
Page 11 of 46
Output:
Page 12 of 46
[Link]:
from random import
randint from tkinter
import messagebox from
tkinter import *
import tkinter
as tk import os
from flIL import ImageTk,
Image import [Link]
nu_pwd=
one nu_U
ame= one
nu_UID= one
def newu():
global Main_window, Canvas1, nu_U ame,
nu_pwd,nu_UID Main_window = Tk()
Main_window.title("QuizGame ew
User")
Main_window.minsize(width=400,heig
ht=400)
Main_window.geometry("600x500")
Canvas1 =
Canvas(Main_window)
[Link](bg="
ff6e40")
[Link](bg=" ffce30")
[Link](expand=True,fill=BOTH)
headingFrame1 = Frame(Main_window,bg=" FFBB00",bd=5)
[Link](relx=0.25,rely=0.1,relwidth=0.5,relheight=0
.13)
headingLabel = Label(headingFrame1, text="Game ew
User", bg='black', fg='white', font=('Century 15'))
[Link](relx=0,rely=0, relwidth=1, relheight=1)
labelFrame = Frame(Main_window,bg='black')
[Link](relx=0.1,rely=0.4,relwidth=0.8,relheight=0.4)
lb1 = Label(labelFrame,text="UserID : ", bg='black',
fg='white') [Link](relx=0.05,rely=0.2, relheight=0.08)
nu_UID = Entry(labelFrame)
nu_UID.place(relx=0.3,rely=0.2, relwidth=0.62, relheight=0.08)
Page 13 of 46
lb2 = Label(labelFrame,text="User ame : ", bg='black',
fg='white') [Link](relx=0.05,rely=0.35, relheight=0.08)
nu_U ame = Entry(labelFrame)
nu_U [Link](relx=0.3,rely=0.35, relwidth=0.62,
relheight=0.08)
Page 14 of 46
lb3 = Label(labelFrame,text="flassword : ", bg='black',
fg='white') [Link](relx=0.05,rely=0.5, relheight=0.08)
nu_pwd = Entry(labelFrame)
nu_pwd.place(relx=0.3,rely=0.5, relwidth=0.62, relheight=0.08)
Submit Button
SubmitBtn = Button(Main_window,text="Add User",bg=' d1ccc0',
fg='black',command=adduser)
[Link](relx=0.28,rely=0.9,
relwidth=0.18,relheight=0.08) quitBtn =
Button(Main_window,text="Quit",bg=' f7f1e3', fg='black',
command=Main_window.destroy)
[Link](relx=0.53,rely=0.9,
relwidth=0.18,relheight=0.08)
Main_window.mainloo
p() def adduser():
global nu_U ame,
nu_pwd,nu_UID,Main_window need to
connect to db
con=[Link](host="localhost",user="root",password
="Tiaa123$"
,database="quizgam
e") cur =
[Link]()
suname = nu_U
[Link]() spwd =
nu_pwd.get() suid =
nu_UID.get()
values="('"+suid+"' ,'"+suname+"' ,'"
+spwd+"')" print(values)
userTable = "gameplayer"
extractInfo="select * from {} where
id='{}'".format(userTable,suid) print (extractInfo)
try:
[Link](extractInfo
) data =[Link]()
Count=[Link]
print (data)
print("rowCount=",Co
unt) if Count>0:
[Link]("Error","User already exist!")
Main_window.destroy()
Page 15 of 46
else:
extractInfo1="insert into {} value
{}".format(userTable,values)
[Link](extractInfo1)
[Link]()
[Link]("Success", "User Added
successfully") Main_window.destroy()
Page 16 of 46
except:
[Link]("Error", "Can't get the gameplayer
data") Main_window.destroy()
Output:
Page 17 of 46
[Link]:
from random import
randint from tkinter
import messagebox from
tkinter import *
import tkinter
as tk import os
from flIL import ImageTk,
Image import [Link]
from Quizgame import *
txpwd=
one U
ame= one
def login2game():
global Main_window,
Canvas1,txpwd,U ame Main_window
= Tk()
Main_window.title("QuizGame
login")
Main_window.minsize(width=400,heig
ht=400)
Main_window.geometry("600x500")
Add your own database name and password here to reflect in
the code
con=[Link](host="localhost",user="root",passwor
d="Abc",dat abase="db")
cur = [Link]()
Enter Table ames
here
Canvas1 =
Canvas(Main_window)
[Link](bg="
ff6e40")
[Link](bg=" 800080")
[Link](expand=True,fill=BOTH)
headingFrame1 = Frame(Main_window,bg=" FFBB00",bd=5)
[Link](relx=0.25,rely=0.1,relwidth=0.5,relheight=0
.13)
headingLabel = Label(headingFrame1, text="Game Login",
Page 18 of 46
bg='black', fg='white', font=('Century 15'))
[Link](relx=0,rely=0, relwidth=1, relheight=1)
labelFrame = Frame(Main_window,bg='black')
[Link](relx=0.1,rely=0.4,relwidth=0.8,relheight=0.4)
lb1 = Label(labelFrame,text="Username : ", bg='black',
fg='white') [Link](relx=0.05,rely=0.2, relheight=0.08)
U ame = Entry(labelFrame)
Page 19 of 46
U [Link](relx=0.3,rely=0.2, relwidth=0.62, relheight=0.08)
lb2 = Label(labelFrame,text="flassword : ", bg='black',
fg='white') [Link](relx=0.05,rely=0.35, relheight=0.08)
txpwd = Entry(labelFrame)
[Link](relx=0.3,rely=0.35, relwidth=0.62, relheight=0.08)
Submit Button
SubmitBtn = Button(Main_window,text="SUBMIT",bg=' d1ccc0',
fg='black',command=glogin)
[Link](relx=0.28,rely=0.9,
relwidth=0.18,relheight=0.08) quitBtn =
Button(Main_window,text="Quit",bg=' f7f1e3', fg='black',
command=Main_window.destroy)
[Link](relx=0.53,rely=0.9,
relwidth=0.18,relheight=0.08)
Main_window.mainloop()
def glogin():
global U
ame,txpwd,Canvas1,userTable,Main_window
con,cur, suname = U [Link]()
spwd = [Link]()
print ("workin progress for login uid=" ,suname
,"pwd=",spwd) need to check DB if the username and
flWD is correct.
con=[Link](host="localhost",user="root",password
="Tiaa123$"
,database="quizgam
e") cur =
[Link]()
userTable = "gameplayer"
extractInfo="select * from {} where
id='{}'".format(userTable,suname) try:
[Link](extractI
nfo) data
=[Link]() print
(data)
if data[0]
[0]==suname: if
data[0]
[2]==spwd:
Page 110 of
46
Main_window.destroy()
play(suname)
else:
[Link]("Error", "Username or password
valid not
")
Main_window.destroy()
else:
[Link]("Error", "Username or password
not valid") Main_window.destroy()
Page 111 of
46
except:
[Link]("Error", "Can't get the gameplayer
data") Main_window.destroy()
Output
Page 112 of
46
[Link]:
from random import
randint from tkinter
import messagebox from
tkinter import *
import tkinter
as tk import os
from flIL import ImageTk,
Image import [Link]
from ShowScore
import *
questionsGK=[]
AnswersGK=[]
questionsMath=[]
AnswersMath=[]
questionsSic=[]
AnswersSic=[]
questionsComp=[]
AnswersComp=[]
qList=[]
ansList=[]
qvar1= one
question="
" first=0
count=0
score=0
Skipcount=
0 ans=""
my_label=
one
qlableText=
one qlb1= one
headingFrame1=
one
headingLabel=
one
qlabelFrame=
one uname=""
subject=""
creating the tkinter window
def importans(file,alist):
file_name =
Page 113 of
46
[Link]([Link](), file) print
(file_name)
file_ans = open(file_name,
'r') count = 0
linetype
=0 line
="a"
Page 114 of
46
while True:
count += 1
Get next line from
file line =
[Link]()
if line is empty
end of file is
reached line =
file_ans.readline() if
not line:
break
print(line);
alist=[Link]("
,") print(alist)
question_list.append(li
ne) file_ans.close()
print(count)
return alist
def
importquiz(file,question_l
ist): """
read the quiz file and import it
in list. """
file = [Link]()+file
file = [Link]([Link](),
file) file_name =
[Link]([Link](), file) print
(file_name)
file1 = open(file_name,
'r') count = 0
linetype
=0 line
="a"
while True:
count += 1
Get next line from
file line =
[Link]()
if line is empty
end of file is
reached line =
[Link]() if
not line:
break
question_list.append(li
Page 20 of 33
ne)
print("Line{}: {}".format(count,
[Link]())) [Link]()
print(count)
return question_list
def showQuestion():
global ans, qList,
ansList,count,qlableText,ansList,qlb1,uname
Page 20 of 33
print ("in
showQuestion") if
(count==5):
show result
text1="you score "+str(score)+ " outof
5" [Link]( "Result",
text1) addscoretoDB()
exit(0)
else:
print("inside else
count=",count)
qno=randint(0,9-count)
print("inside else qno=",qno)
count=count+1
q=[Link](qno
)
tokens=[Link]("
|")
qu=tokens[0]+"\n"+tokens[1]+"\n"+tokens[2]+"\n"+tokens[3]+"\
n"+tokens[4] [Link](qu)
print(ansList)
ans=[Link](
qno)
def addscoretoDB():
global uname,subject,score
print ("user=",uname,"sub=" ,subject,"score=",score)
con=[Link](host="localhost",user="root",password
="Tiaa123$"
,database="quizgam
e") cur =
[Link]()
userTable =
"scores"
values="('"+uname+"',"+score+",'"+subje
ct+"')" extractInfo1="insert into {} value
('{}',{},'{}')".format(userTable,uname,score,subject)
[Link](extractInfo1)
[Link]()
ShowScoreScreen(uname,sub
ject)
def verifyAns():
Page 21 of 46
global ans,score,qvar1
[Link]("verifyAns",str([Link]()))
if
(ans==str([Link](
))): score=score+1
print("inside verifyAns
ans=",ans,"Uans=",str([Link]()),"score=",score)
def submitCallBack():
Page 22 of 46
global
subject,first,qvar1,qList,questionsGK,questionsMath,questionsSic,
questionsCo
mp,AnswersGK,AnswersMath,AnswersSic,AnswersComp,ansList
print("[Link]()=",[Link]())
if(first==0):
[Link]( "submit",
str([Link]())) first=1
if(str([Link]())=="
1"): print("GK")
subject="GK"
importquiz('Questions\GK_ques.txt',questionsGK)
AnswersGK=importans('Questions\GK_ans.txt',AnswersGK)
print(AnswersGK)
qList=questionsGK
ansList=AnswersGK
elif(str([Link]())=
="2"):
print("math")
subject="Math"
importquiz('Questions\Math_ques.txt',questionsMath)
AnswersMath=importans('Questions\
Math_ans.txt',AnswersMath) qList=questionsMath
ansList=AnswersMa
th
elif(str([Link]())=
="3"):
print("science")
subject="Science"
importquiz('Questions\Sci_ques.txt',questionsSic)
AnswersSic=importans('Questions\
Sci_ans.txt',AnswersSic) qList=questionsSic
ansList=AnswersSi
c
elif(str([Link]())=
="4"):
print("Comp
science")
subject="Comput
er"
importquiz('Questions\Comp_ques.txt',questionsComp)
AnswersComp=importans('Questions\
Comp_ans.txt',AnswersComp) qList=questionsComp
ansList=AnswersComp
showQuestion()
else:
Page 23 of 46
addscoretoDB()
qMain_window.destroy()
def nextCallBack():
global first, qList, ansList,var,qlableText
verifyAns()
showQuestion()
Page 24 of 46
def skipCallBack():
global
Skipcount
if(Skipcount==1)
:
[Link] ("Skip","You already skiped 1
question, \ncannot skip this one")
else:
Skipcount=Skipcount+1
showQuestion()
def sel():
[Link]("sel",va
[Link]()) a=2
def play(user):
global qMain_window, qvar1,qlableText,qlb1,qlabelFrame,uname
qMain_window = Tk()
qMain_window.title("Quiz Game")
qMain_window.minsize(width=400,heigh
t=400)
qMain_window.geometry("600x500")
uname=user
qCanvas1 = Canvas(qMain_window)
[Link](bg=" B22222")
[Link](expand=True,fill=BOT
H)
headingFrame1 = Frame(qMain_window,bg=" FFBB00",bd=5)
[Link](relx=0.25,rely=0.1,relwidth=0.5,relheight=0.13
) wel="Welcome "+uname
headingLabel = Label(headingFrame1, text=wel, bg='black',
fg='white', font=('Century 15'))
[Link](relx=0,rely=0, relwidth=1, relheight=1)
qlabelFrame = Frame(qMain_window,bg='black')
[Link](relx=0.1,rely=0.3,relwidth=0.8,relheight=0.6)
qlableText=[Link]()
qlb1 = Label(qlabelFrame, textvariable=qlableText,
bg='black', fg='white',font=('Century
12'),justify=LEFT,wraplength=450)
[Link]("Select The Quiz subject from below options\n\
nA) GK\nB) Math\nC) Science\nD) flython ")
Page 25 of 46
[Link](relx=0.05,rely=0.02, relwidth=0.9,relheight=0.5)
qvar1 = IntVar()
R1 = Radiobutton(qlabelFrame, text="A", variable=qvar1,
value=1,
fg='black',bg='white',command=sel).place(relx=.1,rely=.55)
Page 26 of 46
R2 = Radiobutton(qlabelFrame, text="B", variable=qvar1,
value=2,
fg='black',bg='white',command=sel).place(relx=.5,rely=.55)
R3 = Radiobutton(qlabelFrame, text="C", variable=qvar1,
value=3,
fg='black',bg='white',command=sel).place(relx=.1,rely=.7)
R4 = Radiobutton(qlabelFrame, text="D", variable=qvar1,
value=4,
fg='black',bg='white',command=sel).place(relx=.5,rely=.7)
Submit Button
nxtBtn = Button(qMain_window,text=" ext",bg=' d1ccc0',
fg='black',command=nextCallBack)
[Link](relx=0.2,rely=0.9,
relwidth=0.18,relheight=0.08) SubmitBtn =
Button(qMain_window,text="SUBMIT",bg=' d1ccc0',
fg='black',command=submitCallBack)
[Link](relx=0.4,rely=0.9,
relwidth=0.18,relheight=0.08)
quitBtn = Button(qMain_window,text="Quit",bg=' f7f1e3',
fg='black', command=qMain_window.destroy)
[Link](relx=0.6,rely=0.9,
relwidth=0.18,relheight=0.08)
qMain_window.mainloop()
Page 27 of 46
Output:
Page 28 of 46
Page 29 of 46
[Link]:
from random import
randint from tkinter
import messagebox from
tkinter import *
import tkinter
as tk import os
from flIL import ImageTk,
Image import [Link]
from Quizgame import *
uname=''
subject=''
def ShowScoreScreen(user,sub):
global Main_window,
Canvas1,uname,subject
Main_window = Tk()
Main_window.title("QuizGame
Score")
Main_window.minsize(width=400,heig
ht=400)
Main_window.geometry("600x500")
uname=user
subject=sub
Canvas1 =
Canvas(Main_window)
[Link](bg="
ff6e40")
[Link](bg=" FFFACD")
[Link](expand=True,fill=BOTH)
headingFrame1 = Frame(Main_window,bg=" FFBB00",bd=5)
[Link](relx=0.25,rely=0.1,relwidth=0.5,relheight=0
.13)
headingLabel = Label(headingFrame1,
text="Score", bg='black', fg='white', font=('Century
15'))
[Link](relx=0,rely=0, relwidth=1, relheight=1)
labelFrame=Frame( Main_window,bg='black')
[Link](relx=0.1,rely=0.3,relwidth=0.8,
relheight=0.5)
Label(labelFrame,text="%-20s%-10s%- 20s"%
('ID','Score','Subject'),bg='black',fg='white').place(relx=0.07,
Page 210 of
46
rely=0. 1)
Label(labelFrame,text="
-",bg='black',fg='white').place(relx=0.07,rely=0.2)
con=[Link](host="localhost",user="root",password
="Tiaa123$"
,database="quizgam
e") cur =
[Link]()
userTable =
"scores"
Page 211 of
46
extractInfo="select * from {} where ID='{}' and
subject='{}'".format(userTable,uname,subject)
print
(extractInfo)
y=0.3
try:
[Link](extractInfo
) data =[Link]()
messagebox
("Score",data)
print(data)
for i in data:
Label(labelFrame,text="%-20s%-10s%- 20s"%
(i[0],i[1],i[2]),bg='black',fg='white').place(relx=0.07,rely=y)
y=y+0.1
except:
[Link]("Error", "Can't get the
gameplayer data") exitBT =
Button(Main_window,text="Exit",bg=' f7f1e3', fg='black',
command=Main_window.destroy)
exitBT .place(relx=0.4,rely=0.9,relwidth=0.18,relheight=0.18)
Main_window.mainloop()
Page 212 of
46
Output:
Page 213 of
46
[Link]:
from random import
randint from tkinter
import messagebox from
tkinter import *
import tkinter
as tk import os
from flIL import ImageTk,
Image import [Link]
from Quizgame import *
tpwd= one
dUser =
one
def adminl():
global Main_window,
Canvas1,tpwd,dUser Main_window
= Tk() Main_window.title("Delete
User")
Main_window.minsize(width=400,heig
ht=400)
Main_window.geometry("600x500")
Canvas1 =
Canvas(Main_window)
[Link](bg="
ff6e40")
[Link](bg=" 288BA8")
[Link](expand=True,fill=BOTH)
headingFrame1 = Frame(Main_window,bg=" FFBB00",bd=5)
[Link](relx=0.25,rely=0.1,relwidth=0.5,relheight=0
.13)
headingLabel = Label(headingFrame1, text="Delete User",
bg='black', fg='white', font=('Century 15'))
[Link](relx=0,rely=0, relwidth=1, relheight=1)
labelFrame = Frame(Main_window,bg='black')
[Link](relx=0.1,rely=0.4,relwidth=0.8,relheight=0.4)
lb1 = Label(labelFrame,text="Username : ", bg='black',
fg='white') [Link](relx=0.05,rely=0.2, relheight=0.08)
Page 30 of 33
lb2 = Label(labelFrame,text="admin", bg='black',
fg='white') [Link](relx=0.3,rely=0.2, relwidth=0.62,
relheight=0.08)
lb1 = Label(labelFrame,text="Admin flassword : ", bg='black',
fg='white') [Link](relx=0.05,rely=0.2, relheight=0.08)
tpwd = Entry(labelFrame)
[Link](relx=0.3,rely=0.2, relwidth=0.62, relheight=0.08)
Page 30 of 33
lb2 = Label(labelFrame,text="Delete User : ", bg='black',
fg='white') [Link](relx=0.05,rely=0.35, relheight=0.08)
dUser = Entry(labelFrame)
[Link](relx=0.3,rely=0.35, relwidth=0.62, relheight=0.08)
Submit Button
SubmitBtn = Button(Main_window,text="SUBMIT",bg=' d1ccc0',
fg='black',command=alogin)
[Link](relx=0.28,rely=0.9,
relwidth=0.18,relheight=0.08) quitBtn =
Button(Main_window,text="Quit",bg=' f7f1e3', fg='black',
command=Main_window.destroy)
[Link](relx=0.53,rely=0.9,
relwidth=0.18,relheight=0.08)
Main_window.mainloop()
def deleteUser(delU):
con=[Link](host="localhost",user="root",password
="Tiaa123$"
,database="quizgam
e") cur =
[Link]()
userTable =
"scores"
extractInfo="delete from {} where
id='{}'".format(userTable,delU) extractInfo1="delete from
{} where id='{}'".format ("gameplayer",delU)
print(extractInf
o) try:
[Link](extractInf
o)
[Link](extractInfo
1) [Link]();
[Link]("Success", "User Delete
Successfully") except:
[Link]("Error", "Can't get the data from
DB") Main_window.destroy()
def alogin():
global U
Page 31 of 46
ame,tpwd,Canvas1,userTable,Main_window,dUser
con,cur, suname = "admin"
spwd =
[Link]() delU
= [Link]() if
(delU=='admin')
:
[Link]("Error", "admin Usercannot be
deleted") Main_window.destroy()
else:
Page 32 of 46
print ("workin progress for login
uid=" ,suname ,"pwd=",spwd) need to check DB if the
username and flWD is correct.
con=[Link](host="localhost",user="root",passwor
d="Tiaa123$"
,database="quizgame")
cur = [Link]()
userTable =
"gameplayer"
extractInfo="select * from {} where
id='{}'".format(userTable,suname)
print(extractInfo
) try:
[Link](extractI
nfo) data
=[Link]()
print (data)
if data[0]
[0]==suname: if
data[0]
[2]==spwd:
deleteUser(delU)
Main_window.destroy()
play()
else:
[Link]("Error", "You should be
admin to
delete user")
Main_window.destroy()
else:
[Link]("Error", "You should be admin
Page 33 of 46
Output:
BIBLOGRAPHY
1. [Link]
2. [Link]
3. [Link]
4. [Link]
5. Computer Science with Python (Textbook for Class XII) –
Sumita Arora
Page 34 of 46