ARMY PUBLIC SCHOOL FEROZEPUR
CANTT
A Project Report on the topic
“quiz”
is hereby submitted to
Central Board of Secondary Education
for the partial fulfillment for the award of certificate of
AISSCE (2025-26)
Supervised by: Submitted by:
Mr. Sanjeev Jain Name: Ayush Kumar
PGT Computer Science Roll No.:
1|Page
TABLE OF CONTENT
1. ACKNOWLEDGEMENT
2. CERTIFICATE
3. ABOUT PROJECT
4. DATABASE AND TABLES USED
5. LIBRARY FUNCTIONS USED
6. USER DEFINED FUNCTIONS USED
7. SCREEN SHOTS
8. CODING
9. BIBLiOGRAPHY
2|Page
ACKNOWLEDGEMENT
Making a project is a bear of understanding not only for the developer but for those
around him. Our words cannot do justice to the effect of these people have had on
us, either through technical assistance or moral support. Still, words are all we have
Great acknowledgement is extended to all the people who made this project
possible with their enthusiastic support and encouragement.
First of all we extend out heartiest thanks to our project guide and teacher
Mr. Sanjeev Jain, PGT Computer Science, Army Public School, Ferozepur Cantt for
giving his precious support and timely guidance to compile and successfully
accomplish this project to our best efforts.
We would like to thank our friends for their suggestions, which helped us to make
this project much better than what we could have done alone. And finally thanks to
our parents for their time immemorial support and everlasting encouragement to
make things better and simpler for out better future.
3|Page
CERTIFICATE
This is to certify that the project work entitled “QUIZ ”, which is being submitted by
us in partial fulfillment of the requirement for award of the certificate of AISSCE is
an authentic work carried out by us under the supervision and timely guidance of
Mr. Sanjeev Jain , PGT Computer Science, Army Public School, Ferozepur Cantt..
(Signature) (Signature)
Name: Akshat Wadhawan Name :Ayush Kumar
Roll No: Rollno:
(Signature)
Mr. Sanjeev Jain
PGT Computer Science
Army Public School, Ferozepur Cantt.
4|Page
QUIZ PROJECT
This project gives following facilities :
1. Play Quiz
2. Add a question
3. Modify a Question
4. Delete a question
5. Show All questions
6. Add player record
7. Show Score of all players
FRONT END: PYTHON
BACK END: MYSQL
5|Page
DATABASE NAME: QUIZ
TABLE USED: QUESBANK
COLUMN NAME DATA TYPE & SIZE
QID INT(11)
QUES VARCHAR(1200)
OPT1 VARCHAR(40)
OPT2 VARCHAR(40)
OPT3 VARCHAR(40)
OPT4 VARCHAR(40)
ANS CHAR(1)
TABLE USED: USER
COLUMN NAME DATA TYPE & SIZE
UID Int(11)
UNAME VARHCHAR(40)
USCORE INT(11)
6|Page
NAME OF MODULE / LIBRARY IMPORTED :
[Link]
NAME OF LIBRARY FUNCTIONS USED WITH THEIR PURPOSE:
Function Purpose
connect() Establish a connection of python with mysql
and return a connection object
cursor() creating cursor object in memory for working
on database using connection object
execute() Executing query using execute() function and
return resultset using cursor object
fetchall() Fetching data from resultset created by
executing query from cursor. It will create list
of tuples where each tuple contain record/row
from table. Fetchall() will fetch all tuples from
result set using cursor object.
close() Close the connection.
commit() Saves all changes on databases permanently.
NAME OF USER DEFINED FUNCTIONS USED WITH THEIR PURPOSE:
7|Page
Function Purpose
mainmenu() To display menu options and call other
functions based on choice of user.
welcome() To show welcome screen
adduser() To add a player / user details
addquestion() To add a question in question bank for quiz
deletequestion() To delete a question from question bank
modifyquestion() To modify a question in question bank
showallquestion() To show all questions along with answer on
screen
showalluser() To show all users on screen with their score
playquiz() To play quiz
8|Page
SCREEN
SHOTS
9|Page
SCREEN SHOTS
10 | P a g e
11 | P a g e
12 | P a g e
13 | P a g e
CODING
14 | P a g e
import [Link]
#==============FUNCTION TO ADD A USER=================
def adduser():
con=[Link](host="localhost", user="root", passwd="root", database="quiz")
if con.is_connected==False:
print('error in connecting MySql')
return
cur=[Link]()
[Link]("select * from user")
data=[Link]()
tuid=[Link]+1
print("User Id :",tuid)
tuname=input("enter user name :")
query="insert into user (uid,uname,uscore) values ({},'{}',{})".format(tuid,tuname,0)
[Link](query)
[Link]()
[Link]()
15 | P a g e
#=============FUNCTION TO ADD A QUESTION===============
def addquestion():
con=[Link](host="localhost", user="root", passwd="root",
database="quiz")
if con.is_connected==False:
print('error in connecting MySql')
return
cur=[Link]()
trepeat=True
while trepeat:
[Link]("select * from quesbank")
tdata=[Link]()
tqid=[Link]+1
print("Question Id :",tqid)
tques=input("enter Question :")
topt1=input("enter Option-A:")
topt2=input("enter Option-B :")
topt3=input("enter Option-C :")
topt4=input("enter Option-D :")
validoption=False
while not validoption:
tans=input("enter correct option a-d:")
tans=[Link]()
if len(tans)>1 or tans<'a' or tans>'d':
print("!!!Wrong option !!! enter valid option a-d")
else:
16 | P a g e
validoption=True
query="insert into quesbank (qid,ques,opt1,opt2,opt3,opt4,ans) values
({},'{}','{}','{}','{}','{}','{}')".format(tqid,tques,topt1,topt2,topt3,topt4,tans)
[Link](query)
[Link]()
print('!!! Question Added !!!')
tagain=input('Add more question y/n ?')
if tagain!='y' and tagain!='Y':
trepeat=False
[Link]()
17 | P a g e
#===========FUNCTION TO MODIFY QUESTION=============
def modifyquestion():
con=[Link](host="localhost", user="root", passwd="root",
database="quiz")
if con.is_connected==False:
print('error in connecting MySql')
return
cur=[Link]()
trepeat=True
while trepeat:
tqid=int(input("Enter question id to modify "))
[Link]("select * from quesbank where qid={}".format(tqid))
tdata=[Link]()
if [Link]<1:
print('Wrong Question id ')
input("press enter to go back")
[Link]()
return
print("Ques-",tdata[0][0],":",tdata[0][1])
print("a.",tdata[0][2],'\t\t',"b.",tdata[0][3])
print("c.",tdata[0][4],'\t\t',"d.",tdata[0][5])
print("Asnwer:",tdata[0][6].upper())
tmodi=input("Do you want to modify this question y/n ?")
if [Link]()=='y' :
print("Question Id :",tqid)
tques=input("enter Question :")
18 | P a g e
topt1=input("enter Option-A:")
topt2=input("enter Option-B :")
topt3=input("enter Option-C :")
topt4=input("enter Option-D :")
validoption=False
while not validoption:
tans=input("enter correct option a-d:")
tans=[Link]()
if len(tans)>1 or tans<'a' or tans>'d':
print("!!!Wrong option !!! enter valid option a-d")
else:
validoption=True
query="update quesbank set ques='{}',opt1='{}',opt2='{}',opt3='{}',opt4='{}',ans='{}'
where qid='{}'".format(tques,topt1,topt2,topt3,topt4,tans,tqid)
[Link](query)
[Link]()
print('!!! Question modified !!!')
tagain=input('Modify more question y/n ?')
if tagain!='y' and tagain!='Y':
trepeat=False
[Link]()
19 | P a g e
#===========FUNCTION TO DELETE QUESTION=============
def deletequestion():
con=[Link](host="localhost", user="root", passwd="root",
database="quiz")
if con.is_connected==False:
print('error in connecting MySql')
return
cur=[Link]()
trepeat=True
while trepeat:
tqid=int(input("Enter question id to delete "))
[Link]("select * from quesbank where qid={}".format(tqid))
tdata=[Link]()
if [Link]<1:
print('Wrong Question id ')
input("press enter to go back")
[Link]()
return
print("Ques-",tdata[0][0],":",tdata[0][1])
print("a.",tdata[0][2],'\t\t',"b.",tdata[0][3])
print("c.",tdata[0][4],'\t\t',"d.",tdata[0][5])
print("Asnwer:",tdata[0][6].upper())
tmodi=input("Do you want to delete this question y/n ?")
if [Link]()=='y' :
query="delete from quesbank where qid={}".format(tqid)
[Link](query)
20 | P a g e
[Link]()
print('!!! Question deleted !!!')
tagain=input('Delete more question y/n ?')
if tagain!='y' and tagain!='Y':
trepeat=False
[Link]()
21 | P a g e
#==========FUNCTION TO DISPLAY ALL QUESTION===========
def showallquestion():
con=[Link](host="localhost", user="root", passwd="root",
database="quiz")
if con.is_connected==False:
print('error in connecting MySql')
return
cur=[Link]()
[Link]("Select * from quesbank")
tques=[Link]()
for i in tques:
print("Ques-",i[0],":",i[1])
print("a.",i[2],'\t\t',"b.",i[3])
print("c.",i[4],'\t\t',"d.",i[5])
print("Answer.",i[6])
print('-'*60)
[Link]()
22 | P a g e
#=======FUNCTION TO DISPLAY ALL PLAYER DETAILS =======
def showallusers():
con=[Link](host="localhost", user="root", passwd="root",
database="quiz")
if con.is_connected==False:
print('error in connecting MySql')
return
cur=[Link]()
[Link]("Select * from user")
tuser=[Link]()
print("UID\tNAME\t\t\t\tSCORE")
print('='*60)
for i in tuser:
print(i[0],"\t",i[1],(30-len(i[1]))*" ",i[2])
[Link]()
23 | P a g e
#===========FUNCTION TO PLAY QUIZ=============
def playquiz():
con=[Link](host="localhost", user="root", passwd="root",
database="quiz")
if con.is_connected==False:
print('error in connecting MySql')
return
cur=[Link]()
[Link]("select * from user")
tuser=[Link]()
tuid=[Link]+1
print("User Id :",tuid)
tuname=input("enter user name :")
[Link]("Select * from quesbank")
tscore=0
tques=[Link]()
for i in tques:
print("Ques-",i[0],":",i[1])
print("a.",i[2],'\t\t',"b.",i[3])
print("c.",i[4],'\t\t',"d.",i[5])
validans=False
while not validans:
tans=input("Your answer (a-d)?:")
tans=[Link]()
if tans<'a' or tans>'d':
24 | P a g e
print("Invalid Option !! enter only a-d ")
else:
validans=True
if tans==i[6]:
print("!!!Correct Answer !!!")
tscore=tscore+10
else:
print("!!Ooops WRONG ANSWER !! Correct option is :",i[6].upper() )
print()
print()
print(tuname," your score is ",tscore)
query="insert into user (uid,uname,uscore) values ({},'{}',
{})".format(tuid,tuname,tscore)
[Link](query)
[Link]()
[Link]()
25 | P a g e
#=======FUNCTION TO DISPLAY WELCOME SCREEN=========
def welcome():
print("="*120)
print("\t\t\t\t WELCOME TO QUIZ PROJECT")
print("\t\t\t\t\t Designed By:")
print("\t\t\t\t Akshat Wadhawan & Ayush Kumar")
print("\t\t\t\t\tclass XII Non-Medical")
print("\t\t\t\tARMY PUBLIC SCHOOL FEROZEPUR CANTT")
print("="*120)
input('\n\n\n\n\npress enter to continue...')
26 | P a g e
#===========FUNCTION TO DISPLAY MENU =============
def mainmenu():
welcome()
repeat=True
while repeat:
print("\t\t***MAIN MENU***")
print("\n\t\t 1. PLAY QUIZ")
print("\t\t 2. Add Question ")
print("\t\t 3. Modify Question ")
print("\t\t 4. Delete Question ")
print("\t\t 5. Show all Question ")
print("\t\t 6. Show Details of Players ")
print("\t\t 7. Exit ")
choice=int(input('Enter your choice 1-7 '))
if choice==1 :
playquiz()
elif choice==2 :
addquestion()
elif choice==3 :
modifyquestion()
elif choice==4 :
deletequestion()
elif choice==5 :
showallquestion()
elif choice==6 :
showallusers()
27 | P a g e
elif choice==7 :
repeat=False
print("\n\n\nGOOD BYE....")
else:
print("Wrong Choice ")
#calling mainmenu
mainmenu()
28 | P a g e
Bibliography
[Link] Science by Dhanpat Rai & Co.
[Link] Science by Sultan Chand & Co.
[Link] Documentation
29 | P a g e