SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 126 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ### IMPORT CSV FILE
  2. import csv
  3. csvfile = open ("database.csv","r")
  4. readcsv = csv.reader(csvfile)
  5.  
  6.  
  7. ### MAIN MENU
  8. def mainmenu():
  9.     print("Welcome to Fergus' Quiz!")
  10.     print("Please pick a option")
  11.     print("(1) Login")
  12.     print("(2) Register")
  13.     menuinput = input ("Please enter the number below\n")
  14.     if menuinput == "1":
  15.         login()
  16.     if menuinput == "2":
  17.         register()
  18.  
  19.        
  20. ### LOGIN SECTION      
  21. def login():
  22.     print("Welcome to the login section.")
  23.     csvfile = open( "database.csv","r")
  24.     readcsv = csv.reader(csvfile)
  25.     usernamecheck = input ("What is your username?\n")
  26.     passwordcheck = input ("What is your password?\n")
  27.     for row in csv.reader(open("database.csv"), delimiter =','):
  28.         if row[0] == usernamecheck and row[1] == passwordcheck:
  29.             loggedin()
  30.          
  31.         else:
  32.             print("Invalid login details, please try again.")
  33.             login()
  34.  
  35. ### LOGGED IN
  36. def loggedin():
  37.     print("LOGGED IN")
  38.     print("Please pick whhich topic you would like!")
  39.     print("------------------------")
  40.     print("(1) History")
  41.     print("(2) Geography")
  42.     topicpick = input("Please enter the number below\n")
  43.     if topicpick == "1":
  44.         history()
  45.  
  46.  
  47.  
  48. ### REGISTER SECTION
  49. def register():
  50.     print("Welcome to the register section.")
  51.     csvfile = open ("database.csv","a")
  52.     writer = csv.writer(csvfile)
  53.     username = input ("Please pick a username\n")
  54.     password = input ("Please pick a password\n")
  55.     writer.writerow((username, password))
  56.     print ("You are sucessfully registered!")
  57.     csvfile.close()
  58.     mainmenu()
  59.  
  60.  
  61. ### HISTORY SECTION
  62. def history():
  63.     points = 0
  64.     print("Welcome to the History section")
  65.     historyquiz = input("Please pick a difficulty: easy, medium or hard.\n")
  66.     if historyquiz == "easy":
  67.        
  68.         #question 1
  69.         print("What does LAN stand for?")
  70.         print("a. Local Area Network")
  71.         print("b. Local Arm Network")
  72.         a1e = input("What is your answer?\a")
  73.         if a1e == "a":
  74.             print("Correct.")
  75.             print("-------------------------------------------------")
  76.             points = points+1
  77.         else:
  78.             print ("Incorrect.")
  79.             print("-------------------------------------------------")
  80.  
  81.         #question 2
  82.         print("What does WAN stand for?")
  83.         print("a. Wide Area Network")
  84.         print("b. Whale Area Network")
  85.         a2e = input("What is your answer?\n")
  86.         if a2e == "a":
  87.             print("Correct.")
  88.             print("-------------------------------------------------")
  89.             points = points+1
  90.         else:
  91.             print ("Incorrect.")
  92.             print("-------------------------------------------------")
  93.  
  94.         #question 3
  95.         print("What does WWW stand for?")
  96.         print("a. World Web Warp")
  97.         print("b. World Wide Web")
  98.         a3e = input("What is your answer?\n")
  99.         if a3e == "b":
  100.             print("Correct.")
  101.             print("-------------------------------------------------")
  102.             points = points+1
  103.         else:
  104.             print ("Incorrect.")
  105.             print("-------------------------------------------------")
  106.        
  107.  
  108.         #question 4
  109.         print("What is binary written in?")
  110.         print("a. 2&5")
  111.         print("b. 1&0")
  112.         a4e = input("What is your answer?\n")
  113.         if a4e == "b":
  114.             print("Correct.")
  115.             print("-------------------------------------------------")
  116.             points = points+1
  117.         else:
  118.             print ("Incorrect.")
  119.             print("-------------------------------------------------")
  120.  
  121.         #question 5
  122.         print("How do you display text in python")
  123.         print("a. 'print'")
  124.         print("b. 'display'")
  125.         a5e = input("What is your answer?\n")
  126.         if a5e == "a":
  127.             print("Correct.")
  128.             print("-------------------------------------------------")
  129.             points = points+1
  130.         else:
  131.             print ("Incorrect.")
  132.             print("-------------------------------------------------")
  133.         print("You have",points,"points.")
  134.  
  135.     if historyquiz == "medium":
  136.         #question 1
  137.         print("What does LAN stand for?")
  138.         print("a. Local Area Network")
  139.         print("b. Local Arm Network")
  140.         print("c. Lope Arm Network")
  141.         a1m = input("What is your answer?\a")
  142.         if a1m == "a":
  143.             print("Correct.")
  144.             print("-------------------------------------------------")
  145.             points = points+1
  146.         else:
  147.             print ("Incorrect.")
  148.             print("-------------------------------------------------")
  149.  
  150.         #question 2
  151.         print("What does WAN stand for?")
  152.         print("a. Wide Area Network")
  153.         print("b. Whale Area Network")
  154.         print("c. Wide Arm Network")
  155.         a2m = input("What is your answer?\n")
  156.         if a2m == "a":
  157.             print("Correct.")
  158.             print("-------------------------------------------------")
  159.             points = points+1
  160.         else:
  161.             print ("Incorrect.")
  162.             print("-------------------------------------------------")
  163.  
  164.         #question 3
  165.         print("What does WWW stand for?")
  166.         print("a. World Web Warp")
  167.         print("b. World Wide Web")
  168.         print("c. World Wide Waste")
  169.         a3m = input("What is your answer?\n")
  170.         if a3m == "b":
  171.             print("Correct.")
  172.             print("-------------------------------------------------")
  173.             points = points+1
  174.         else:
  175.             print ("Incorrect.")
  176.             print("-------------------------------------------------")
  177.            
  178.  
  179.         #question 4
  180.         print("What is binary written in?")
  181.         print("a. 2&5")
  182.         print("b. 1&0")
  183.         print("c. 3&6")
  184.         a4m = input("What is your answer?\n")
  185.         if a4m == "b":
  186.             print("Correct.")
  187.             print("-------------------------------------------------")
  188.             points = points+1
  189.         else:
  190.             print ("Incorrect.")
  191.             print("-------------------------------------------------")
  192.  
  193.         #question 5
  194.         print("How do you display text in python")
  195.         print("a. 'print'")
  196.         print("b. 'display'")
  197.         print("c. 'show'")
  198.         a5m = input("What is your answer?\n")
  199.         if a5m == "a":
  200.             print("Correct.")
  201.             print("-------------------------------------------------")
  202.             points = points+1
  203.         else:
  204.             print ("Incorrect.")
  205.             print("-------------------------------------------------")
  206.         print("You have",points,"points.")
  207.  
  208.        
  209.  
  210.        
  211.  
  212.  
  213. ### LOOP
  214. loop = 0
  215. if loop == 0:
  216.     mainmenu()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top