Advertisement
DefeatedPurpose

Lua Quiz!

Jul 30th, 2018
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.98 KB | None | 0 0
  1. --CHEESE()
  2. --Certified Weeb#6917 (Discord)
  3. --Share your results! OwO
  4. print("Welcome to the LUA test! There are 10 questions you'll need to answer!")
  5. print("Rules:")
  6. print("1. No looking up answers")
  7. print("2. No re-taking the test.")
  8. print("3. No asking other people for help")
  9. print("Allowed:")
  10. print("1. Studying before the test")
  11. print("Do you understand?")
  12. print("If yes then type: '1' or if no then type: '2'")
  13. understand = io.read()
  14. understood = nil
  15. correct = 0
  16. score = 0
  17. bonus = nil
  18. attempted = nil
  19. rating = nil
  20. ctt = nil
  21. if understand == "1" then
  22.     understood = true
  23.     elseif understand == "2" then
  24.     understood = false
  25.     end
  26. if understood then
  27.     print("Great, Let's begin the test")
  28.     ctt = true
  29.     elseif not understood then
  30.     print("Looks like you didn't understand, You may not start the test until you do.")
  31.     ctt = false
  32.     end
  33. if ctt then
  34.     print("Enter your username...")
  35.     un = io.read()
  36.     print("Welcome, "..un)
  37.     unr = math.random(1,1000)
  38.     print("Your user number is : "..unr)
  39.     print(""..un..", Are you ready?")
  40.     io.read()
  41.     print("Ready or not, Question 1:")
  42.     print("What is wrong with this script?")
  43.     print("print('This is a test)")
  44.     print("1. There is nothing wrong.")
  45.     print("2. There is an unfinished string")
  46.     print("3. There is no period.")
  47.     q1 = io.read()
  48.     if q1 == "2" then
  49.         print("Correct!")
  50.         correct = correct + 1
  51.         score = score + 10
  52.         elseif q1 ~= "2" then
  53.         print("Incorrect!")
  54.         end
  55.     print("Question 2:")
  56.     print("What is wrong with this script?")
  57.     print("if variable == true then dosomething() end")
  58.     print("1. You don't need an 'end' for if statements.")
  59.     print("2. There is nothing wrong")
  60.     print("3. You don't need '== true'")
  61.     q2 = io.read()
  62.     if q2 == "3" then
  63.         print("Correct!")
  64.         correct = correct + 1
  65.         score = score + 10
  66.         elseif q2 ~= "3" then
  67.         print("Incorrect!")
  68.         end
  69.     print("Question 3:")
  70.     print("What symbol do you use to multiply values in lua?")
  71.    print("1. '*'")
  72.    print("2. 'x'")
  73.    print("3. You can't multiply values in lua.")
  74.     q3 = io.read()
  75.     if q3 == "1" then
  76.         print("Correct!")
  77.         correct = correct + 1
  78.         score = score + 10
  79.         elseif q3 ~= "1" then
  80.         print("Incorrect!")
  81.         end
  82.     print("Question 4:")
  83.     print("What symbol do you use to divide values in lua?")
  84.     print("1. '/'")
  85.     print("2. The division symbol")
  86.     print("3. You can't divide values in lua.")
  87.     q4 = io.read()
  88.     if q4 == "1" then
  89.         print("Correct!")
  90.         correct = correct + 1
  91.         score = score + 10
  92.         elseif q4 ~= "1" then
  93.         print("Incorrect!")
  94.         end
  95.     print("Question 5:")
  96.     print("What will this output?")
  97.     print("local lua = {} for i=1,100 do table.insert(lua,math.random(1,100)) end print(table.concat(lua),'')")
  98.     print("1. It will print noting.")
  99.     print("2. A random string of numbers")
  100.     print("3. It will error.")
  101.     q5 = io.read()
  102.     if q5 == "2" then
  103.         print("Correct!")
  104.         correct = correct + 1
  105.         score = score + 10
  106.         elseif q5 ~= "2" then
  107.         print("Incorrect!")
  108.         end
  109.     print("Question 6:")
  110.     print("What does print(math.random(1, 100)) do?")
  111.     print("1. Nothing.")
  112.     print("2. Error")
  113.     print("3. Prints a random number between 1 and 100")
  114.     q6 = io.read()
  115.     if q6 == "3" then
  116.         print("Correct!")
  117.         correct = correct + 1
  118.         score = score + 10
  119.         elseif q6 ~= "3" then
  120.         print("Incorrect")
  121.         end
  122.     print("Question 7:")
  123.     print("What does this script do?")
  124.     print("if a > b then print('test') end")
  125.     print("1. Error.")
  126.     print("2. Will print 'test' if a is bigger than b")
  127.     print("3. Print's 'test'")
  128.     q7 = io.read()
  129.     if q7 == "2" then
  130.         print("Correct!")
  131.         correct = correct + 1
  132.         score = score + 10
  133.         elseif q7 ~= "2" then
  134.         print("Incorrect!")
  135.         end
  136.     print("Question 8")
  137.     print("How do you end a 'while true do' loop?")
  138.     print("1. break")
  139.     print("2. end")
  140.     print("3. stop.")
  141.     q8 = io.read()
  142.     if q8 == "1" then
  143.         print("Correct!")
  144.         correct = correct + 1
  145.         score = score + 10
  146.         elseif q8 ~= "1" then
  147.         print("Incorrect!")
  148.         end
  149.     print("Question 9:")
  150.     print("What does this do?")
  151.     print("a = true if a then print('test') end")
  152.     print("1. Do nothing.")
  153.     print("2. prints 'test'")
  154.     print("3. Will print 'test' if a is true")
  155.     q9 = io.read()
  156.     if q9 == "3" then
  157.         print("Correct!")
  158.         correct = correct + 1
  159.         score = score + 10
  160.         elseif q9 ~= "3" then
  161.         print("Incorrect!")
  162.         end
  163.     print("Question 10 (EASY!)")
  164.     print("What language is this script coded in?")
  165.     print("1. Lua")
  166.     print("2. Java")
  167.     print("3. Python")
  168.     q10 = io.read()
  169.     if q10 == "1" then
  170.         print("Correct!")
  171.         correct = correct + 1
  172.         score = score + 10
  173.         elseif q10 ~= "1" then
  174.         print("Incorrect!")
  175.         end
  176.     print("End of the test!")
  177.     if score == 0 then
  178.         rating = "Did you even try?"
  179.         elseif score == 10 then
  180.         rating = "Rank : -F"
  181.         elseif score == 20 then
  182.         rating = "Rank : F"
  183.         elseif score == 30 then
  184.         rating = "Rank : F+"
  185.         elseif score == 40 then
  186.         rating = "Rank : F++"
  187.         elseif score == 50 then
  188.         rating = "Rank : -D"
  189.         elseif score == 60 then
  190.         rating = "Rank : D"
  191.         elseif score == 70 then
  192.         rating = "Rank : C"
  193.         elseif score == 80 then
  194.         rating = "Rank : B"
  195.         elseif score == 90 then
  196.         rating = "Rank : A"
  197.         elseif score == 100 then
  198.         rating = "Rank : P+"
  199.         end
  200.     print("Would you like to attempt the bonus question?")
  201.     print("1 for yes and 2 for no.")
  202.     bq = io.read()
  203.     if bq == "1" then
  204.         attempted = "Yes"
  205.         print("What is a table in lua?")
  206.         print("1. An information holder.")
  207.         print("2. A associative array to hold numbers and strings with no limit")
  208.         print("3. A table with four legs.")
  209.         q11 = io.read()
  210.         if q11 == "2" then
  211.             print("Correct!")
  212.             bonus = "Yes"
  213.             elseif q11 ~= "2" then
  214.             print("Incorrect")
  215.             bonus = "No"
  216.             end
  217.         elseif bq == "2" then
  218.         attempted = "No"
  219.         print("Understandable")
  220.         end
  221.     print("Here is your profile to keep and/or share!!")
  222.     print("-----[GENERATED PROFILE]-----")
  223.     print("Certified Weeb's lua test!")
  224.     print("Username : "..un)
  225.     print("User # : "..unr)
  226.     print("Test score : "..score.."%")
  227.     print("Answers : "..correct.." out of 10")
  228.     print("Rating : "..rating)
  229.     print("Attempted Bonus? : "..attempted)
  230.     print("Got bonus? : "..bonus)
  231.     print("-----[GENERATED PROFILE]-----")
  232.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement