Easy_Flex

Untitled

Apr 28th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 28.24 KB | None | 0 0
  1. import tkinter
  2. from tkinter import *
  3. import random
  4.  
  5. # Sample Questions
  6.  
  7. gmat = [
  8.     "This is a sample gmat question 1",
  9.     "This is a sample gmat question 2",
  10.     "This is a sample gmat question 3",
  11.     "This is a sample gmat question 4",
  12.     "This is a sample gmat question 5",
  13.     "This is a sample gmat question 6",
  14.     "This is a sample gmat question 7",
  15.     "This is a sample gmat question 8",
  16.     "This is a sample gmat question 9",
  17.     "This is a sample gmat question 10",
  18.     "This is a sample gmat question 11",
  19.     "This is a sample gmat question 12",
  20.     "This is a sample gmat question 13",
  21.     "This is a sample gmat question 14",
  22.     "This is a sample gmat question 15"
  23. ]
  24.  
  25. gmat_answers = [
  26.     ["A", "B", "C", "D"],
  27.     ["A", "B", "C", "D"],
  28.     ["A", "B", "C", "D"],
  29.     ["A", "B", "C", "D"],
  30.     ["A", "B", "C", "D"],
  31.     ["A", "B", "C", "D"],
  32.     ["A", "B", "C", "D"],
  33.     ["A", "B", "C", "D"],
  34.     ["A", "B", "C", "D"],
  35.     ["A", "B", "C", "D"],
  36.     ["A", "B", "C", "D"],
  37.     ["A", "B", "C", "D"],
  38.     ["A", "B", "C", "D"],
  39.     ["A", "B", "C", "D"],
  40.     ["A", "B", "C", "D"],
  41.     ["A", "B", "C", "D"]
  42. ]
  43.  
  44. toefl = [
  45.     "This is a sample toefl question 1",
  46.     "This is a sample toefl question 2",
  47.     "This is a sample toefl question 3",
  48.     "This is a sample toefl question 4",
  49.     "This is a sample toefl question 5",
  50.     "This is a sample toefl question 6",
  51.     "This is a sample toefl question 7",
  52.     "This is a sample toefl question 8",
  53.     "This is a sample toefl question 9",
  54.     "This is a sample toefl question 10",
  55.     "This is a sample toefl question 11",
  56.     "This is a sample toefl question 12",
  57.     "This is a sample toefl question 13",
  58.     "This is a sample toefl question 14",
  59.     "This is a sample toefl question 15"
  60. ]
  61.  
  62. toefl_answers = [
  63.     ["A", "B", "C", "D"],
  64.     ["A", "B", "C", "D"],
  65.     ["A", "B", "C", "D"],
  66.     ["A", "B", "C", "D"],
  67.     ["A", "B", "C", "D"],
  68.     ["A", "B", "C", "D"],
  69.     ["A", "B", "C", "D"],
  70.     ["A", "B", "C", "D"],
  71.     ["A", "B", "C", "D"],
  72.     ["A", "B", "C", "D"],
  73.     ["A", "B", "C", "D"],
  74.     ["A", "B", "C", "D"],
  75.     ["A", "B", "C", "D"],
  76.     ["A", "B", "C", "D"],
  77.     ["A", "B", "C", "D"]
  78. ]
  79.  
  80. jamb = {
  81.     "Chemistry": [
  82.         "This is a sample Chemistry question 1",
  83.         "This is a sample Chemistry question 2",
  84.         "This is a sample Chemistry question 3",
  85.         "This is a sample Chemistry question 4",
  86.         "This is a sample Chemistry question 5",
  87.         "This is a sample Chemistry question 6",
  88.         "This is a sample Chemistry question 7",
  89.         "This is a sample Chemistry question 8",
  90.         "This is a sample Chemistry question 9",
  91.         "This is a sample Chemistry question 10",
  92.         "This is a sample Chemistry question 11",
  93.         "This is a sample Chemistry question 12",
  94.         "This is a sample Chemistry question 13",
  95.         "This is a sample Chemistry question 14",
  96.         "This is a sample Chemistry question 15",
  97.     ],
  98.     "Biology": [
  99.         "This is a sample Biology question 1",
  100.         "This is a sample Biology question 2",
  101.         "This is a sample Biology question 3",
  102.         "This is a sample Biology question 4",
  103.         "This is a sample Biology question 5",
  104.         "This is a sample Biology question 6",
  105.         "This is a sample Biology question 7",
  106.         "This is a sample Biology question 8",
  107.         "This is a sample Biology question 9",
  108.         "This is a sample Biology question 10",
  109.         "This is a sample Biology question 11",
  110.         "This is a sample Biology question 12",
  111.         "This is a sample Biology question 13",
  112.         "This is a sample Biology question 14",
  113.         "This is a sample Biology question 15"
  114.     ],
  115.     "Physics": [
  116.         "This is a sample Physics question 1",
  117.         "This is a sample Physics question 2",
  118.         "This is a sample Physics question 3",
  119.         "This is a sample Physics question 4",
  120.         "This is a sample Physics question 5",
  121.         "This is a sample Physics question 6",
  122.         "This is a sample Physics question 7",
  123.         "This is a sample Physics question 8",
  124.         "This is a sample Physics question 9",
  125.         "This is a sample Physics question 10",
  126.         "This is a sample Physics question 11",
  127.         "This is a sample Physics question 12",
  128.         "This is a sample Physics question 13",
  129.         "This is a sample Physics question 14",
  130.         "This is a sample Physics question 15"
  131.     ],
  132.     "Mathematics": [
  133.         "This is a sample Mathematics question 1",
  134.         "This is a sample Mathematics question 2",
  135.         "This is a sample Mathematics question 3",
  136.         "This is a sample Mathematics question 4",
  137.         "This is a sample Mathematics question 5",
  138.         "This is a sample Mathematics question 6",
  139.         "This is a sample Mathematics question 7",
  140.         "This is a sample Mathematics question 8",
  141.         "This is a sample Mathematics question 9",
  142.         "This is a sample Mathematics question 10",
  143.         "This is a sample Mathematics question 11",
  144.         "This is a sample Mathematics question 12",
  145.         "This is a sample Mathematics question 13",
  146.         "This is a sample Mathematics question 14",
  147.         "This is a sample Mathematics question 15"
  148.     ],
  149.     "English": [
  150.         "This is a sample English question 1",
  151.         "This is a sample English question 2",
  152.         "This is a sample English question 3",
  153.         "This is a sample English question 4",
  154.         "This is a sample English question 5",
  155.         "This is a sample English question 6",
  156.         "This is a sample English question 7",
  157.         "This is a sample English question 8",
  158.         "This is a sample English question 9",
  159.         "This is a sample English question 10",
  160.         "This is a sample English question 11",
  161.         "This is a sample English question 12",
  162.         "This is a sample English question 13",
  163.         "This is a sample English question 14",
  164.         "This is a sample English question 15"
  165.     ],
  166.     "Government": [
  167.         "This is a sample Government question 1",
  168.         "This is a sample Government question 2",
  169.         "This is a sample Government question 3",
  170.         "This is a sample Government question 4",
  171.         "This is a sample Government question 5",
  172.         "This is a sample Government question 6",
  173.         "This is a sample Government question 7",
  174.         "This is a sample Government question 8",
  175.         "This is a sample Government question 9",
  176.         "This is a sample Government question 10",
  177.         "This is a sample Government question 11",
  178.         "This is a sample Government question 12",
  179.         "This is a sample Government question 13",
  180.         "This is a sample Government question 14",
  181.         "This is a sample Government question 15"
  182.     ],
  183.     "Agricultural Science": [
  184.         "This is a sample Agricultural Science question 1",
  185.         "This is a sample Agricultural Science question 2",
  186.         "This is a sample Agricultural Science question 3",
  187.         "This is a sample Agricultural Science question 4",
  188.         "This is a sample Agricultural Science question 5",
  189.         "This is a sample Agricultural Science question 6",
  190.         "This is a sample Agricultural Science question 7",
  191.         "This is a sample Agricultural Science question 8",
  192.         "This is a sample Agricultural Science question 9",
  193.         "This is a sample Agricultural Science question 10",
  194.         "This is a sample Agricultural Science question 11",
  195.         "This is a sample Agricultural Science question 12",
  196.         "This is a sample Agricultural Science question 13",
  197.         "This is a sample Agricultural Science question 14",
  198.         "This is a sample Agricultural Science question 15"
  199.     ],
  200.     "Economics": [
  201.         "This is a sample Economics question 1",
  202.         "This is a sample Economics question 2",
  203.         "This is a sample Economics question 3",
  204.         "This is a sample Economics question 4",
  205.         "This is a sample Economics question 5",
  206.         "This is a sample Economics question 6",
  207.         "This is a sample Economics question 7",
  208.         "This is a sample Economics question 8",
  209.         "This is a sample Economics question 9",
  210.         "This is a sample Economics question 10",
  211.         "This is a sample Economics question 11",
  212.         "This is a sample Economics question 12",
  213.         "This is a sample Economics question 13",
  214.         "This is a sample Economics question 14",
  215.         "This is a sample Economics question 15"
  216.     ],
  217.     "Christian Religious Knowledge": [
  218.         "This is a sample Christian Religious Knowledge question 1",
  219.         "This is a sample Christian Religious Knowledge question 2",
  220.         "This is a sample Christian Religious Knowledge question 3",
  221.         "This is a sample Christian Religious Knowledge question 4",
  222.         "This is a sample Christian Religious Knowledge question 5",
  223.         "This is a sample Christian Religious Knowledge question 6",
  224.         "This is a sample Christian Religious Knowledge question 7",
  225.         "This is a sample Christian Religious Knowledge question 8",
  226.         "This is a sample Christian Religious Knowledge question 9",
  227.         "This is a sample Christian Religious Knowledge question 10",
  228.         "This is a sample Christian Religious Knowledge question 11",
  229.         "This is a sample Christian Religious Knowledge question 12",
  230.         "This is a sample Christian Religious Knowledge question 13",
  231.         "This is a sample Christian Religious Knowledge question 14",
  232.         "This is a sample Christian Religious Knowledge question 15",
  233.     ]
  234. }
  235.  
  236. jamb_answers = {
  237.     "Chemistry": [
  238.         ["A", "B", "C", "D"],
  239.         ["A", "B", "C", "D"],
  240.         ["A", "B", "C", "D"],
  241.         ["A", "B", "C", "D"],
  242.         ["A", "B", "C", "D"],
  243.         ["A", "B", "C", "D"],
  244.         ["A", "B", "C", "D"],
  245.         ["A", "B", "C", "D"],
  246.         ["A", "B", "C", "D"],
  247.         ["A", "B", "C", "D"],
  248.         ["A", "B", "C", "D"],
  249.         ["A", "B", "C", "D"],
  250.         ["A", "B", "C", "D"],
  251.         ["A", "B", "C", "D"],
  252.         ["A", "B", "C", "D"]
  253.     ],
  254.     "Biology": [
  255.         ["A", "B", "C", "D"],
  256.         ["A", "B", "C", "D"],
  257.         ["A", "B", "C", "D"],
  258.         ["A", "B", "C", "D"],
  259.         ["A", "B", "C", "D"],
  260.         ["A", "B", "C", "D"],
  261.         ["A", "B", "C", "D"],
  262.         ["A", "B", "C", "D"],
  263.         ["A", "B", "C", "D"],
  264.         ["A", "B", "C", "D"],
  265.         ["A", "B", "C", "D"],
  266.         ["A", "B", "C", "D"],
  267.         ["A", "B", "C", "D"],
  268.         ["A", "B", "C", "D"],
  269.         ["A", "B", "C", "D"]
  270.     ],
  271.     "Physics": [
  272.         ["A", "B", "C", "D"],
  273.         ["A", "B", "C", "D"],
  274.         ["A", "B", "C", "D"],
  275.         ["A", "B", "C", "D"],
  276.         ["A", "B", "C", "D"],
  277.         ["A", "B", "C", "D"],
  278.         ["A", "B", "C", "D"],
  279.         ["A", "B", "C", "D"],
  280.         ["A", "B", "C", "D"],
  281.         ["A", "B", "C", "D"],
  282.         ["A", "B", "C", "D"],
  283.         ["A", "B", "C", "D"],
  284.         ["A", "B", "C", "D"],
  285.         ["A", "B", "C", "D"],
  286.         ["A", "B", "C", "D"]
  287.     ],
  288.     "Mathematics": [
  289.         ["A", "B", "C", "D"],
  290.         ["A", "B", "C", "D"],
  291.         ["A", "B", "C", "D"],
  292.         ["A", "B", "C", "D"],
  293.         ["A", "B", "C", "D"],
  294.         ["A", "B", "C", "D"],
  295.         ["A", "B", "C", "D"],
  296.         ["A", "B", "C", "D"],
  297.         ["A", "B", "C", "D"],
  298.         ["A", "B", "C", "D"],
  299.         ["A", "B", "C", "D"],
  300.         ["A", "B", "C", "D"],
  301.         ["A", "B", "C", "D"],
  302.         ["A", "B", "C", "D"],
  303.         ["A", "B", "C", "D"]
  304.     ],
  305.     "English": [
  306.         ["A", "B", "C", "D"],
  307.         ["A", "B", "C", "D"],
  308.         ["A", "B", "C", "D"],
  309.         ["A", "B", "C", "D"],
  310.         ["A", "B", "C", "D"],
  311.         ["A", "B", "C", "D"],
  312.         ["A", "B", "C", "D"],
  313.         ["A", "B", "C", "D"],
  314.         ["A", "B", "C", "D"],
  315.         ["A", "B", "C", "D"],
  316.         ["A", "B", "C", "D"],
  317.         ["A", "B", "C", "D"],
  318.         ["A", "B", "C", "D"],
  319.         ["A", "B", "C", "D"],
  320.         ["A", "B", "C", "D"]
  321.     ],
  322.     "Government": [
  323.         ["A", "B", "C", "D"],
  324.         ["A", "B", "C", "D"],
  325.         ["A", "B", "C", "D"],
  326.         ["A", "B", "C", "D"],
  327.         ["A", "B", "C", "D"],
  328.         ["A", "B", "C", "D"],
  329.         ["A", "B", "C", "D"],
  330.         ["A", "B", "C", "D"],
  331.         ["A", "B", "C", "D"],
  332.         ["A", "B", "C", "D"],
  333.         ["A", "B", "C", "D"],
  334.         ["A", "B", "C", "D"],
  335.         ["A", "B", "C", "D"],
  336.         ["A", "B", "C", "D"],
  337.         ["A", "B", "C", "D"]
  338.     ],
  339.     "Agricultural Science": [
  340.         ["A", "B", "C", "D"],
  341.         ["A", "B", "C", "D"],
  342.         ["A", "B", "C", "D"],
  343.         ["A", "B", "C", "D"],
  344.         ["A", "B", "C", "D"],
  345.         ["A", "B", "C", "D"],
  346.         ["A", "B", "C", "D"],
  347.         ["A", "B", "C", "D"],
  348.         ["A", "B", "C", "D"],
  349.         ["A", "B", "C", "D"],
  350.         ["A", "B", "C", "D"],
  351.         ["A", "B", "C", "D"],
  352.         ["A", "B", "C", "D"],
  353.         ["A", "B", "C", "D"],
  354.         ["A", "B", "C", "D"]
  355.     ],
  356.     "Economics": [
  357.         ["A", "B", "C", "D"],
  358.         ["A", "B", "C", "D"],
  359.         ["A", "B", "C", "D"],
  360.         ["A", "B", "C", "D"],
  361.         ["A", "B", "C", "D"],
  362.         ["A", "B", "C", "D"],
  363.         ["A", "B", "C", "D"],
  364.         ["A", "B", "C", "D"],
  365.         ["A", "B", "C", "D"],
  366.         ["A", "B", "C", "D"],
  367.         ["A", "B", "C", "D"],
  368.         ["A", "B", "C", "D"],
  369.         ["A", "B", "C", "D"],
  370.         ["A", "B", "C", "D"],
  371.         ["A", "B", "C", "D"]
  372.     ],
  373.     "Christian Religious knowledge": [
  374.         ["A", "B", "C", "D"],
  375.         ["A", "B", "C", "D"],
  376.         ["A", "B", "C", "D"],
  377.         ["A", "B", "C", "D"],
  378.         ["A", "B", "C", "D"],
  379.         ["A", "B", "C", "D"],
  380.         ["A", "B", "C", "D"],
  381.         ["A", "B", "C", "D"],
  382.         ["A", "B", "C", "D"],
  383.         ["A", "B", "C", "D"],
  384.         ["A", "B", "C", "D"],
  385.         ["A", "B", "C", "D"],
  386.         ["A", "B", "C", "D"],
  387.         ["A", "B", "C", "D"],
  388.         ["A", "B", "C", "D"]
  389.     ],
  390. }
  391.  
  392. waec = {}
  393.  
  394. user_answer = []
  395.  
  396. indexes = []
  397.  
  398. # Function to invoke the start button
  399.  
  400.  
  401. def startNow():
  402.     global btnStart
  403.     btnStart = Button(
  404.         root,
  405.         # image= img2,
  406.         foreground="#ffffff",
  407.         background="#000000",
  408.         text="START",
  409.         font=("Dark Ministry", 24),
  410.         relief=FLAT,
  411.         border=3,
  412.         width=50,
  413.         command=startIsPressed,
  414.     )
  415.     btnStart.pack(pady=(400, 0), padx=(0, 30))
  416.  
  417. # End of Function to invoke the start button
  418.  
  419. # Function to select quiz type and courses to be tested on
  420.  
  421.  
  422. def selectExam():
  423.     global quiz_type, answers, question
  424.     print("Welcome to Quiz Night")
  425.     quiz_type = input("What type of quiz would you like to take: \nJAMB\nWAEC\nGMAT\nTOEFL \n")
  426.  
  427.     if (quiz_type == "GMAT") or (quiz_type == "Gmat") or (quiz_type == "gmat"):
  428.         question = gmat
  429.         answers = gmat_answers
  430.  
  431.     elif (quiz_type == "TOEFL") or (quiz_type == "Toefl") or (quiz_type == "toefl"):
  432.         question = toefl
  433.         answers = toefl_answers
  434.  
  435.     # conditional statement to enter option of courses to be tested on if the quiz type selected is Jamb
  436.  
  437.     elif (quiz_type == "JAMB") or (quiz_type == "Jamb") or (quiz_type == "jamb"):
  438.         print("Enter your 4 subject combination order")
  439.         sub1 = str.title(input("Enter your First subject: \n"))
  440.         sub2 = str.title(input("Enter your Second subject: \n"))
  441.         sub3 = str.title(input("Enter your Third subject: \n"))
  442.         sub4 = str.title(input("Enter your Fourth subject: \n"))
  443.         if sub1 and sub2 and sub3 and sub4 in jamb.keys():
  444.             questions = [jamb[sub1], jamb[sub2], jamb[sub3], jamb[sub4]]
  445.             question = []
  446.  
  447.             # for loop to convert the question and answer options of the selected courses from a dictionary to a list
  448.  
  449.             for intervals in questions:
  450.                 for stuffs in intervals:
  451.                     question.append(stuffs)
  452.             answer = [jamb_answers[sub1], jamb_answers[sub2], jamb_answers[sub3], jamb_answers[sub4]]
  453.             answers = []
  454.             for ans in answer:
  455.                 for stiffs in ans:
  456.                     answers.append(stiffs)
  457.  
  458.         elif sub1 or sub2 or sub3 or sub4 not in jamb.keys():
  459.             print("You have entered a wrong course. please enter the correct course combination")
  460.  
  461.             # loop to ensure the courses entered are in the list of questions available in the jamb quiz
  462.  
  463.             while sub1 or sub2 or sub3 or sub4 not in jamb.keys():
  464.                 sub1 = str.title(input("Enter your First subject: \n"))
  465.                 sub2 = str.title(input("Enter your Second subject: \n"))
  466.                 sub3 = str.title(input("Enter your Third subject: \n"))
  467.                 sub4 = str.title(input("Enter your Fourth subject: \n"))
  468.                 if sub1 and sub2 and sub3 and sub4 in jamb.keys():
  469.                     break
  470.  
  471.             # for loop to convert the question and answer options of the selected courses from a dictionary to a list
  472.  
  473.             questions = [jamb[sub1], jamb[sub2], jamb[sub3], jamb[sub4]]
  474.             question = []
  475.             for intervals in questions:
  476.                 for stuffs in intervals:
  477.                     question.append(stuffs)
  478.             answer = [jamb_answers[sub1], jamb_answers[sub2], jamb_answers[sub3], jamb_answers[sub4]]
  479.             answers = []
  480.             for ans in answer:
  481.                 for stiffs in ans:
  482.                     answers.append(stiffs)
  483.  
  484.     # conditional statement to enter option of courses to be tested on if the quiz type selected is waec
  485.  
  486.     elif (quiz_type == "WAEC") or (quiz_type == "Waec") or (quiz_type == "waec"):
  487.         print("Enter your 9 subject combination order")
  488.         sub1 = str.title(input("Enter your First subject: \n"))
  489.         sub2 = str.title(input("Enter your Second subject: \n"))
  490.         sub3 = str.title(input("Enter your Third subject: \n"))
  491.         sub4 = str.title(input("Enter your Fourth subject: \n"))
  492.         sub5 = str.title(input("Enter your Fourth subject: \n"))
  493.         sub6 = str.title(input("Enter your Fourth subject: \n"))
  494.         sub7 = str.title(input("Enter your Fourth subject: \n"))
  495.         sub8 = str.title(input("Enter your Fourth subject: \n"))
  496.         sub9 = str.title(input("Enter your Fourth subject: \n"))
  497.         if sub1 and sub2 and sub3 and sub4 and sub5 and sub6 and sub7 and sub8 and sub9 in waec.keys():
  498.             questions = [waec[sub1], waec[sub2], waec[sub3], waec[sub4], waec[sub5],
  499.                          waec[sub6], waec[sub7], waec[sub8], waec[sub9]]
  500.             question = []
  501.  
  502.             # for loop to convert the question and answer options of the selected courses from a dictionary to a list
  503.  
  504.             for intervals in questions:
  505.                 for stuffs in intervals:
  506.                     question.append(stuffs)
  507.             answer = [waec[sub1], waec[sub2], waec[sub3], waec[sub4], waec[sub5],
  508.                       waec[sub6], waec[sub7], waec[sub8], waec[sub9]]
  509.             answers = []
  510.             for ans in answer:
  511.                 for stiffs in ans:
  512.                     answers.append(stiffs)
  513.  
  514.         elif sub1 and sub2 and sub3 and sub4 and sub5 and sub6 and sub7 and sub8 and sub9 not in waec.keys():
  515.  
  516.             # loop to ensure the courses entered are in the list of questions available in the jamb quiz
  517.  
  518.             while sub1 or sub2 or sub3 or sub4 not in jamb.keys():
  519.                 print("You have entered a wrong course. please enter the correct course combination")
  520.                 sub1 = str.title(input("Enter your First subject: \n"))
  521.                 sub2 = str.title(input("Enter your Second subject: \n"))
  522.                 sub3 = str.title(input("Enter your Third subject: \n"))
  523.                 sub4 = str.title(input("Enter your Fourth subject: \n"))
  524.                 sub5 = str.title(input("Enter your Fourth subject: \n"))
  525.                 sub6 = str.title(input("Enter your Fourth subject: \n"))
  526.                 sub7 = str.title(input("Enter your Fourth subject: \n"))
  527.                 sub8 = str.title(input("Enter your Fourth subject: \n"))
  528.                 sub9 = str.title(input("Enter your Fourth subject: \n"))
  529.                 if sub1 and sub2 and sub3 and sub4 and sub5 and sub6 and sub7 and sub8 and sub9 in waec.keys():
  530.                     break
  531.  
  532.             questions = [waec[sub1], waec[sub2], waec[sub3], waec[sub4], waec[sub5],
  533.                          waec[sub6], waec[sub7], waec[sub8], waec[sub9]]
  534.             question = []
  535.  
  536.             # for loop to convert the question and answer options of the selected courses from a dictionary to a list
  537.  
  538.             for intervals in questions:
  539.                 for stuffs in intervals:
  540.                     question.append(stuffs)
  541.             answer = [waec[sub1], waec[sub2], waec[sub3], waec[sub4], waec[sub5],
  542.                       waec[sub6], waec[sub7], waec[sub8], waec[sub9]]
  543.             answers = []
  544.             for ans in answer:
  545.                 for stiffs in ans:
  546.                     answers.append(stiffs)
  547.  
  548.     labelmage.destroy()
  549.     labeltext.destroy()
  550.     lbInstruction.destroy()
  551.     lbRules.destroy()
  552.     btnQuiz.destroy()
  553.     startNow()
  554.  
  555. # End of Function to select quiz type and courses to be tested on
  556.  
  557. # Function to generate random questions and also to determine the number of questions to display for each quiz type
  558.  
  559.  
  560. def gen():
  561.     global indexes, quiz_type
  562.  
  563. # Conditional statement to determine the number of question and also
  564.     # to generate the questions randomly for GMAT and TOEFL Questions
  565.  
  566.     if (((quiz_type == "GMAT") or (quiz_type == "Gmat") or (quiz_type == "gmat")) or ((quiz_type == "TOEFL") or
  567.         (quiz_type == "Toefl") or (quiz_type == "toefl"))):
  568.         while len(indexes) <= 10:
  569.             x = random.randint(0, 14)
  570.             if x in indexes:
  571.                 continue
  572.             else:
  573.                 indexes.append(x)
  574.  
  575. # Conditional statement to determine the number of question and also
  576.     # to generate the questions randomly for JAMB Questions
  577.  
  578.     elif (quiz_type == "JAMB") or (quiz_type != "Jamb") or (quiz_type == "jamb"):
  579.         while len(indexes) <= 40:
  580.             x = random.randint(0, 59)
  581.             if x in indexes:
  582.                 continue
  583.             else:
  584.                 indexes.append(x)
  585.  
  586. # Conditional ststement to determine the number of question and also
  587.     # to generate the questions randomly for WAEC Questions
  588.  
  589.     elif (quiz_type == "WAEC") or (quiz_type == "Waec") or (quiz_type == "waec"):
  590.         while len(indexes) <= 90:
  591.             x = random.randint(0, 134)
  592.             if x in indexes:
  593.                 continue
  594.             else:
  595.                 indexes.append(x)
  596.  
  597.  
  598. # End of Function to generate random questions and also to determine the number of questions to display for each quiz type
  599.  
  600. ques = 1
  601.  
  602. # Function to generate the answer option for each question and each quiz type
  603.  
  604.  
  605. def selected():
  606.     global radiovar, user_answer
  607.     global lblQuestion, r1, r2, r3, r4
  608.     global ques
  609.     x = radiovar.get()
  610.     user_answer.append(x)
  611.  
  612.      # Conditional statement to determine the number of question and also
  613.     # to generate the number of options for GMAT and TOEFL Questions
  614.  
  615.     if (((quiz_type == "GMAT") or (quiz_type == "Gmat") or (quiz_type == "gmat")) or ((quiz_type == "TOEFL") or
  616.         (quiz_type == "Toefl") or (quiz_type == "toefl"))):
  617.         if ques <= 10:
  618.             lblQuestion.config(text=question[indexes[ques]])
  619.             r1["text"] = answers[indexes[ques]][0]
  620.             r2["text"] = answers[indexes[ques]][1]
  621.             r3["text"] = answers[indexes[ques]][2]
  622.             r4["text"] = answers[indexes[ques]][3]
  623.             ques += 1
  624.  
  625.         else:
  626.             pass
  627.  
  628.     # Conditional statement to determine the number of question and also
  629.     # to generate the number of options for JAMB Questions
  630.  
  631.     elif (quiz_type == "JAMB") or (quiz_type != "Jamb") or (quiz_type == "jamb"):
  632.         if ques <= 40:
  633.             lblQuestion.config(text=question[indexes[ques]])
  634.             r1["text"] = answers[indexes[ques]][0]
  635.             r2["text"] = answers[indexes[ques]][1]
  636.             r3["text"] = answers[indexes[ques]][2]
  637.             r4["text"] = answers[indexes[ques]][3]
  638.             ques += 1
  639.  
  640.         else:
  641.             pass
  642.  
  643.     # Conditional statement to determine the number of question and also
  644.     # to generate the number of options for GMAT and TOEFL Questions
  645.  
  646.     elif (quiz_type == "WAEC") or (quiz_type == "Waec") or (quiz_type == "waec"):
  647.         if ques <= 90:
  648.             lblQuestion.config(text=question[indexes[ques]])
  649.             r1["text"] = answers[indexes[ques]][0]
  650.             r2["text"] = answers[indexes[ques]][1]
  651.             r3["text"] = answers[indexes[ques]][2]
  652.             r4["text"] = answers[indexes[ques]][3]
  653.             ques += 1
  654.  
  655.         else:
  656.             pass
  657.  
  658.     else:
  659.         pass
  660.  
  661. # End of Function to generate the answer option for each question and each quiz type
  662.  
  663. # Function to load questions and answers
  664.  
  665.  
  666. def startIsPressed():
  667.     labelmage.destroy()
  668.     labeltext.destroy()
  669.     lbInstruction.destroy()
  670.     lbRules.destroy()
  671.     btnStart.destroy()
  672.     gen()
  673.     startQuiz()
  674.  
  675. # Function to load questions and answers
  676.  
  677.  
  678. # Function to pick answers from the options
  679.  
  680.  
  681. def startQuiz():
  682.     global lblQuestion, r1, r2, r3, r4, btnStart
  683.     lblQuestion = Label(
  684.         root,
  685.         text=question[indexes[0]],
  686.         font=("Dark Ministry", 18),
  687.         width=500,
  688.         justify="center",
  689.         wraplength=400,
  690.     )
  691.     lblQuestion.pack()
  692.  
  693.     global radiovar
  694.     radiovar = IntVar()
  695.     radiovar.set(-1)
  696.  
  697.     r1 = Radiobutton(
  698.         root,
  699.         text=answers[indexes[0]][0],
  700.         font=("Times", 12),
  701.         value=0,
  702.         variable=radiovar,
  703.         command=selected,
  704.     )
  705.     r1.pack()
  706.  
  707.     r2 = Radiobutton(
  708.         root,
  709.         text=answers[indexes[0]][1],
  710.         font=("Times", 12),
  711.         value=1,
  712.         variable=radiovar,
  713.         command=selected,
  714.     )
  715.     r2.pack()
  716.  
  717.     r3 = Radiobutton(
  718.         root,
  719.         text=answers[indexes[0]][2],
  720.         font=("Times", 12),
  721.         value=2,
  722.         variable=radiovar,
  723.         command=selected,
  724.     )
  725.     r3.pack()
  726.  
  727.     r4 = Radiobutton(
  728.         root,
  729.         text=answers[indexes[0]][3],
  730.         font=("Times", 12),
  731.         value=3,
  732.         variable=radiovar,
  733.         command=selected,
  734.     )
  735.     r4.pack()
  736.  
  737. # Function to pick answers from the options
  738.  
  739.  
  740. root = tkinter.Tk()
  741. root.title("Quiz Night")
  742. root.geometry("700x600")
  743. root.config(background="#ffffff")
  744. # root.resizable(0, 0)
  745.  
  746. img1 = PhotoImage(file="01.png")
  747. labelmage = Label(
  748.     root,
  749.     image=img1,
  750.     background="#ffffff",
  751. )
  752. labelmage.pack(pady=(40, 0), padx=(20, 0))
  753.  
  754. labeltext = Label(
  755.     root,
  756.     text="Welcome to Quiz Night",
  757.     font=("Dark Ministry", 30, "bold"),
  758.     background="#ffffff",
  759. )
  760. labeltext.pack(pady=(0, 40))
  761.  
  762. # img2 = PhotoImage(file="02.png")
  763.  
  764. lbInstruction = Label(
  765.     root,
  766.     text="Read the instructions properly, Click the Select Quiz Button to pick the quiz you want to attempt",
  767.     background="#ffffff",
  768.     font=("Casual Hardcore", 20),
  769.     justify="center",
  770. )
  771. lbInstruction.pack(pady=(10, 40))
  772.  
  773. lbRules = Label(
  774.     root,
  775.     text="This quiz contains 10 questions. You will get 20 seconds to solve a question\n"
  776.          "Once you select a button that will be a final choice, hence think before you select",
  777.     width=100,
  778.     font=("Times", 16),
  779.     background="#000000",
  780.     foreground="#FACA2F",
  781. )
  782. lbRules.pack()
  783.  
  784. functionalButtons = Frame(
  785.     root,
  786.     background="BLUE"
  787. )
  788.  
  789. # Button to select the type of quiz to be tested on
  790.  
  791. btnQuiz = Button(
  792.     functionalButtons,
  793.     foreground = "#000000",
  794.     background = "#ffffff",
  795.     text = "SELECT QUIZ TYPE",
  796.     font = ("Dark Ministry", 24),
  797.     relief = FLAT,
  798.     border = 3,
  799.     width=25,
  800.     command = selectExam,
  801. )
  802. btnQuiz.pack(side=LEFT, pady = (40, 0), padx=(30, 0))
  803.  
  804. # Button to start the quiz
  805.  
  806.  
  807. # Button to quit the whole application
  808.  
  809. btnEnd = Button(
  810.     functionalButtons,
  811.     # image= img2,
  812.     foreground="#ffffff",
  813.     background="#000000",
  814.     text="EXIT",
  815.     font=("Dark Ministry", 24),
  816.     relief=FLAT,
  817.     border=3,
  818.     width=25,
  819.     command=root.quit,
  820. )
  821. btnEnd.pack(side = BOTTOM, pady=(40, 0), padx =(15, 30))
  822.  
  823. functionalButtons.pack(side=BOTTOM, fill=X)
  824.  
  825.  
  826. root.mainloop()
Add Comment
Please, Sign In to add comment