Computer Science Final Project - After Editing
Computer Science Final Project - After Editing
G.R.TEJNI
K.S.DHARSHANA
R.ARAVIND
Page | 1
INDEX
1. Problem Definition 3
Requirements
4. Future Enhancements 7
6. Output 29-35
7. Bibliography 36
Page | 2
PROBLEM DEFINITION
QUIZ MASTER is based on popular reality quiz shows where a player
has to answer some questions based on various themes. The player gets
to choose the correct answer from four different sets of options. If the
player chooses the right option he gets one point and proceeds. If the
option was wrong no points will be allotted.
This portal allows the user to take a quiz from pre-existing topics
like Computer science, Science, General knowledge and Geography.
This portal allows the user to enter the questions and the options
corresponding to it. After entering the questions and options the user
can let their friend or their companion take the quiz and receive their
scores accordingly.
3. Expert Mode:
This portal lets the user to play a competitive quiz game mode
where the players competes to get the No.1 spot on the leaderboard.
Unlike others, in this game mode the players get +4 points for
answering a question correctly and -1 point for answering it wrong.
Page | 3
PROBLEM ANALYSIS
LANGUAGES USED:-
Python is an interpreted, object-oriented, high level programming language with
dynamic semantics. Its design philosophy emphasizes code readability with its
use of significant indentation. Its language constructs as well as its object-
oriented approach aim to help programmers write clear, logical code for small
and large-scale projects.
SQL is a domain-specific language used in programming and designed for
managing data held in a relational database management system, or for stream
processing in a relational data stream management system
MySQL Workbench is a visual database design tool that integrates SQL
development, administration, database design, creation and maintenance into a
single integrated development environment for the MySQL database system
MODULES USED:
Random
Sys
FUNCTIONS USED:
Home():
This function is used to display the main portal of the QUIZ MASTER.
Computer():
This function is used to execute the program which is responsible for the
showcasing and interpreting the collected data and thereby letting the player to
take the quiz based on Computer science.
Science():
This function is used to execute the program which is responsible for the
showcasing and interpreting the collected data and thereby letting the player to
take the quiz based on Science.
Page | 4
Geography():
This function is used to execute the program which is responsible for the
showcasing and interpreting the collected data and thereby letting the player to
take the quiz based on General knowledge and Geography.
Question():
This function is the first part of the Interactive friendly quiz portal and it is
used to accept the questions and answers from the users and compile them in a
quiz format and making it available for the user to take the quiz.
Quiz():
This function is the second part of the Interactive Friendly Quiz portal and it
lets the user to take the quiz which was created by their companion. It also allows
the user to save the quiz and play it later.
Expertmode():
This function executes the program to let the user play the Expertmode.
Leaderboard():
This function is used to accept the player details and add them to the current
leaderboard.
ViewLB():
This function lets the user to view the current leaderboard positions of the
top players ranked from the highest score to the lowest score.
Page | 5
HARDWARE & SOFTWARE
REQUIREMENT
HARDWARE SPECIFICATION:-
Processor : Dual core or above
Hard Disk : 40 GB
RAM : 8GB
Page | 6
FUTURE ENHANCEMENT
The Quiz Master can be given an app like user interface, which can make the
experience even more interactive and fun.
The ability to add more pre-existing questions to the database giving the user
more options to choose from.
The ability to create your own marking scheme for the Friendly Interactive
Quiz Portal.
The ability to create a permanent account which can store your previous
scores along with a login ID and password to access your account.
Page | 7
SOURCE CODE
import sys
import mysql.connector
import random
mycursor=mydb.cursor()
def Home():
f=1
try:
while f!=4:
print("**************************")
print("Welcome to QuizMaster")
print("**************************")
print("3.Expert Mode")
print("4. Exit")
if f==1:
while f==1:
Page | 8
print('1.Computer Science')
print('2.General Knowledge')
print('3.Science')
if p==1:
Computer()
elif p==2:
Geography()
elif p==3:
Science()
else:
elif f==2:
print('2.Take Quiz')
if k==1:
Question()
elif k==2:
Quiz()
else:
Home()
elif f==3:
Page | 9
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~")
print("********************************")
print("INSTRUCTIONS:- This is a competitive game mode where players compete with their
scores to get the No.1 spot on the Leaderboard.")
print('After the completion of the quiz you will be able to view the leaderboard positions of the top
players along with their dates of participation.')
print("The following table shows the current leaderboard positions of all the previous participants.
Try your best to beat them")
print("***************************************")
ViewLB()
print("***************************************")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~")
print('NOTE:- In this Game mode for every correct answer you will recieve 4 points and for every
wrong answer you will lose 1 point. You also have an option to skip the question')
print("Good Luck!!")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~")
Expertmode()
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~")
elif f==4:
mydb.close()
sys.exit()
except ValueError:
Home()
def Computer():
try:
print("***********************")
mycursor.execute("insert into csc values(4,'Choose the incorrect option: Python is a/an. .. ','Non-
extensible language','Easy to read language','Free and open source','Interpreted language','Non-extensible
language')")
mycursor.execute("insert into csc values(5,'What data type can hold more than one
value?','String','List','Integer','Boolean','List')")
mycursor.execute("insert into csc values(6,'What would you put in an if statement to see if two values
are equal?','//','++','==','||','==')")
Page | 11
mycursor.execute("insert into csc values(7,'Which of the following is the correct extension of the
Python file?','.p','.py','.python','.pl','.py')")
mycursor.execute("insert into csc values(8,'What arithmetic operators can be used with strings in
Python?','+','-','*','All of the above','+')")
mycursor.execute("insert into csc values(9,'To add a new element to a list we use which Python
command?','list1.addEnd(5)','list1.addLast(5)','list1.append(5)','list1.add(5)','list1.append(5)')")
mydb.commit()
data=mycursor.fetchall()
rc=mycursor.rowcount
if noq>rc:
Home()
l=[]
while len(l)!=noq:
x=random.randint(1,rc)
if l.count(x)>0:
l.remove(x)
else:
l.append(x)
c=1
score=0
Page | 12
for i in range(0,len(l)):
ques=mycursor.fetchone()
print(" ")
print("Q.",c,": ",ques[1],"\nA.",ques[2],"\t\tB.",ques[3],"\nC.",ques[4],"\t\tD.",ques[5])
print(" ")
c+=1
ans=None
while ans==None:
if choice=='A' or choice=='a':
ans=ques[2]
ans=ques[3]
ans=ques[4]
ans=ques[5]
else:
if ans==ques[6]:
print("Correct")
score=score+1
else:
print(" ")
Home()
except:
print('Refreshing..')
Computer()
def Science():
try:
print("***********************")
mycursor.execute("insert into sci values(4,'What is a material that does not carry an electrical charge
called?','Conductor','Insulator','Semi-Conductor','None of the above','Insulator')")
mycursor.execute("insert into sci values(5,'What is the most abundant gas in the Earth
atmosphere?','Nitrogen','Oxygen','Helium','Carbon Dioxide','Nitrogen')")
mycursor.execute("insert into sci values(6,'What name is given for the number of protons found in the
nucleus of an atom?','Mass Number','Atomic Number','Oxidation Number','Neutron Number','Atomic
Number')")
mycursor.execute("insert into sci values(7,'Which of the following is a non metal that remains liquid at
room temperature?','Phosphorous','Bromine','Chlorine','Helium','Bromine')")
Page | 14
mycursor.execute("insert into sci values(8,'Which of the following is used in
pencils?','Graphite','Charcoal','Silicon','Phosphorus','Graphite')")
mydb.commit()
data=mycursor.fetchall()
rc=mycursor.rowcount
if noq>rc:
Home()
l=[]
while len(l)!=noq:
x=random.randint(1,rc)
if l.count(x)>0:
l.remove(x)
else:
l.append(x)
c=1
score=0
for i in range(0,len(l)):
ques=mycursor.fetchone()
Page | 15
print(" ")
print("Q.",c,": ",ques[1],"\nA.",ques[2],"\t\tB.",ques[3],"\nC.",ques[4],"\t\tD.",ques[5])
print(" ")
c+=1
ans=None
while ans==None:
if choice=='A' or choice=='a':
ans=ques[2]
ans=ques[3]
ans=ques[4]
ans=ques[5]
else:
if ans==ques[6]:
print("Correct")
score=score+1
else:
print(" ")
print(" ")
Home()
Page | 16
except:
print('Refreshing..')
Science()
def Geography():
try:
print("***********************")
mycursor.execute("insert into geo values(2,'Which country has the largest population in the
world?','India','China','USA','Russia','China')")
mycursor.execute("insert into geo values(3,'What is the name of the largest country in the
world?','Russia','USA','China','Africa','Russia')")
mycursor.execute("insert into geo values(4,'What is the name of the largest ocean in the world?','The
Pacific Ocean','Indian Ocean','Atlantic Ocean','Arctic Ocean','The Pacific Ocean')")
mycursor.execute("insert into geo values(6,'What is the full form of ISRO?','Indian Space Research
Organisation','International Space Research Organisation','Indian Science Research Organisation','Indian
Space Resource Organisation','Indian Space Research Organisation')")
mycursor.execute("insert into geo values(10,'Which one of the following is the second tallest mountain
in the world?','Mt.Everest','K2','Kangchenjunga','Lhotse','K2')")
Page | 17
mydb.commit()
data=mycursor.fetchall()
rc=mycursor.rowcount
if noq>rc:
Home()
l=[]
while len(l)!=noq:
x=random.randint(1,rc)
if l.count(x)>0:
l.remove(x)
else:
l.append(x)
c=1
score=0
for i in range(0,len(l)):
ques=mycursor.fetchone()
print(" ")
print("Q.",c,": ",ques[1],"\nA.",ques[2],"\t\tB.",ques[3],"\nC.",ques[4],"\t\tD.",ques[5])
print(" ")
c+=1
ans=None
Page | 18
while ans==None:
if choice=='A' or choice=='a':
ans=ques[2]
ans=ques[3]
ans=ques[4]
ans=ques[5]
else:
if ans==ques[6]:
print("Correct")
score=score+1
else:
print(" ")
print(" ")
Home()
except:
print('Refreshing..')
Geography()
Page | 19
def Question():
try:
ch='Y'
print("***********************")
print("***********************")
ans=0
while ans==0:
if op==1:
ans=op1
elif op==2:
ans=op2
elif op==3:
ans=op3
elif op==4:
ans=op4
Page | 20
else:
data=mycursor.fetchall()
qid=(mycursor.rowcount)+1
mydb.commit()
if h=='y' or h=='Y':
Quiz()
else:
if u=='y' or u=='Y':
Home()
else:
Home()
except:
Question()
def Quiz():
Page | 21
try:
print("**************************")
print("**************************")
data=mycursor.fetchall()
rc=mycursor.rowcount
if noq>rc:
Home()
l=[]
while len(l)!=noq:
x=random.randint(1,rc)
if l.count(x)>0:
l.remove(x)
else:
l.append(x)
c=1
score=0
for i in range(0,len(l)):
ques=mycursor.fetchone()
print(" ")
print("Q.",c,": ",ques[1],"\nA.",ques[2],"\t\tB.",ques[3],"\nC.",ques[4],"\t\tD.",ques[5])
Page | 22
print(" ")
c+=1
ans=None
while ans==None:
if choice=='A' or choice=='a':
ans=ques[2]
ans=ques[3]
ans=ques[4]
ans=ques[5]
else:
if ans==ques[6]:
print("Correct")
score=score+1
else:
print(" ")
print(" ")
Home()
except:
def Expertmode():
try:
print("****************************************")
print("****************************************")
mycursor.execute("insert into exp values(4,'Who was the first Indian Scientist to win a Nobel
Prize?','C.V Raman','Amartya Sen','Hargobind Khorana','Subramanian Chrandrashekar','C.V Raman')")
mycursor.execute("insert into exp values(5,'Who was the first President of India?','Abdul Kalam','Lal
Bahadur Shastri','Dr. Rajendra Prasad','Zakir Hussain','Dr. Rajendra Prasad')")
mycursor.execute("insert into exp values(6,'What does pip stand for python?','Preferred Installer
Program','Personal Installer Program','Preferred Identifier Program','Personal Identifier Program','Preferred
Installer Program')")
mycursor.execute("insert into exp values(7,' Which of the following is the truncation division
operator in Python?',' / ',' // ',' % ',' || ',' // ')")
mycursor.execute("insert into exp values(8,'Which of the following is not a core data type in Python
programming?','List','Class','Tuple','Dictionary','Class')")
Page | 24
mycursor.execute("insert into exp values(10,'1024 Kilobytes is equal
to. ........','1GB','1TB','1MB','None of the above','1MB')")
mydb.commit()
data=mycursor.fetchall()
print("NOTE:-Make sure to enter the date in the correct format. If the date is not entered properly
your score may not be added to the leaderboard.")
rc=mycursor.rowcount
if noq>rc:
Home()
l=[]
while len(l)!=noq:
x=random.randint(1,rc)
if l.count(x)>0:
l.remove(x)
else:
l.append(x)
c=1
score=0
for i in range(0,len(l)):
print(" ")
print("Q.",c,": ",ques[1],"\nA.",ques[2],"\t\tB.",ques[3],"\nC.",ques[4],"\t\tD.",ques[5])
print(" ")
c+=1
ans=None
while ans==None:
if choice=='A' or choice=='a':
ans=ques[2]
ans=ques[3]
ans=ques[4]
ans=ques[5]
ans='skipped'
else:
if ans==ques[6]:
print("Correct")
score=score+4
elif ans=='skipped':
else:
m=[]
m.append(name)
m.append(dt)
m.append(score)
Leaderboard(m)
print(" ")
print(" ")
G=input("Y/N?")
if G=='y' or G=='Y':
ViewLB()
Home()
else:
Home()
except:
def Leaderboard(z):
Page | 27
try:
except:
def ViewLB():
data=mycursor.fetchall()
print(row)
Home()
Page | 28
OUTPUT
Page | 29
This is the output for a user attempting a quiz from one of the
pre-existing topics.
Page | 30
This is the output for the user attempting to take the quiz via
Friendly Interactive Quiz portal.
The user has to enter the questions first in order to take the
quiz.
Page | 31
This the output shown when the user attempts the Friendly
Interactive quiz.
Page | 32
This is the main menu of the Expert mode portal.
This is the output for the user attempting the Expert mode quiz.
Page | 33
Note: In the above shown output we can see as to what happens if we skip a
question.
Page | 34
The above output shows that the user can exit the QuizMaster Portal
anytime they want.
Page | 35
BIBLIOGRAPHY
https://www.mysql.com
https://www.python.org
https://en.wikipedia.org/wiki/SQL
https://www.gktoday.in/gk-questions/
Computer Science with Python by Sumita Arora from Dhanpat Rai & Co.
Publication
Page | 36