0% found this document useful (0 votes)
32 views

Project File

1) The document describes an online quiz game project built in Python without graphics. It allows users to create accounts, log in, play an MCQ game, and view scores. 2) The source code shows functions for signup, login, the game with scoring, and viewing scores. It uses MySQL to store user data and scores. 3) The output shows the main menu, account creation, login, playing the game with scoring, and viewing all user scores. It provides an interactive experience for users.

Uploaded by

Tarushi Garg
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Project File

1) The document describes an online quiz game project built in Python without graphics. It allows users to create accounts, log in, play an MCQ game, and view scores. 2) The source code shows functions for signup, login, the game with scoring, and viewing scores. It uses MySQL to store user data and scores. 3) The output shows the main menu, account creation, login, playing the game with scoring, and viewing all user scores. It provides an interactive experience for users.

Uploaded by

Tarushi Garg
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

2021-2022

Submitted to : Submitted by:


Govind sir Sanyog kumar
Class -12
PROJECT BASED
ON

Online
Quiz Game
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 sanyog kumar of


class XII (SCIENCE) of Gardenia Public
School has done his project on online quiz
game under my supervision. He 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.
InternalExaminer External Examiner
Acknowledgement
It is with pleasure that I acknowledge my sincere
gratitude to our teacher, govind sir who taught and
undertook the responsibility of teaching the subject
computer science. I have been greatly benefited from his
classes.
My sincere thanks goes to our Principal jaydeep
dixit 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-sanyog kumar


Class-12
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.connector.connect(h
ost="localhost",user="root",

password="123456",database="kbc")

def signup():
mycursor=mydb.cursor()
nm=input("Enter user name:")
pas=input("Enter Password:")
em=input("Confirm Password:")
if pas==em:
mycursor.execute("insert
into user(username,password)
values('{}','{}')".format(nm,pas))
mydb.commit()
print(mycursor.rowcount,"Id
Created")
else:
print("Password does not
match")
main()
def login():
mycursor=mydb.cursor()
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.fetchal
l()
print("Name \t Score")
for i in myrecords:
print(i[1],'\t',i[3])
print("Total number of rows
retrieved",mycursor.rowcou
nt)
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],":",myr
ecords[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:

Press 1 to create new user account:


Press 2 for User Login and play game:

Press ‘Y’ to Start Game after login:


(If answer is correct, Score increases by
10 points per correct question. )

(If answer goes wrong, Score remains


same. )
(After last question user can watch
final score. And can press ‘Y’ to play
again.)

(If user score 50 “You won” message


start flashing. And game redirect to
main menu)
Press 3 for getting list of all user and
can watch scores of all user:
Bibliography
Book Name
Preeti Arora

Website
http://python.mykvs.in/index.php

https://www.google.co.in/

You might also like