Advertisement
Guest User

Untitled

a guest
Oct 5th, 2018
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 10.75 KB | None | 0 0
  1. import time
  2.  
  3. def welcome():
  4.     print("------------Welcome to THE QUIZ!------------")
  5.     time.sleep(0.5)
  6.     accountCreate = input("Hit Y to create an account!\nHit Q to quit the quiz!\n")
  7.     if accountCreate == 'Y' or accountCreate == 'y':
  8.         account()
  9.     if accountCreate == 'N' or accountCreate == 'n':
  10.         quit()
  11.  
  12.  
  13. def account():
  14.     try:
  15.         f = open("account.txt",'w+')
  16.     except:
  17.         f = open("account.txt",'a')
  18.     print("OK! Here are a few questions!\n")
  19.     time.sleep(0.5)
  20.     firstName = input("Firstname:  ")
  21.     time.sleep(0.5)
  22.     surname = input("Surname:  ")
  23.     time.sleep(0.5)
  24.     age = input("Age:  ")
  25.     time.sleep(0.5)
  26.     usernameAsk = print("You username is:  ",firstName[0:3]+age)
  27.     username = firstName[0:3]+age
  28.     time.sleep(0.5)
  29.     password = input("Password:  ")
  30.     time.sleep(0.5)
  31.     confirm = input("Confirm Password:  ")
  32.     while password != confirm:
  33.         print("INVALID! Please re-enter your password!\n")
  34.         time.sleep(0.5)
  35.         password = input("Password:  ")
  36.         time.sleep(0.5)
  37.         confirm = input("Confirm Password:  ")
  38.     f.write(firstName + ' , ' + surname + ' , ' + age + '\n\nUsername:  ' + username + '\nPassword:  ' + confirm)
  39.     fRead= f.readlines()
  40.    
  41.    
  42.     edit = input('Would you like to edit your details?Y/N\n')
  43.     if edit == 'Y' or edit == 'y':
  44.         account()
  45.     else:
  46.         topics()
  47.  
  48. def topics():
  49.     """with open('packages.txt') as f:
  50.        for i, line in enumerate(f, 1):
  51.        if i == num:
  52.            break
  53.       print line"""
  54.     topicChoice = input("Would you like to be tested on Maths\nor Geography?M/G\n")
  55.     difficulty = int(input("Select difficulty:\n1.Easy\n2.Medium\n3.Hard\nSelect 1 , 2 or 3\n"))
  56.     if topicChoice == 'M' or topicChoice == 'm' and difficulty == 1:
  57.         maths_1()
  58.     elif topicChoice == 'M' or topicChoice == 'm' and difficulty == 2:
  59.         maths_2()
  60.     elif topicChoice == 'M' or topicChoice == 'm' and difficulty == 3:
  61.         maths_3()
  62.     elif topicChoice == 'G' or topicChoice == 'g' and difficulty == 1:
  63.         geo_1()
  64.     elif topicChoice == 'G' or topicChoice == 'g' and difficulty == 2:
  65.         geo_2()
  66.     elif topicChoice == 'G' or topicChoice == 'g' and difficulty == 3:
  67.         geo_3()
  68.  
  69. def maths_1():
  70.     cont = 5
  71.     print("You have chosen Maths Easy! Here you go!")
  72.     m = open("maths.txt",'r')
  73.     lines = m.readlines()
  74.     time.sleep(0.5)
  75.     print(lines[0])
  76.     q1 = int(input())
  77.     if q1 != 9:
  78.         time.sleep(0.5)
  79.         #print("WRONG!") #Try Again:")
  80.         cont -= 1
  81.     time.sleep(0.5)
  82.     print(lines[1])
  83.     q2 = int(input())
  84.     if q2 != 30:
  85.         time.sleep(0.5)
  86.         #print("WRONG!") #Try Again:")
  87.         cont -= 1
  88.     time.sleep(0.5)
  89.     print(lines[2])
  90.     q3 = int(input())
  91.     if q3 != 63:
  92.         time.sleep(0.5)
  93.         #print("WRONG!") #Try Again:")
  94.         cont -= 1
  95.     time.sleep(0.5)
  96.     print(lines[3])
  97.     q4 = int(input())
  98.     if q4 != 24:
  99.         time.sleep(0.5)
  100.         #print("WRONG!") #Try Again:")
  101.         cont -= 1
  102.     time.sleep(0.5)
  103.     print(lines[4])
  104.     q5 = int(input())
  105.     if q5 != 22:
  106.         #print("WRONG!") #Try Again:")
  107.         cont -= 1
  108.     time.sleep(0.5)
  109.     score = (cont/5)*100
  110.     #print("You score out of 5 is ", 5 - cont)
  111.     print("Your score is ", score, '%')
  112.     time.sleep(0.5)
  113.     again = input("Would you like to take another quiz?Y/N")
  114.     if again == 'Y' or again == 'y':
  115.         topics()
  116.     else:
  117.         quit()
  118. def maths_2():
  119.     cont = 5
  120.     print("You have chosen Maths Medium! Here you go!")
  121.     m2 = open("maths2.txt",'r')
  122.     lines = m2.readlines()
  123.     time.sleep(0.5)
  124.     print(lines[0])
  125.     q1 = int(input())
  126.     if q1 != 5:
  127.         time.sleep(0.5)
  128.         #print("WRONG!") #Try Again:")
  129.         cont -= 1
  130.     time.sleep(0.5)
  131.     print(lines[1])
  132.     q2 = int(input())
  133.     if q2 != 48:
  134.         time.sleep(0.5)
  135.         #print("WRONG!") #Try Again:")
  136.         cont -= 1
  137.     time.sleep(0.5)
  138.     print(lines[2])
  139.     q3 = int(input())
  140.     if q3 != 256:
  141.         time.sleep(0.5)
  142.         #print("WRONG!") #Try Again:")
  143.         cont -= 1
  144.     time.sleep(0.5)
  145.     print(lines[3])
  146.     q4 = int(input())
  147.     if q4 != 400:
  148.         time.sleep(0.5)
  149.         #print("WRONG!") #Try Again:")
  150.         cont -= 1
  151.     time.sleep(0.5)
  152.     print(lines[4])
  153.     q5 = int(input())
  154.     if q5 != 100:
  155.         time.sleep(0.5)
  156.         #print("WRONG!") #Try Again:")
  157.         cont -= 1
  158.     time.sleep(0.5)
  159.     score =  (cont/5)*100
  160.     #print("You score out of 5 is ", 5 - cont)
  161.     print("Your score is ", score, '%')
  162.     time.sleep(0.5)
  163.     again = input("Would you like to take another quiz?Y/N\n")
  164.     if again == 'Y' or again == 'y':
  165.         topics()
  166.     else:
  167.         quit()
  168. def maths_3():
  169.     cont = 5
  170.     print("You have chosen Maths Hard! Here you go!")
  171.     m3 = open("maths3.txt",'r')
  172.     lines = m3.readlines()
  173.     time.sleep(0.5)
  174.     print(lines[0])
  175.     q1 = int(input())
  176.     if q1 != 2:
  177.         time.sleep(0.5)
  178.         #print("WRONG!") #Try Again:")
  179.         cont -= 1
  180.     time.sleep(0.5)
  181.     print(lines[1])
  182.     q2 = float(input())
  183.     if q2 != 0.3:
  184.         time.sleep(0.5)
  185.         #print("WRONG!") #Try Again:")
  186.         cont -= 1
  187.     time.sleep(0.5)
  188.     print(lines[2])
  189.     q3 = float(input())
  190.     if q3 != 25.5:
  191.         time.sleep(0.5)
  192.         #print("WRONG!") #Try Again:")
  193.         cont -= 1
  194.     time.sleep(0.5)
  195.     print(lines[3])
  196.     q4 = int(input())
  197.     if q4 != 1:
  198.         time.sleep(0.5)
  199.         #print("WRONG!") #Try Again:")
  200.         cont -= 1
  201.     time.sleep(0.5)
  202.     print(lines[4])
  203.     q5 = int(input())
  204.     if q5 != 3:
  205.         time.sleep(0.5)
  206.         #print("WRONG!") #Try Again:")
  207.         cont -= 1
  208.     time.sleep(0.5)
  209.     score = (cont/5)*100
  210.     #print("You score out of 5 is ", 5 - cont)
  211.     print("Your score is ", score, '%')
  212.     time.sleep(0.5)
  213.     again = input("Would you like to take another quiz?Y/N\n")
  214.     if again == 'Y' or again == 'y':
  215.         topics()
  216.     else:
  217.         quit()
  218. def geo_1():
  219.     cont = 5
  220.     print("You have chosen Geograohy Easy! Here you go!")
  221.     g = open("geography.txt",'r')
  222.     lines = g.readlines()
  223.     time.sleep(0.5)
  224.     print(lines[0]+'\n1. Tokoyo\n2. Dehli\n3. Bangkok\nEnter choice number:  ')
  225.     q1 = int(input())
  226.     if q1 != 1:
  227.         time.sleep(0.5)
  228.         #print("WRONG!") #Try Again:")
  229.         cont -= 1
  230.     time.sleep(0.5)
  231.     print(lines[1]+'\n1. 5\n2. 4\n3. 7\nEnter choice number:  ')
  232.     q2 = int(input())
  233.     if q2 != 3:
  234.         time.sleep(0.5)
  235.         #print("WRONG!") #Try Again:")
  236.         cont -= 1
  237.     time.sleep(0.5)
  238.     print(lines[2]+'\n1. Russia\n2. China\n3. North America\nEnter choice number:  ')
  239.     q3 = int(input())
  240.     if q3 != 1:
  241.         time.sleep(0.5)
  242.         #print("WRONG!") #Try Again:")
  243.         cont -= 1
  244.     time.sleep(0.5)
  245.     print(lines[3]+'\n1. Luxemborg\n2. Vatican City\n3. Monaco\nEnter choice number:  ')
  246.     q4 = int(input())
  247.     if q4 != 2:
  248.         time.sleep(0.5)
  249.         #print("WRONG!") #Try Again:")
  250.         cont -= 1
  251.     time.sleep(0.5)
  252.     print(lines[4]+'\n1. 6 Billion\n2. 7 Billion \n3. 5 Billion\nEnter choice number:  ')
  253.     q5 = int(input())
  254.     if q5 != 2:
  255.         time.sleep(0.5)
  256.         #print("WRONG!") #Try Again:")
  257.         cont -= 1
  258.     time.sleep(0.5)
  259.     score = (cont/5)*100
  260.     #print("You score out of 5 is ", 5 - cont)
  261.     print("Your score is ", score, '%')
  262.     time.sleep(0.5)
  263.     again = input("Would you like to take another quiz?Y/N\n")
  264.     if again == 'Y' or again == 'y':
  265.         topics()
  266.     else:
  267.         quit()
  268. def geo_2():
  269.     cont = 5
  270.     print("You have chosen Geograohy Medium! Here you go!")
  271.     g2 = open("geography2.txt",'r')
  272.     lines = g2.readlines()
  273.     time.sleep(0.5)
  274.     print(lines[0]+'\n1. Guyana\n2. Lima\n3. Washington\nEnter choice number:  ')
  275.     q1 = int(input())
  276.     #print("q1:    :",q1)#mmd
  277.     if q1 != 2:
  278.         time.sleep(0.5)
  279.         #print("WRONG!") #Try Again:")
  280.         cont -= 1
  281.     time.sleep(0.5)
  282.     print(lines[1]+'\n1. Brazil\n2. Northern Ireland\n3. Africa\nEnter choice number:  ')
  283.     q2 = int(input())
  284.     if q2 != 1:
  285.         time.sleep(0.5)
  286.         #print("WRONG!") #Try Again:")
  287.         cont -= 1
  288.     time.sleep(0.5)
  289.     print(lines[2]+'\n1. China\n2. Spain\n3. India\nEnter choice number:  ')
  290.     q3 = int(input())
  291.     if q3 != 1:
  292.         time.sleep(0.5)
  293.         #print("WRONG!") #Try Again:")
  294.         cont -= 1
  295.     time.sleep(0.5)
  296.     print(lines[3]+'\n1. Atlantis\n2. Earthia\n3. Pangea\nEnter choice number:  ')
  297.     q4 = int(input())
  298.     if q4 != 3:
  299.         time.sleep(0.5)
  300.         #print("WRONG!") #Try Again:")
  301.         cont -= 1
  302.     time.sleep(0.5)
  303.     print(lines[4]+'\n1. 45\n2. 29\n3. 20\nEnter choice number:  ')
  304.     q5 = int(input())
  305.     if q5 != 2:
  306.         time.sleep(0.5)
  307.         #print("WRONG!") #Try Again:")
  308.         cont -= 1
  309.     time.sleep(0.5)
  310.     score = (cont/5)*100
  311.     #print("You score out of 5 is ", 5 - cont)
  312.     print("Your score is ",score, '%')
  313.     time.sleep(0.5)
  314.     again = input("Would you like to take another quiz?Y/N\n")
  315.     if again == 'Y' or again == 'y':
  316.         topics()
  317.     else:
  318.         quit()
  319. def geo_3():
  320.     cont = 5
  321.     print("You have chosen Geograohy Hard! Here you go!")
  322.     g3 = open("geography3.txt",'r')
  323.     lines = g3.readlines()
  324.     time.sleep(0.5)
  325.     print(lines[0]+'\n1. Kenya\n2. South Africa\n3. Brazil\nEnter choice number:  ')
  326.     q1 = int(input())
  327.     if q1 != 3:
  328.         time.sleep(0.5)
  329.         #print("WRONG!") #Try Again:")
  330.         cont -= 1
  331.     time.sleep(0.5)
  332.     print(lines[1]+'\n1. Chennai\n2. Mumbai\n3. Goa\nEnter choice number:  ')
  333.     q2 = int(input())
  334.     if q2 != 1:
  335.         time.sleep(0.5)
  336.         #print("WRONG!") #Try Again:")
  337.         cont -= 1
  338.     time.sleep(0.5)
  339.     print(lines[2]+'\n1. Texas\n2. New York\n3. Alaska\nEnter choice number:  ')
  340.     q3 = int(input())
  341.     if q3 != 3:
  342.         time.sleep(0.5)
  343.         #print("WRONG!") #Try Again:")
  344.         cont -= 1
  345.     time.sleep(0.5)
  346.     print(lines[3]+'\n1. Gabriel\n2. Angel Falls\n3. Angel Mountain\nEnter choice number:  ')
  347.     q4 = int(input())
  348.     if q4 != 2:
  349.         time.sleep(0.5)
  350.         #print("WRONG!") #Try Again:")
  351.         cont -= 1
  352.     time.sleep(0.5)
  353.     print(lines[4]+'\n1. Japan\n2. Nepal\n3. Thailand\nEnter choice number:  ')
  354.     q5 = int(input())
  355.     if q5 != 1:
  356.         time.sleep(0.5)
  357.         #print("WRONG!") #Try Again:")
  358.         cont -= 1
  359.     time.sleep(0.5)
  360.     score = (cont/5)*100
  361.     #print("You score out of 5 is ", 5 - cont)
  362.     print("Your score is ", score , '%')
  363.     time.sleep(0.5)
  364.     again = input("Would you like to take another quiz?Y/N\n")
  365.     if again == 'Y' or again == 'y':
  366.         topics()
  367.     else:
  368.         quit()
  369.    
  370.  
  371.    
  372. welcome()
  373.  
  374. account()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement