· 6 years ago · Jan 26, 2020, 09:46 AM
1
2
3
4
5
6
7
8
9
10
11
12
13Opp. Nagar Palika, Station Road, Khachrod
14School Code: 50970
15
162019 - 2020
17Class – XII
18Subject – Informatics Practices
19
20
21
22Project Topic
23
24
25
26
27,
28
29Submitted to Submitted by
30
31Mr. NarendraMahawar Ku. Aqsha Khan
32
33
34External’s Sign.
35
36
37
38
39
40
41
42
43
44CONTENTS
45
46• CERTIFICATES
47• AKNOWLEDGEMENT
48• INTRODUCTION
49• AIM
50• PROGRAM LISTINGS/ CODING OF PROJECT WITH OUTPUT
51• MERITS
52• DE-MERITS
53• CONCLUSION
54
55
56
57
58
59
60
61
62
63
64
65CERTIFICATE
66
67This is to certify that Aqsa Khan ofImerialInetrnational School, Khachrod(M.P.) appearing for the AISSCE-2020 of CBSE, New Delhi has worked under my supervision by showing a great interest and completed her project to my total satisfaction. The project work is certified to be an original and bonafide work.
68
69The work and conduct of Aqsa Khan during the completion of her project was excellent.
70
71
72
73
74Roll No. :-
75Class :-
76
77
78 __________________ _________________
79 Signature of External Signature of Teacher
80
81
82
83
84
85
86
87
88
89
90
91
92ACKNOWLEGMENT
93
94I Aqsa khan of class XII would sincerely like to thank Mr. NarendraMahawar, my Informatics Practices teacher who has a constant source of inspirations and guidance throughout the project worth.
95
96I am highly indebted to my Informatics Practicesteacher for his guidance and constant supervision as well as for providing necessary information regarding the project and also for his support in completing the project.
97
98I would also like to thank my Principal Mr. Kritesh Sharma who has encouraged in general the Informatics PracticesStudents to be analytical in solving the problems.
99
100
101
102 With Thanks
103Signature Aqsa Khan
104
105INTRODUCTION
106
107Simple Quiz App in Python
108
109
110A quiz is a form of game or mind sport, in which the players (as individuals or in teams) attempt to answer questions correctly. It is a game to test the knowledge about a certain subject. In some countries, a quiz is also a brief assessment used in education and similar fields to measure growth in knowledge, abilities, and/or skills.
111
112AIM
113The Simple Quiz App in Python is a simple project for testing one’s knowledge power in the given topic examination. The project contains only the user side. The user must log in or sign up first to start the quiz. Also, there is a time duration set for solving the questions. The user should solve the questions before time is up.
114About System
115The project file contains python scripts (quiz.py) and database files. This app project just contains the user section. The user can log in to give the exam. After giving the exam, the user can see their score and evaluate them. The design of this project is pretty simple so that the user won’t find any difficulties while working on it.
116
117System Requirements:
118• Python
119• Tkinterface
120How To Run The Project?
121To run this project, you must have installed Python on your PC.
122Step: Go inside the project folder, open cmd then type quiz.py and enter to start the system.
123OR
124Step: Simply, double click the quiz.py file and you are ready to go.
125PROGRAM LISTINGS/ CODING OF PROJECT WITH OUTPUT
126
127import tkinter as tk
128from tkinter import *
129import random
130import sqlite3
131import time
132
133defloginPage(logdata):
134sup.destroy()
135 global login
136 login = Tk()
137
138user_name = StringVar()
139 password = StringVar()
140
141login_canvas = Canvas(login,width=720,height=440,bg="#101357")
142login_canvas.pack()
143
144login_frame = Frame(login_canvas,bg="white")
145login_frame.place(relwidth=0.8,relheight=0.8,relx=0.1,rely=0.1)
146
147 heading = Label(login_frame,text="Quiz App Login",fg="black",bg="white")
148heading.config(font=('calibri 40'))
149heading.place(relx=0.2,rely=0.1)
150
151
152
153 #USER NAME
154ulabel = Label(login_frame,text="Username",fg='black',bg='white')
155ulabel.place(relx=0.21,rely=0.4)
156uname = Entry(login_frame,bg='#d3d3d3',fg='white',textvariable = user_name)
157uname.config(width=42)
158uname.place(relx=0.31,rely=0.4)
159
160 #PASSWORD
161plabel = Label(login_frame,text="Password",fg='black',bg='white')
162plabel.place(relx=0.215,rely=0.5)
163 pas = Entry(login_frame,bg='#d3d3d3',fg='white',textvariable = password)
164pas.config(width=42)
165pas.place(relx=0.31,rely=0.5)
166
167def check():
168 for a,b,c,d in logdata:
169 if b == uname.get() and c == pas.get():
170 menu()
171 break
172 else:
173 error = Label(login_frame,text="Wrong Username or Password!",fg='black',bg='white')
174error.place(relx=0.37,rely=0.7)
175
176 #LOGIN BUTTON
177 log = Button(login_frame,text='Login',padx=5,pady=5,width=5,command=check)
178log.configure(width = 15,height=1, activebackground = "#33B5E5", relief = FLAT)
179log.place(relx=0.4,rely=0.6)
180
181
182login.mainloop()
183
184
185
186
187
188defsignUpPage():
189root.destroy()
190 global sup
191 sup = Tk()
192
193fname = StringVar()
194uname = StringVar()
195passW = StringVar()
196 country = StringVar()
197
198
199sup_canvas = Canvas(sup,width=720,height=440,bg="#101357")
200sup_canvas.pack()
201
202sup_frame = Frame(sup_canvas,bg="white")
203sup_frame.place(relwidth=0.8,relheight=0.8,relx=0.1,rely=0.1)
204
205 heading = Label(sup_frame,text="Quiz App SignUp",fg="black",bg="white")
206heading.config(font=('calibri 40'))
207heading.place(relx=0.2,rely=0.1)
208
209 #full name
210flabel = Label(sup_frame,text="Full Name",fg='black',bg='white')
211flabel.place(relx=0.21,rely=0.4)
212fname = Entry(sup_frame,bg='#d3d3d3',fg='white',textvariable = fname)
213fname.config(width=42)
214fname.place(relx=0.31,rely=0.4)
215
216 #username
217ulabel = Label(sup_frame,text="Username",fg='black',bg='white')
218ulabel.place(relx=0.21,rely=0.5)
219 user = Entry(sup_frame,bg='#d3d3d3',fg='white',textvariable = uname)
220user.config(width=42)
221user.place(relx=0.31,rely=0.5)
222
223
224 #password
225plabel = Label(sup_frame,text="Password",fg='black',bg='white')
226plabel.place(relx=0.215,rely=0.6)
227 pas = Entry(sup_frame,bg='#d3d3d3',fg='white',textvariable = passW)
228pas.config(width=42)
229pas.place(relx=0.31,rely=0.6)
230
231
232
233 #country
234clabel = Label(sup_frame,text="Country",fg='black',bg='white')
235clabel.place(relx=0.215,rely=0.7)
236 c = Entry(sup_frame,bg='#d3d3d3',fg='white',textvariable = country)
237c.config(width=42)
238c.place(relx=0.31,rely=0.7)
239defaddUserToDataBase():
240
241fullname = fname.get()
242 username = user.get()
243 password = pas.get()
244 country = c.get()
245
246 conn = sqlite3.connect('quiz.db')
247 create = conn.cursor()
248create.execute('CREATE TABLE IF NOT EXISTS userSignUp(FULLNAME text, USERNAME text,PASSWORDtext,COUNTRY text)')
249create.execute("INSERT INTO userSignUp VALUES (?,?,?,?)",(fullname,username,password,country))
250conn.commit()
251create.execute('SELECT * FROM userSignUp')
252 z=create.fetchall()
253 print(z)
254# L2.config(text="Username is "+z[0][0]+"\nPassword is "+z[-1][1])
255conn.close()
256loginPage(z)
257defgotoLogin():
258 conn = sqlite3.connect('quiz.db')
259 create = conn.cursor()
260conn.commit()
261create.execute('SELECT * FROM userSignUp')
262 z=create.fetchall()
263loginPage(z)
264 #signup BUTTON
265sp = Button(sup_frame,text='SignUp',padx=5,pady=5,width=5,command = addUserToDataBase)
266sp.configure(width = 15,height=1, activebackground = "#33B5E5", relief = FLAT)
267sp.place(relx=0.4,rely=0.8)
268
269 log = Button(sup_frame,text='Already have a Account?',padx=5,pady=5,width=5,command = gotoLogin,bg="white")
270log.configure(width = 16,height=1, activebackground = "#33B5E5", relief = FLAT)
271log.place(relx=0.4,rely=0.9)
272
273sup.mainloop()
274
275
276
277def menu():
278login.destroy()
279 global menu
280 menu = Tk()
281
282
283menu_canvas = Canvas(menu,width=720,height=440,bg="#101357")
284menu_canvas.pack()
285
286menu_frame = Frame(menu_canvas,bg="white")
287menu_frame.place(relwidth=0.8,relheight=0.8,relx=0.1,rely=0.1)
288
289
290
291wel = 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")
292wel.config(font=('Broadway 22'))
293wel.place(relx=0.1,rely=0.02)
294
295
296
297
298
299 level = Label(menu_frame,text='Select your Difficulty Level !!',bg="white",font="calibri 18")
300level.place(relx=0.25,rely=0.3)
301
302
303var = IntVar()
304easyR = Radiobutton(menu_frame,text='Easy',bg="white",font="calibri 16",value=1,variable = var)
305easyR.place(relx=0.25,rely=0.4)
306
307mediumR = Radiobutton(menu_frame,text='Medium',bg="white",font="calibri 16",value=2,variable = var)
308mediumR.place(relx=0.25,rely=0.5)
309
310hardR = Radiobutton(menu_frame,text='Hard',bg="white",font="calibri 16",value=3,variable = var)
311hardR.place(relx=0.25,rely=0.6)
312
313
314def navigate():
315
316 x = var.get()
317 print(x)
318 if x == 1:
319menu.destroy()
320 easy()
321elif x == 2:
322menu.destroy()
323 medium()
324
325elif x == 3:
326menu.destroy()
327 difficult()
328 else:
329 pass
330
331
332
333letsgo = Button(menu_frame,text="Let's Go",bg="white",font="calibri 12",command=navigate)
334letsgo.place(relx=0.25,rely=0.8)
335menu.mainloop()
336def easy():
337
338 global e
339 e = Tk()
340
341easy_canvas = Canvas(e,width=720,height=440,bg="#101357")
342easy_canvas.pack()
343
344easy_frame = Frame(easy_canvas,bg="white")
345easy_frame.place(relwidth=0.8,relheight=0.8,relx=0.1,rely=0.1)
346
347
348defcountDown():
349 check = 0
350for k in range(10, 0, -1):
351
352 if k == 1:
353 check=-1
354timer.configure(text=k)
355easy_frame.update()
356time.sleep(1)
357
358timer.configure(text="Times up!")
359 if check==-1:
360 return (-1)
361 else:
362 return 0
363 global score
364 score = 0
365
366easyQ = [
367 [
368 "What will be the output of the following Python code? \nl=[1, 0, 2, 0, 'hello', '', []] \nlist(filter(bool, nl))",
369 "[1, 0, 2, ‘hello’, '', []]",
370 "Error",
371 "[1, 2, ‘hello’]",
372 "[1, 0, 2, 0, ‘hello’, '', []]"
373 ] ,
374 [
375 "What will be the output of the following Python expression if the value of x is 34? \nprint(“%f”%x)" ,
376 "34.00",
377 "34.000000",
378 "34.0000",
379 "34.00000000"
380
381 ],
382 [
383 "What will be the value of X in the following Python expression? \nX = 2+9*((3*12)-8)/10" ,
384 "30.8",
385 "27.2",
386 "28.4",
387 "30.0"
388 ],
389 [
390 "Which of these in not a core data type?" ,
391 "Tuples",
392 "Dictionary",
393 "Lists",
394 "Class"
395 ],
396 [
397 "Which of the following represents the bitwise XOR operator?" ,
398 "&",
399 "!",
400 "^",
401 "|"
402 ]
403 ]
404 answer = [
405 "[1, 2, ‘hello’]",
406 "34.000000",
407 "27.2",
408 "Class",
409 "^"
410 ]
411 li = ['',0,1,2,3,4]
412 x = random.choice(li[1:])
413
414ques = Label(easy_frame,text =easyQ[x][0],font="calibri 12",bg="white")
415ques.place(relx=0.5,rely=0.2,anchor=CENTER)
416
417var = StringVar()
418
419 a = Radiobutton(easy_frame,text=easyQ[x][1],font="calibri 10",value=easyQ[x][1],variable = var,bg="white")
420a.place(relx=0.5,rely=0.42,anchor=CENTER)
421
422 b = Radiobutton(easy_frame,text=easyQ[x][2],font="calibri 10",value=easyQ[x][2],variable = var,bg="white")
423b.place(relx=0.5,rely=0.52,anchor=CENTER)
424
425 c = Radiobutton(easy_frame,text=easyQ[x][3],font="calibri 10",value=easyQ[x][3],variable = var,bg="white")
426c.place(relx=0.5,rely=0.62,anchor=CENTER)
427
428 d = Radiobutton(easy_frame,text=easyQ[x][4],font="calibri 10",value=easyQ[x][4],variable = var,bg="white")
429d.place(relx=0.5,rely=0.72,anchor=CENTER)
430
431li.remove(x)
432
433 timer = Label(e)
434timer.place(relx=0.8,rely=0.82,anchor=CENTER)
435
436
437
438def display():
439
440 if len(li) == 1:
441e.destroy()
442showMark(score)
443 if len(li) == 2:
444nextQuestion.configure(text='End',command=calc)
445
446 if li:
447 x = random.choice(li[1:])
448ques.configure(text =easyQ[x][0])
449
450a.configure(text=easyQ[x][1],value=easyQ[x][1])
451
452b.configure(text=easyQ[x][2],value=easyQ[x][2])
453
454c.configure(text=easyQ[x][3],value=easyQ[x][3])
455
456d.configure(text=easyQ[x][4],value=easyQ[x][4])
457
458li.remove(x)
459 print(li)
460 y = countDown()
461 if y == -1:
462 display()
463
464
465defcalc():
466 global score
467 if (var.get() in answer):
468 score+=1
469 display()
470
471 submit = Button(easy_frame,command=calc,text="Submit")
472submit.place(relx=0.5,rely=0.82,anchor=CENTER)
473
474nextQuestion = Button(easy_frame,command=display,text="Next")
475nextQuestion.place(relx=0.87,rely=0.82,anchor=CENTER)
476
477 y = countDown()
478 if y == -1:
479 display()
480e.mainloop()
481
482
483def medium():
484
485 global m
486 m = Tk()
487
488med_canvas = Canvas(m,width=720,height=440,bg="#101357")
489med_canvas.pack()
490
491med_frame = Frame(med_canvas,bg="white")
492med_frame.place(relwidth=0.8,relheight=0.8,relx=0.1,rely=0.1)
493
494
495defcountDown():
496 check = 0
497for k in range(10, 0, -1):
498
499 if k == 1:
500 check=-1
501timer.configure(text=k)
502med_frame.update()
503time.sleep(1)
504
505timer.configure(text="Times up!")
506 if check==-1:
507 return (-1)
508 else:
509 return 0
510
511 global score
512 score = 0
513
514mediumQ = [
515 [
516 "Which of the following is not an exception handling keyword in Python?",
517 "accept",
518 "finally",
519 "except",
520 "try"
521 ],
522 [
523 "Suppose list1 is [3, 5, 25, 1, 3], what is min(list1)?",
524 "3",
525 "5",
526 "25",
527 "1"
528 ],
529 [
530 "Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1]?",
531 "Error",
532 "None",
533 "25",
534 "2"
535 ],
536 [
537 "print(0xA + 0xB + 0xC):",
538 "0xA0xB0xC",
539 "Error",
540 "0x22",
541 "33"
542 ],
543 [
544 "Which of the following is invalid?",
545 "_a = 1",
546 "__a = 1",
547 "__str__ = 1",
548 "none of the mentioned"
549 ],
550 ]
551 answer = [
552 "accept",
553 "1",
554 "25",
555 "33",
556 "none of the mentioned"
557 ]
558
559 li = ['',0,1,2,3,4]
560 x = random.choice(li[1:])
561
562ques = Label(med_frame,text =mediumQ[x][0],font="calibri 12",bg="white")
563ques.place(relx=0.5,rely=0.2,anchor=CENTER)
564
565var = StringVar()
566
567 a = Radiobutton(med_frame,text=mediumQ[x][1],font="calibri 10",value=mediumQ[x][1],variable = var,bg="white")
568a.place(relx=0.5,rely=0.42,anchor=CENTER)
569
570 b = Radiobutton(med_frame,text=mediumQ[x][2],font="calibri 10",value=mediumQ[x][2],variable = var,bg="white")
571b.place(relx=0.5,rely=0.52,anchor=CENTER)
572
573 c = Radiobutton(med_frame,text=mediumQ[x][3],font="calibri 10",value=mediumQ[x][3],variable = var,bg="white")
574c.place(relx=0.5,rely=0.62,anchor=CENTER)
575
576 d = Radiobutton(med_frame,text=mediumQ[x][4],font="calibri 10",value=mediumQ[x][4],variable = var,bg="white")
577d.place(relx=0.5,rely=0.72,anchor=CENTER)
578
579li.remove(x)
580
581 timer = Label(m)
582timer.place(relx=0.8,rely=0.82,anchor=CENTER)
583
584
585
586def display():
587
588 if len(li) == 1:
589m.destroy()
590showMark(score)
591 if len(li) == 2:
592nextQuestion.configure(text='End',command=calc)
593
594 if li:
595 x = random.choice(li[1:])
596ques.configure(text =mediumQ[x][0])
597
598a.configure(text=mediumQ[x][1],value=mediumQ[x][1])
599
600b.configure(text=mediumQ[x][2],value=mediumQ[x][2])
601
602c.configure(text=mediumQ[x][3],value=mediumQ[x][3])
603
604d.configure(text=mediumQ[x][4],value=mediumQ[x][4])
605
606li.remove(x)
607 print(li)
608 y = countDown()
609 if y == -1:
610 display()
611
612
613defcalc():
614 global score
615 if (var.get() in answer):
616 score+=1
617 display()
618
619 submit = Button(med_frame,command=calc,text="Submit")
620submit.place(relx=0.5,rely=0.82,anchor=CENTER)
621
622nextQuestion = Button(med_frame,command=display,text="Next")
623nextQuestion.place(relx=0.87,rely=0.82,anchor=CENTER)
624
625 y = countDown()
626 if y == -1:
627 display()
628m.mainloop()
629def difficult():
630
631
632 global h
633 h = Tk()
634
635hard_canvas = Canvas(h,width=720,height=440,bg="#101357")
636hard_canvas.pack()
637
638hard_frame = Frame(hard_canvas,bg="white")
639hard_frame.place(relwidth=0.8,relheight=0.8,relx=0.1,rely=0.1)
640
641
642defcountDown():
643 check = 0
644for k in range(10, 0, -1):
645
646 if k == 1:
647 check=-1
648timer.configure(text=k)
649hard_frame.update()
650time.sleep(1)
651
652timer.configure(text="Times up!")
653 if check==-1:
654 return (-1)
655 else:
656 return 0
657
658 global score
659 score = 0
660
661hardQ = [
662 [
663 "All keywords in Python are in _________",
664 "lower case",
665 "UPPER CASE",
666 "Capitalized",
667 "None of the mentioned"
668 ],
669 [
670 "Which of the following cannot be a variable?",
671 "__init__",
672 "in",
673 "it",
674 "on"
675 ],
676 [
677 "Which of the following is a Python tuple?",
678 "[1, 2, 3]",
679 "(1, 2, 3)",
680 "{1, 2, 3}",
681 "{}"
682 ],
683 [
684 "What is returned by math.ceil(3.4)?",
685 "3",
686 "4",
687 "4.0",
688 "3.0"
689 ],
690 [
691 "What will be the output of print(math.factorial(4.5))?",
692 "24",
693 "120",
694 "error",
695 "24.0"
696 ]
697
698]
699 answer = [
700 "None of the mentioned",
701 "in",
702 "(1,2,3)",
703 "4",
704 "error"
705 ]
706
707 li = ['',0,1,2,3,4]
708 x = random.choice(li[1:])
709
710ques = Label(hard_frame,text =hardQ[x][0],font="calibri 12",bg="white")
711ques.place(relx=0.5,rely=0.2,anchor=CENTER)
712
713var = StringVar()
714
715 a = Radiobutton(hard_frame,text=hardQ[x][1],font="calibri 10",value=hardQ[x][1],variable = var,bg="white")
716a.place(relx=0.5,rely=0.42,anchor=CENTER)
717
718 b = Radiobutton(hard_frame,text=hardQ[x][2],font="calibri 10",value=hardQ[x][2],variable = var,bg="white")
719b.place(relx=0.5,rely=0.52,anchor=CENTER)
720
721 c = Radiobutton(hard_frame,text=hardQ[x][3],font="calibri 10",value=hardQ[x][3],variable = var,bg="white")
722c.place(relx=0.5,rely=0.62,anchor=CENTER)
723
724 d = Radiobutton(hard_frame,text=hardQ[x][4],font="calibri 10",value=hardQ[x][4],variable = var,bg="white")
725d.place(relx=0.5,rely=0.72,anchor=CENTER)
726
727li.remove(x)
728
729 timer = Label(h)
730timer.place(relx=0.8,rely=0.82,anchor=CENTER)
731
732
733
734def display():
735
736 if len(li) == 1:
737h.destroy()
738showMark(score)
739 if len(li) == 2:
740nextQuestion.configure(text='End',command=calc)
741
742 if li:
743 x = random.choice(li[1:])
744ques.configure(text =hardQ[x][0])
745
746a.configure(text=hardQ[x][1],value=hardQ[x][1])
747
748b.configure(text=hardQ[x][2],value=hardQ[x][2])
749
750c.configure(text=hardQ[x][3],value=hardQ[x][3])
751
752d.configure(text=hardQ[x][4],value=hardQ[x][4])
753
754li.remove(x)
755 print(li)
756 y = countDown()
757 if y == -1:
758 display()
759
760
761defcalc():
762 global score
763 if (var.get() in answer):
764 score+=1
765 display()
766
767 submit = Button(hard_frame,command=calc,text="Submit")
768submit.place(relx=0.5,rely=0.82,anchor=CENTER)
769
770nextQuestion = Button(hard_frame,command=display,text="Next")
771nextQuestion.place(relx=0.87,rely=0.82,anchor=CENTER)
772
773 y = countDown()
774 if y == -1:
775 display()
776h.mainloop()
777
778
779defshowMark(mark):
780 global sh
781sh = Tk()
782
783show_canvas = Canvas(sh,width=720,height=440,bg="#101357")
784show_canvas.pack()
785
786show_frame = Frame(show_canvas,bg="white")
787show_frame.place(relwidth=0.8,relheight=0.8,relx=0.1,rely=0.1)
788
789st = "Your score is "+str(mark)
790mlabel = Label(show_canvas,text=st,fg="black")
791mlabel.place(relx=0.5,rely=0.2,anchor=CENTER)
792
793sh.mainloop()
794def start():
795 global root
796 root = Tk()
797 canvas = Canvas(root,width = 720,height = 440, bg = 'yellow')
798canvas.grid(column = 0 , row = 1)
799img = PhotoImage(file="output-onlinepngtools.png")
800canvas.create_image(50,10,image=img,anchor=NW)
801
802 button = Button(root, text='Start',command = signUpPage)
803button.configure(width = 102,height=2, activebackground = "#33B5E5", relief = RAISED)
804button.grid(column = 0 , row = 2)
805
806root.mainloop()
807
808
809if __name__=='__main__':
810 start()
811
812
813
814
815CONCLUSION
816
817“QUIZ” software developed for a school or to a college has been designed for time reduction taken for conducting a quiz, for calculating the marks, for shortlisting the student’s name, hence increasing the efficiency. It is designed to replace an existing paper work and correction manually. The system uses VB .Net as front end and Microsoft SQL as a backend for the database. The implementation of the system in the organization will considerably reduce time and also provide readily calculated marks.