You are on page 1of 16

XYZ Public School

Kalyanpur

Session 2022-2023
Computer Science Project File
Submitted To: Submitted By:
PROJECT BASE ON
nline
iz ame
Index
S No. Content Page No.
1) Certificate 4
2) Acknowledgement 5
3) Introduction 6
4) Source Code 7
5) Output Window 11
6) Bibliography 15
CERTIFICATE
This is to certify that <Your name here> of class XII
(STREAM) of <SchooI name> has done his/her project on
<Project name > under my supervision. He / She has
taken interest and has shown at most sincerity in
completion of this project. I certify this Project up to my
expectation & as per guidelines issued by CBSE, NEW
DELHI.

Internal Examiner

External Examiner
Acknowled
It is with pleasure that I acknowledge my sincere
gratitude to our teacher, < Teacher name > who taught
and undertook the responsibility of teaching the subject
computer science. I have been greatly benefited from
his/her classes.
My sincere thanks goes to our Principal <PrincipaI
name> who has always been a source of encouragement
and support and without whose inspiration, this project
would not have been a successful.
Finally, I would like to express my sincere appreciation
for all the other students for my batch their friendship &
the fine times that we all shared together.
Last but not least, I would like to thank all those who had
helped directly or indirectly towards the completion of
this project.
Name of student
Class
Introduction
Online Quiz game in python is a simple console
application built without the use of graphics. This project
helps in creating a online quiz game concept. In this
project we tried make sign up system for user, than after
doing proper login user can play MCQ game.
Some of the features of the program are:
1) User can Create new account to play game.
2) User can login again and again to play game.
3) After completion of game user score is automatically
stores in database.
4) We can check scores of all the users.
5) User can navigate in game with main menu.
Source Code
import mysql.connector
mydb=mysql.connecto ost="localhost",us
er="root",

passwor '123456" abase= c")

de
mycursor=mydb.cursor()
nm=input(”En user name:")
Pass
em=inp

er(user
lues('{}

"Id Created")
lse:
Password does not match")

def
mycursor=myd
nm=input("Enter user name:")
pas=input("Enter Password:")
mycursor.execute("select * from user where
username='{}' and password='{}'".format(nm,pas))
myrecords=mycursor.fetchone()
global user
user=myrecords[1]
print(“Welcome to game: ",myrecords[1])
start=input("Press 'Y' to start game and any
other key to log out:”)
if start==“Y“:
print("Let's Start")
game()
else:
print(“Thanks for visiting us, You are
log out")

def score():
mycursor=mydb.cursor()

mycursor.execute(”Select * from user")


myrecords=mycursor.fetchall()
print("Name \t Score”)
for i in myrecords:
print(i[1], '\t',i[3])
print("Total number of rows
retrieved“,mycursor.rowcount)
main()

def game():

mycursor=mydb.cursor()
mycursor.execute(“Select * from mcq")
score=0
i=1
while i<=5:

myrecords=mycursor.fetchone()

print("Question“,myrecords[0],":",myrecords[1])
print("Options")
print(myrecords[2])
print(myrecords[3])
print(myrecords[4])
print(myrecords[5])
ans=input(”Enter correct option:")
if ans== myrecords[6] :
print(”Correct Answer“)
score=score+10
print(”Points:",score)
else:
print("Wrong Answer“)
print(”Points:”,score)
i=i+1
mycursor.execute("update user set score={}
where username='{}'“.format(score,user))
mydb.commit()

if score==50:
print(“You win”)

else:
a=input("Press Y to play again or N to
main menu:“)
if a=="Y":
game()
else:
main()

def main():
print("\nWelcome to Online Quiz Game")
print("1.New Account \n2.Log in\n3.Check
your Score”)
ch=int(input("Enter your Choice:"))
if ch==1:
signup()
elif ch==2:
login()
elif ch==3:
score()
else:
print("Enter correct choice")
main()
main()
Output
Main menu:

Welcome to Ontine Quiz Game


Nex Ac count
Log in
Check your Score
Enter your Choice:

Press 1 to create new user account:


Welcome to Online Quiz Game
1.New Account
2. Log in
3. Check your Score
iEnter your Choice:1
Enter user name:rohan
Enter Password: rohanl23
Confirm Password:ro hanl23
1 Id Created
Press 2 for User Login and play game:
Welcome to Online Quiz Game
1.New Account
2. Log in
3. Check your Score
Enter your Choice:2
Enter user name:rohan
Enter Pass Word:rohanl23
Welcome to game: rohan
Press 'Y' to start game and any other key to log out:

Press ‘Y’ to Start Game after login:


(If answer is correct, Score increases by 10 points per
correct question. )
Press 'Y' to start game and any other key to log out:Y
, Let s Sta at
Question 1 : Which keyword is used to define a function in python?
'Opt 1on s
a . del
b . def1ne
c . new
d . None of the above
E nten cornecI opt1on : a
Connect Answe r
Points: 10

(If answer goes wrong, Score remains same. )


uestion 2 : Nhich of the following functions is not performed using a mouse?
pt1on s
a . Tu nn on
b . Hove
c . R1ght - c Mick
d . Drag and Drop
Enter con secI opt1on : b
song Answe n
Po1nts : 10
(After last question user can watch final score. And can
press ‘Y’ to play again.)
Question 5 : What keys do you use to copy something?
Options
a. CTRL+C
b. CTRL+P
c. CTRL+V
d. CTRL+X
Enter correct option:a
Correct Answer
Points: 40
Press Y to play again or N to main menu:

(If user score 50 “You won” message start flashing. And


game redirect to main menu)
Question 5 : What keys do you use to copy
Options
CTRL+C
CTRL+P
CTRL+V
CTRL+X
Enter correct option:a
Correct Answer
Points: 50
You win

Welcome to Online Quiz Game


1.New Account
Log in
Check your Score
Enter your Choice:
Press 3 for getting list of all user and can watch scores of
all user:
Welcome to Online Quiz Game
1. Net‹ Ac count
2. Log in
3. Check your Score
Ente r your Choice : 3
Name Score
Rahul 40
nanoj 30
rohan 50
Total number of rows retrieved 3

Tables in database
Book Name
Preeti Arora

Website
YO

You might also like