Simple Quiz App Using Python
Simple Quiz App Using Python
Simple Quiz App Using Python
INTRODUCTION
One of the main benefits of our system is automated marking, that is, teachers do not
need to check the answer script as they do in manual quiz. It saves valuable time of a teacher.
On the other hand, students can score according to his/her merit level and it will give
feedback about a student in which side he/she is weak. In recent years, the use of online quiz
systems has become quite popular due to pressures of increasing class sizes and the need for
more efficient and effective methods of assessing distant students. It is due to the popularity
of distant education. Still now maximum educational institutes have been using manual
system to take quiz. In the recent year a few instructors of some institutes have been using
web-based M.C.Q. quiz system. Actually, it depends on how much web technology a country
takes or uses. For example, in Bangladesh it is rare to use a web based quiz system. But in
case of U.S.A. it is a general case to use a web based quiz system.
1
2. SYSTEM ANALYSIS
Technical Feasibility
Technical Feasibility deals with the hardware as well as software requirements.
Technology is not a constraint to type system development. To find out whether the
necessary technology, the proposed equipments have the capacity to hold the data, which is
used in the project, should be checked to carry out this technical feasibility.
The technical feasibility issues usually raised during the feasibility stage of
investigation includes these
This software is running in windows 7 Operating System, which can be easily
installed.
The hardware required is Pentium based server.
The system can be expanded.
2
Economical Feasibility
This feasibility study present tangible and intangible benefits from the prefect by
comparing the development and operational cost. The technique of cost benefit analysis is
often used as a basis for assessing economic feasibility. This system needs some more initial
investment than the existing system, but it can be justifiable that it will improve quality of
service.
Thus feasibility study should center along the following points:
Improvement resulting over the existing method in terms of accuracy,
timeliness.
Cost comparison
Estimate on the life expectancy of the hardware
Overall objective
Our project is economically feasible. It does not require much cost to be involved in the
overall process. The overall objectives are in easing out the requirement processes.
3
2.2 EXISTING SYSTEM
In the early days it was the most popular methods of assessing student. Still now the
system is quite popular to the students as well as to the teacher. In this system there are
several problems that we face in a common way. Some of those problems are: Manual system
requires pen/ pencils and paper. Teacher needs to spend time to script checking. Student
needs to wait to get their result up to the teacher finishes the script checking. These are the
most common problems of manual quiz system that rotated each and every time of quiz held.
For these causes the popularity of manual system decreases day by day and online intelligent
quiz system is taking the place of the manual system.
4
2.2 PROPOSED SYSTEM
Now a day the web base quiz system is getting popular with a tremendous speed. As
the technology is spreading through out the world the automated system will also taking the
places of the manual systems. Currently big institutes are running their online quiz systems at
a very successful rate. As the time is progressing the online quiz is making interest to the
faculties and also to the students. In the big cities and organizations people are getting
understand that how the online quiz system is better and efficient. With in the recent time this
system will be taken place to this techno world. But this system also has some lacking. If this
system has the intelligent part then it will be a perfect one. The problems that may occurs
with web based quiz system: Can’t evaluate the student perfectly. Can’t generate the proper
feed back of the students.
From the previous two systems I realize to solve the problems of those systems to get
a standard quiz system. In the previous two systems the things that are short from a standard
quiz system, to fix it up I design an intelligent system, which will work according to the web
base system. From this intelligent system we can omit the manual system’s problem criteria
because it work as a web base system, which is totally automated. It also omit the general
web based system because it gives the evaluate option for the students performance and feed
back criteria. To get a standard quiz system I tried to join the intelligent system that I
designed for my thesis project. This will help to remove the current system’s problems.
In recent years, the use of electronic online quiz systems has become quite popular
due to pressures of increasing class sizes, and the need for more efficient methods of
assessing distances students. This thing motivates us to work with web based quiz system.
We also have tried to eliminate the problem with general web based quiz system and decide
to create a web based intelligent quiz system. In our thesis project, we have tried to develop
an “Online Intelligent Quiz System” which will be popular in both the students and teachers.
To develop the system we collected some documents from web. Then we have analyzed
those documents and tried to find some logic from there. As a step of development we
collected requirements where we have conducted a survey. In that survey we took teachers
and students opinions to make the system more meaningful. For that we made a question set
and gave it to some teachers and students. They gave their opinions on those scripts. In below
survey details are given.
5
3. SYSTEM ENVIRONMENT
RAM capacity : 4 GB
Mouse : Optical
Coding : Python
6
3.3 SOFTWARE SPECIFICATION
FRONT END
Often, programmers fall in love with Python because of the increased productivity it
provides. Since there is no compilation step, the edit-test-debug cycle is incredibly fast.
Debugging Python programs is easy: a bug or bad input will never cause a segmentation
fault. Instead, when the interpreter discovers an error, it raises an exception. When the
program doesn't catch the exception, the interpreter prints a stack trace. A source level
debugger allows inspection of local and global variables, evaluation of arbitrary expressions,
setting breakpoints, stepping through the code a line at a time, and so on. The debugger is
written in Python itself, testifying to Python's introspective power. On the other hand, often
the quickest way to debug a program is to add a few print statements to the source: the fast
edit-test-debug cycle makes this simple approach very effective.
Python uses dynamic typing and a combination of reference counting and a cycle-
detecting garbage collector for memory management. It also features dynamic name
resolution (late binding), which binds method and variable names during program execution.
7
Python's design offers some support for functional programming in the Lisp tradition.
It has filter, map, and reduce functions; list comprehensions, dictionaries, sets, and generator
expressions. The standard library has two modules (itertools and functools) that implement
functional tools borrowed from Haskell and Standard ML.[56]
The language's core philosophy is summarized in the document The Zen of Python
(PEP 20), which includes aphorisms such as:
Rather than having all of its functionality built into its core, Python was designed to
be highly extensible. This compact modularity has made it particularly popular as a means of
adding programmable interfaces to existing applications. Van Rossum's vision of a small core
language with a large standard library and easily extensible interpreter stemmed from his
frustrations with ABC, which espoused the opposite approach.
Python strives for a simpler, less-cluttered syntax and grammar while giving
developers a choice in their coding methodology. In contrast to Perl's "there is more than one
way to do it" motto, Python embraces a "there should be one—and preferably only one—
obvious way to do it" design philosophy. Alex Martelli, a Fellow at the Python Software
Foundation and Python book author, writes that "To describe something as 'clever' is not
considered a compliment in the Python culture."
Python's developers strive to avoid premature optimization, and reject patches to non-
critical parts of the C Python reference implementation that would offer marginal increases in
speed at the cost of clarity.[59] When speed is important, a Python programmer can move time-
critical functions to extension modules written in languages such as C, or use PyPy, a just-in-
time compiler. Cython is also available, which translates a Python script into C and makes
direct C-level API calls into the Python interpreter.
8
An important goal of Python's developers is keeping it fun to use. This is reflected in
the language's name—a tribute to the British comedy group Monty Python[60]—and in
occasionally playful approaches to tutorials and reference materials, such as examples that
refer to spam and eggs (from a famous Monty Python sketch) instead of the standard foo and
bar.[61][62]
A common neologism in the Python community is pythonic, which can have a wide
range of meanings related to program style. To say that code is pythonic is to say that it uses
Python idioms well, that it is natural or shows fluency in the language, that it conforms with
Python's minimalist philosophy and emphasis on readability. In contrast, code that is difficult
to understand or reads like a rough transcription from another programming language is
called unpythonic.
The assignment statement (token '=', the equals sign). This operates differently than in
traditional imperative programming languages, and this fundamental mechanism
(including the nature of Python's version of variables) illuminates many other features
of the language. Assignment in C, e.g., x = 2, translates to "typed variable name x
receives a copy of numeric value 2". The (right-hand) value is copied into an allocated
storage location for which the (left-hand) variable name is the symbolic address. The
memory allocated to the variable is large enough (potentially quite large) for the
declared type. In the simplest case of Python assignment, using the same example, x =
2, translates to "(generic) name x receives a reference to a separate, dynamically
allocated object of numeric (int) type of value 2." This is termed binding the name to
the object. Since the name's storage location doesn't contain the indicated value, it is
improper to call it a variable. Names may be subsequently rebound at any time to
objects of greatly varying types, including strings, procedures, complex objects with
data and methods, etc. Successive assignments of a common value to multiple names,
e.g., x = 2; y = 2; z = 2 result in allocating storage to (at most) three names and one
9
numeric object, to which all three names are bound. Since a name is a generic
reference holder it is unreasonable to associate a fixed data type with it. However at a
given time a name will be bound to some object, which will have a type; thus there is
dynamic typing.
The if statement, which conditionally executes a block of code, along with else and
elif (a contraction of else-if).
The for statement, which iterates over an iterable object, capturing each element to a
local variable for use by the attached block.
The while statement, which executes a block of code as long as its condition is true.
The try statement, which allows exceptions raised in its attached code block to be
caught and handled by except clauses; it also ensures that clean-up code in a finally
block will always be run regardless of how the block exits.
The raise statement, used to raise a specified exception or re-raise a caught exception.
The class statement, which executes a block of code and attaches its local namespace
to a class, for use in object-oriented programming.
The def statement, which defines a function or method.
The with statement, from Python 2.5 released in September 2006, which encloses a
code block within a context manager (for example, acquiring a lock before the block
of code is run and releasing the lock afterwards, or opening a file and then closing it),
allowing Resource Acquisition Is Initialization (RAII)-like behavior and replaces a
common try/finally idiom.[68]
The break statement, exits from the loop.
The continue statement, skips this iteration and continues with the next item.
The pass statement, which serves as a NOP. It is syntactically needed to create an
empty code block.
The assert statement, used during debugging to check for conditions that ought to
apply.
The yield statement, which returns a value from a generator function. From Python
2.5, yield is also an operator. This form is used to implement coroutines.
The import statement, which is used to import modules whose functions or variables
can be used in the current program. There are three ways of using import: import
<module name> [as <alias>] or from <module name> import * or from <module
name> import <definition 1> [as <alias 1>], <definition 2> [as <alias 2>], ....
The print statement was changed to the print() function in Python 3.
10
Python does not support tail call optimization or first-class continuations, and,
according to Guido van Rossum, it never will. However, better support for coroutine-like
functionality is provided in 2.5, by extending Python's generators. Before 2.5, generators
were lazy iterators; information was passed unidirectionally out of the generator. From
Python 2.5, it is possible to pass information back into a generator function, and from Python
3.3, the information can be passed through multiple stack levels.
Libraries
Python's large standard library, commonly cited as one of its greatest strengths,[101]
provides tools suited to many tasks. For Internet-facing applications, many standard formats
and protocols such as MIME and HTTP are supported. It includes modules for creating
graphical user interfaces, connecting to relational databases, generating pseudorandom
numbers, arithmetic with arbitrary-precision decimals,[102] manipulating regular expressions,
and unit testing.
Some parts of the standard library are covered by specifications (for example, the
Web Server Gateway Interface (WSGI) implementation wsgiref follows PEP 333[103]), but
most modules are not. They are specified by their code, internal documentation, and test
suites. However, because most of the standard library is cross-platform Python code, only a
few modules need altering or rewriting for variant implementations.
As of November 2019, the Python Package Index (PyPI), the official repository for
third-party Python software, contains over 200,000 packages with a wide range of
functionality, including:
Automation Multimedia
Data analytics Networking
Databases Scientific computing
Documentation System administration
Graphical user interfaces Test frameworks
Image processing Text processing
Machine learning Web frameworks
Mobile App Web scraping
11
Cross-compilers to other languages
12
BACK END
SQLite
INTRODUCTON
SQLite is a relational database management system contained in a C programming
library. In contrast to many other database management systems, SQLite is not a client–
server database engine. Rather, it is embedded into the end program.SQLite is ACID-
compliant and implements most of the SQL standard, using a dynamically and weakly
typed SQL syntax that does not guarantee the domain integrity.
DESIGN
Unlike client–server database management systems, the SQLite engine has no
standalone processes with which the application program communicates. Instead, the
SQLite library is linked in and thus becomes an integral part of the application program.
The library can also be called dynamically. Due to the server-less design, SQLite
applications require fewer configurations than client-server databases. SQLite is called
zero-conf[7]because it does not require service management (such as startup scripts) or
access control based on GRANT and passwords. Several computer processes or threads
may access the same database concurrently. Several read accesses can be satisfied in
parallel. A write access can only be satisfied if no other accesses are currently being
serviced. Otherwise, the write access fails with an error code (or can automatically be
retried until a configurable timeout expires). This concurrent access situation would
change when dealing with temporary tables. This restriction is relaxed in version 3.7
when write-ahead logging (WAL) is turned on enabling concurrent reads and writes.
13
4. SYSTEM DESIGN
4.1 INPUT DESIGN
In the input design, user-oriented inputs are converted into a computer based system
format. It also includes determining the record media, method of input, speed of capture and
entry on to the screen. Online data entry accepts commands and data through a keyboard. The
major approach to input design is the menu and the prompt design. In each alternative, the
user’s options are predefined. The data flow diagram indicates logical data flow, data stores,
source and destination. Input data are collected and organized into a group of similar data.
Once identified input media are selected for processing.
In this software, importance is given to develop Graphical User Interface (GUI),
which is an important factor in developing efficient and user-friendly software. For inputting
user data, attractive forms are designed. User can also select desired options from the menu,
which provides all possible facilities.
Also the important input format is designed in such a way that accidental errors are
avoided. The user has to input only just the minimum data required, which also helps in
avoiding the errors that the users may make. Accurate designing of the input format is very
important in developing efficient software. The goal or input design is to make entry as easy,
logical and free from errors.
14
4.3 DATABASE DESIGN
Database design is the process of producing a detailed data model of a database.
Logical data model contains all the needed logical and physical design choices and physical
storage parameters needed a design in a Definition Language, Which can then be used to
create a database. A fully attributed data model contains detailed attributes for each entity.
15
5. SYSTEM SPECIFATION
16
MODULES
This Project main purpose is to develop Online Quiz system named ‘LETS QUIZ’. The
application (LETS QUIZ) will provide online based quiz with multiple choice question
(MCQ). This quiz application will support android base operating system. With this
application, users or any organization can perform actions like
Administrative Task
Interviewee Task
Administrative Task
Addition, Deletion and update for questions, answers are the main part of administrative
task. Quizzes, Users also can add, delete and update from user interface (UI). As a result, the
following tasks are define as administrative task.
Interviewee Task
Select any Quiz or subject which he /she wants to give Examination. One interviewee can
give Quiz only for one time. Once a quiz has finished, it become 5 inactive to that user.
Finally, Score can be shown considering the quiz has been taken from any individuals. As a
result, the following tasks are define as interviewee task.
Administrator and Interviewee user login to the application from any android platform
which is define as Client side. On the otherhand, application server or web server and
17
Database server are define as server site. Application server communicates with the database
where all the information are store. Client side and server side communicate between them
with Http/Https.
18
6. SYSTEM IMPLEMENTATION
Implementation is the stage of the project when the theoretical design is turned into a
working system. Implementation means converting a new or revised system design into an
operational condition. In this project Bug Tracking maintains NPR Arts and Science College,
Dindigul, implementation includes all these activities that the place to convert the new
system.
The purpose of test plan is preparing it helps us to think through the efforts needed to
validate the acceptability of a software product. It will help people outside the test group to
understand the why and how of product validation and regulated environments, we have to
have a written test plan. The general testing process includes the creation of a test plan .We
want a document that describes the objectives, scope, approach and focus of the software
testing effort. It includes test cases, conditions, the test environment, a list of related tasks,
pass/fail criteria, and risk assessment. One of the outputs for creating a test strategy is an
approved and signed off test plan document. The software testing methodology a three step
process and one of the steps is the creation of a test plan. We want an opportunity to review
the test plan with the project team. Test plans should be documented, so that they are
repeatable.
The purpose of training is to ensure that all the personal who are associate with the
system should possess the basic knowledge and skills. The end user must know in detail what
their rules will be how they can use the system and what the system will or will not do before
the initialization of the training the programmer materials are prepared for the users with
description. The users are instructed first, how to operate the system. User training also
instructs individuals in trouble shooting system determining whether problem arise due to any
system failure or software failure or something that they had one in using the system. The
system will be implemented as soon as possible.
19
7. SYSTEM TESTING
Software testing is an important element of software quality assurance and represents the
ultimate review of specification, design and coding. It increasing visibility of software as a
system element and the costs associates with a software failure are motivating forces for all
well planned through testing .The system is tested with giving wrong information. Cascade
deletion and, the software developer checks updating. Testing and debugging are different
activities, but debugging must be accommodated in any testing strategy.
TYPES OF TESTING
UNIT TESTING
Unit testing is the important and major part of the project. So errors can be rectified
easily in each module and program clarity can be increased. In this project, the entire system
is divided into several modules and is developed individually. Hence, unit testing is
conducted to individual modules.
INTEGRATION TESTING
Integration testing is the systematic technique for constructing the program structure
while conducting tests to uncover errors associated with integrating. After the unit test, each
module is gradually integrated to form one final system. All the modules when unit tested
will work properly but after integrating the data can cause error one module can have an
inadvertent, adverse effect on another; sub functions when combined may not produce the
desired major function; global data structures can cause problems, etc. In this project the
integration testing is performed by combing login, civil registration and status modules are
generated the report.
20
PERFORMANCE TESTING
A type of Physical test covering a wide range of engineering or functional evaluations
where a material, product, or system is not specified by detailed material or component
specifications: rather, emphasis is on the final measurable performance characteristics.
Testing can be a qualitative or quantitative procedure.
ACCEPTANCE TESTING
The User Acceptance testing focuses mainly on the functionality thereby validating
the fitness-for-use of the system by the business user. The user acceptance test is performed
by the users and application managers.
Test Results
All the test cases mentioned above passed successfully. No defects encountered.
21
8. CONCLUSION
In Online quiz management system report in python. thesis, we have focused on the
automated system, which replaces the manual quiz system. But the interesting thing is that
the thesis is not just an online quiz system; it has its own intelligent capability. This was
actually our target feature of our thesis. Basically, we have tried to introduce the evaluation
method of student-performance and the feedback of the student in the online quiz. Here, the
questions are appeared according to the previous answer of that student. We have
implemented it in our thesis and it works successfully in our system. In this system, an
educational institute can make their examination procedure automated. It gives the
opportunity to the authority to register teachers for different subjects and also give the facility
to the students to register their courses for the examinations using the OIQS. Though this is a
MCQ based quiz system but it is a perfect MCQ based online quiz system that gives a lot of
facilities to the users, as a modern quiz system should have. This system is designed basically
for the educational institute but also can be developed for other examination systems like job
interview, quiz contest and for other criteria.
FUTURE WORK
Currently, ‘Let’s quiz’ application is developed for Android operating system. As this
is the staring of this kind of initiative, Majority for uses, Android is considered as first choice.
Other platform like IOS, Windows, and Tizen etc. will consider as future development work.
As Lets Quiz is developed with cross platform IDE (Titanium Studio), so little modification
will help to build apps that support other operating system. Graphical enhancement wills also
a part of future planning
22
9. BIBILIOGRAPHY
Reference Websites
[1] http://www.tutorialspoint.com/python
[2] https://www.w3schools.com/python
[3] https://www.learnpython.org
[4] https://www.programiz.com
23
10. APPENDIX
SCREEN SHOT
24
25
26
SOURCE CODE
import tkinter as tk
from tkinter import *
import random
import sqlite3
import time
def loginPage(logdata):
sup.destroy()
global login
login = Tk()
user_name = StringVar()
password = StringVar()
login_canvas = Canvas(login,width=720,height=440,bg="#101357")
login_canvas.pack()
login_frame = Frame(login_canvas,bg="white")
login_frame.place(relwidth=0.8,relheight=0.8,relx=0.1,rely=0.1)
#USER NAME
ulabel = Label(login_frame,text="Username",fg='black',bg='white')
ulabel.place(relx=0.21,rely=0.4)
uname = Entry(login_frame,bg='#d3d3d3',fg='white',textvariable = user_name)
uname.config(width=42)
uname.place(relx=0.31,rely=0.4)
#PASSWORD
plabel = Label(login_frame,text="Password",fg='black',bg='white')
27
plabel.place(relx=0.215,rely=0.5)
pas = Entry(login_frame,bg='#d3d3d3',fg='white',textvariable = password)
pas.config(width=42)
pas.place(relx=0.31,rely=0.5)
def check():
for a,b,c,d in logdata:
if b == uname.get() and c == pas.get():
menu()
break
else:
error = Label(login_frame,text="Wrong Username or
Password!",fg='black',bg='white')
error.place(relx=0.37,rely=0.7)
#LOGIN BUTTON
log = Button(login_frame,text='Login',padx=5,pady=5,width=5,command=check)
log.configure(width = 15,height=1, activebackground = "#33B5E5", relief = FLAT)
log.place(relx=0.4,rely=0.6)
login.mainloop()
def signUpPage():
root.destroy()
global sup
sup = Tk()
fname = StringVar()
uname = StringVar()
passW = StringVar()
country = StringVar()
28
sup_canvas = Canvas(sup,width=720,height=440,bg="#101357")
sup_canvas.pack()
sup_frame = Frame(sup_canvas,bg="white")
sup_frame.place(relwidth=0.8,relheight=0.8,relx=0.1,rely=0.1)
#full name
flabel = Label(sup_frame,text="Full Name",fg='black',bg='white')
flabel.place(relx=0.21,rely=0.4)
fname = Entry(sup_frame,bg='#d3d3d3',fg='white',textvariable = fname)
fname.config(width=42)
fname.place(relx=0.31,rely=0.4)
#username
ulabel = Label(sup_frame,text="Username",fg='black',bg='white')
ulabel.place(relx=0.21,rely=0.5)
user = Entry(sup_frame,bg='#d3d3d3',fg='white',textvariable = uname)
user.config(width=42)
user.place(relx=0.31,rely=0.5)
#password
plabel = Label(sup_frame,text="Password",fg='black',bg='white')
plabel.place(relx=0.215,rely=0.6)
pas = Entry(sup_frame,bg='#d3d3d3',fg='white',textvariable = passW)
pas.config(width=42)
pas.place(relx=0.31,rely=0.6)
29
#country
clabel = Label(sup_frame,text="Country",fg='black',bg='white')
clabel.place(relx=0.215,rely=0.7)
c = Entry(sup_frame,bg='#d3d3d3',fg='white',textvariable = country)
c.config(width=42)
c.place(relx=0.31,rely=0.7)
def addUserToDataBase():
fullname = fname.get()
username = user.get()
password = pas.get()
country = c.get()
conn = sqlite3.connect('quiz.db')
create = conn.cursor()
create.execute('CREATE TABLE IF NOT EXISTS userSignUp(FULLNAME text,
USERNAME text,PASSWORD text,COUNTRY text)')
create.execute("INSERT INTO userSignUp VALUES (?,?,?,?)",
(fullname,username,password,country))
conn.commit()
create.execute('SELECT * FROM userSignUp')
z=create.fetchall()
print(z)
# L2.config(text="Username is "+z[0][0]+"\nPassword is "+z[-1][1])
conn.close()
loginPage(z)
def gotoLogin():
conn = sqlite3.connect('quiz.db')
create = conn.cursor()
conn.commit()
create.execute('SELECT * FROM userSignUp')
z=create.fetchall()
loginPage(z)
#signup BUTTON
30
sp = Button(sup_frame,text='SignUp',padx=5,pady=5,width=5,command =
addUserToDataBase)
sp.configure(width = 15,height=1, activebackground = "#33B5E5", relief = FLAT)
sp.place(relx=0.4,rely=0.8)
sup.mainloop()
def menu():
login.destroy()
global menu
menu = Tk()
menu_canvas = Canvas(menu,width=720,height=440,bg="#101357")
menu_canvas.pack()
menu_frame = Frame(menu_canvas,bg="white")
menu_frame.place(relwidth=0.8,relheight=0.8,relx=0.1,rely=0.1)
wel = Label(menu_canvas,text=' W E L C O M E T O Q U I Z S T A T I O N
',fg="white",bg="#101357")
wel.config(font=('Broadway 22'))
wel.place(relx=0.1,rely=0.02)
31
level.place(relx=0.25,rely=0.3)
var = IntVar()
easyR = Radiobutton(menu_frame,text='Easy',bg="white",font="calibri
16",value=1,variable = var)
easyR.place(relx=0.25,rely=0.4)
mediumR = Radiobutton(menu_frame,text='Medium',bg="white",font="calibri
16",value=2,variable = var)
mediumR.place(relx=0.25,rely=0.5)
hardR = Radiobutton(menu_frame,text='Hard',bg="white",font="calibri
16",value=3,variable = var)
hardR.place(relx=0.25,rely=0.6)
def navigate():
x = var.get()
print(x)
if x == 1:
menu.destroy()
easy()
elif x == 2:
menu.destroy()
medium()
elif x == 3:
menu.destroy()
difficult()
else:
pass
32
letsgo = Button(menu_frame,text="Let's Go",bg="white",font="calibri
12",command=navigate)
letsgo.place(relx=0.25,rely=0.8)
menu.mainloop()
def easy():
global e
e = Tk()
easy_canvas = Canvas(e,width=720,height=440,bg="#101357")
easy_canvas.pack()
easy_frame = Frame(easy_canvas,bg="white")
easy_frame.place(relwidth=0.8,relheight=0.8,relx=0.1,rely=0.1)
def countDown():
check = 0
for k in range(10, 0, -1):
if k == 1:
check=-1
timer.configure(text=k)
easy_frame.update()
time.sleep(1)
timer.configure(text="Times up!")
if check==-1:
return (-1)
else:
return 0
global score
score = 0
33
easyQ = [
[
"What will be the output of the following Python code? \nl=[1, 0, 2, 0, 'hello', '',
[]] \nlist(filter(bool, nl))",
"[1, 0, 2, ‘hello’, '', []]",
"Error",
"[1, 2, ‘hello’]",
"[1, 0, 2, 0, ‘hello’, '', []]"
],
[
"What will be the output of the following Python expression if the value of x is
34? \nprint(“%fâ€%x)" ,
"34.00",
"34.000000",
"34.0000",
"34.00000000"
],
[
"What will be the value of X in the following Python expression? \nX =
2+9*((3*12)-8)/10" ,
"30.8",
"27.2",
"28.4",
"30.0"
],
[
"Which of these in not a core data type?" ,
"Tuples",
"Dictionary",
"Lists",
"Class"
],
[
34
"Which of the following represents the bitwise XOR operator?" ,
"&",
"!",
"^",
"|"
]
]
answer = [
"[1, 2, ‘hello’]",
"34.000000",
"27.2",
"Class",
"^"
]
li = ['',0,1,2,3,4]
x = random.choice(li[1:])
var = StringVar()
a = Radiobutton(easy_frame,text=easyQ[x][1],font="calibri 10",value=easyQ[x]
[1],variable = var,bg="white")
a.place(relx=0.5,rely=0.42,anchor=CENTER)
b = Radiobutton(easy_frame,text=easyQ[x][2],font="calibri 10",value=easyQ[x]
[2],variable = var,bg="white")
b.place(relx=0.5,rely=0.52,anchor=CENTER)
c = Radiobutton(easy_frame,text=easyQ[x][3],font="calibri 10",value=easyQ[x]
[3],variable = var,bg="white")
c.place(relx=0.5,rely=0.62,anchor=CENTER)
35
d = Radiobutton(easy_frame,text=easyQ[x][4],font="calibri 10",value=easyQ[x]
[4],variable = var,bg="white")
d.place(relx=0.5,rely=0.72,anchor=CENTER)
li.remove(x)
timer = Label(e)
timer.place(relx=0.8,rely=0.82,anchor=CENTER)
def display():
if len(li) == 1:
e.destroy()
showMark(score)
if len(li) == 2:
nextQuestion.configure(text='End',command=calc)
if li:
x = random.choice(li[1:])
ques.configure(text =easyQ[x][0])
a.configure(text=easyQ[x][1],value=easyQ[x][1])
b.configure(text=easyQ[x][2],value=easyQ[x][2])
c.configure(text=easyQ[x][3],value=easyQ[x][3])
d.configure(text=easyQ[x][4],value=easyQ[x][4])
li.remove(x)
print(li)
y = countDown()
if y == -1:
36
display()
def calc():
global score
if (var.get() in answer):
score+=1
display()
submit = Button(easy_frame,command=calc,text="Submit")
submit.place(relx=0.5,rely=0.82,anchor=CENTER)
nextQuestion = Button(easy_frame,command=display,text="Next")
nextQuestion.place(relx=0.87,rely=0.82,anchor=CENTER)
y = countDown()
if y == -1:
display()
e.mainloop()
def medium():
global m
m = Tk()
med_canvas = Canvas(m,width=720,height=440,bg="#101357")
med_canvas.pack()
med_frame = Frame(med_canvas,bg="white")
med_frame.place(relwidth=0.8,relheight=0.8,relx=0.1,rely=0.1)
def countDown():
check = 0
37
for k in range(10, 0, -1):
if k == 1:
check=-1
timer.configure(text=k)
med_frame.update()
time.sleep(1)
timer.configure(text="Times up!")
if check==-1:
return (-1)
else:
return 0
global score
score = 0
mediumQ = [
[
"Which of the following is not an exception handling keyword in Python?",
"accept",
"finally",
"except",
"try"
],
[
"Suppose list1 is [3, 5, 25, 1, 3], what is min(list1)?",
"3",
"5",
"25",
"1"
],
[
"Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1]?",
38
"Error",
"None",
"25",
"2"
],
[
"print(0xA + 0xB + 0xC):",
"0xA0xB0xC",
"Error",
"0x22",
"33"
],
[
"Which of the following is invalid?",
"_a = 1",
"__a = 1",
"__str__ = 1",
"none of the mentioned"
],
]
answer = [
"accept",
"1",
"25",
"33",
"none of the mentioned"
]
li = ['',0,1,2,3,4]
x = random.choice(li[1:])
39
var = StringVar()
a = Radiobutton(med_frame,text=mediumQ[x][1],font="calibri 10",value=mediumQ[x]
[1],variable = var,bg="white")
a.place(relx=0.5,rely=0.42,anchor=CENTER)
b = Radiobutton(med_frame,text=mediumQ[x][2],font="calibri 10",value=mediumQ[x]
[2],variable = var,bg="white")
b.place(relx=0.5,rely=0.52,anchor=CENTER)
c = Radiobutton(med_frame,text=mediumQ[x][3],font="calibri 10",value=mediumQ[x]
[3],variable = var,bg="white")
c.place(relx=0.5,rely=0.62,anchor=CENTER)
d = Radiobutton(med_frame,text=mediumQ[x][4],font="calibri 10",value=mediumQ[x]
[4],variable = var,bg="white")
d.place(relx=0.5,rely=0.72,anchor=CENTER)
li.remove(x)
timer = Label(m)
timer.place(relx=0.8,rely=0.82,anchor=CENTER)
def display():
if len(li) == 1:
m.destroy()
showMark(score)
if len(li) == 2:
nextQuestion.configure(text='End',command=calc)
if li:
40
x = random.choice(li[1:])
ques.configure(text =mediumQ[x][0])
a.configure(text=mediumQ[x][1],value=mediumQ[x][1])
b.configure(text=mediumQ[x][2],value=mediumQ[x][2])
c.configure(text=mediumQ[x][3],value=mediumQ[x][3])
d.configure(text=mediumQ[x][4],value=mediumQ[x][4])
li.remove(x)
print(li)
y = countDown()
if y == -1:
display()
def calc():
global score
if (var.get() in answer):
score+=1
display()
submit = Button(med_frame,command=calc,text="Submit")
submit.place(relx=0.5,rely=0.82,anchor=CENTER)
nextQuestion = Button(med_frame,command=display,text="Next")
nextQuestion.place(relx=0.87,rely=0.82,anchor=CENTER)
y = countDown()
if y == -1:
display()
m.mainloop()
def difficult():
41
global h
h = Tk()
hard_canvas = Canvas(h,width=720,height=440,bg="#101357")
hard_canvas.pack()
hard_frame = Frame(hard_canvas,bg="white")
hard_frame.place(relwidth=0.8,relheight=0.8,relx=0.1,rely=0.1)
def countDown():
check = 0
for k in range(10, 0, -1):
if k == 1:
check=-1
timer.configure(text=k)
hard_frame.update()
time.sleep(1)
timer.configure(text="Times up!")
if check==-1:
return (-1)
else:
return 0
global score
score = 0
hardQ = [
[
"All keywords in Python are in _________",
42
"lower case",
"UPPER CASE",
"Capitalized",
"None of the mentioned"
],
[
"Which of the following cannot be a variable?",
"__init__",
"in",
"it",
"on"
],
[
"Which of the following is a Python tuple?",
"[1, 2, 3]",
"(1, 2, 3)",
"{1, 2, 3}",
"{}"
],
[
"What is returned by math.ceil(3.4)?",
"3",
"4",
"4.0",
"3.0"
],
[
"What will be the output of print(math.factorial(4.5))?",
"24",
"120",
"error",
"24.0"
]
43
]
answer = [
"None of the mentioned",
"in",
"(1,2,3)",
"4",
"error"
]
li = ['',0,1,2,3,4]
x = random.choice(li[1:])
var = StringVar()
a = Radiobutton(hard_frame,text=hardQ[x][1],font="calibri 10",value=hardQ[x]
[1],variable = var,bg="white")
a.place(relx=0.5,rely=0.42,anchor=CENTER)
b = Radiobutton(hard_frame,text=hardQ[x][2],font="calibri 10",value=hardQ[x]
[2],variable = var,bg="white")
b.place(relx=0.5,rely=0.52,anchor=CENTER)
c = Radiobutton(hard_frame,text=hardQ[x][3],font="calibri 10",value=hardQ[x]
[3],variable = var,bg="white")
c.place(relx=0.5,rely=0.62,anchor=CENTER)
d = Radiobutton(hard_frame,text=hardQ[x][4],font="calibri 10",value=hardQ[x]
[4],variable = var,bg="white")
d.place(relx=0.5,rely=0.72,anchor=CENTER)
li.remove(x)
44
timer = Label(h)
timer.place(relx=0.8,rely=0.82,anchor=CENTER)
def display():
if len(li) == 1:
h.destroy()
showMark(score)
if len(li) == 2:
nextQuestion.configure(text='End',command=calc)
if li:
x = random.choice(li[1:])
ques.configure(text =hardQ[x][0])
a.configure(text=hardQ[x][1],value=hardQ[x][1])
b.configure(text=hardQ[x][2],value=hardQ[x][2])
c.configure(text=hardQ[x][3],value=hardQ[x][3])
d.configure(text=hardQ[x][4],value=hardQ[x][4])
li.remove(x)
print(li)
y = countDown()
if y == -1:
display()
def calc():
global score
45
if (var.get() in answer):
score+=1
display()
submit = Button(hard_frame,command=calc,text="Submit")
submit.place(relx=0.5,rely=0.82,anchor=CENTER)
nextQuestion = Button(hard_frame,command=display,text="Next")
nextQuestion.place(relx=0.87,rely=0.82,anchor=CENTER)
y = countDown()
if y == -1:
display()
h.mainloop()
def showMark(mark):
global sh
sh = Tk()
show_canvas = Canvas(sh,width=720,height=440,bg="#101357")
show_canvas.pack()
show_frame = Frame(show_canvas,bg="white")
show_frame.place(relwidth=0.8,relheight=0.8,relx=0.1,rely=0.1)
sh.mainloop()
def start():
global root
root = Tk()
canvas = Canvas(root,width = 1100,height = 540, bg = 'yellow')
46
canvas.grid(column = 0 , row = 1)
img = PhotoImage(file="output-onlinepngtools.png")
canvas.create_image(50,10,image=img,anchor=NW)
root.mainloop()
if __name__=='__main__':
start()
47