Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- user_name = raw_input("Welcome to Quiz #6, please input your name: \n")
- print "Okay %s! Let\'s start!" % user_name
- def question_one(user_grade):
- print """
- 1. What does the return statement do?
- a. Prints something
- b. Calls a function
- c. Prints and returns to the calling function
- d. Returns to the beginning of a function
- """
- input_answer_one = raw_input("What is your answer?\n")
- if input_answer_one == 'c':
- os.system('clear')
- user_grade = user_grade + 1
- question_two(user_grade)
- else:
- os.system('clear')
- question_two(user_grade)
- def question_two(user_grade):
- print """
- 2. What will "false or false" give you?
- a. True
- b. False
- c. False and true
- d. False and false
- """
- input_answer_two = raw_input("What is your answer?\n")
- if input_answer_two == "b":
- os.system('clear')
- user_grade = user_grade + 1
- question_three(user_grade)
- else:
- os.system('clear')
- question_three(user_grade)
- def question_three(user_grade):
- print """
- 3. What will "not true and false" give you?
- a. True
- b. False
- c. Error
- d. True and False
- """
- input_answer_three = raw_input("What is your answer?\n")
- if input_answer_three == "a":
- os.system('clear')
- user_grade + 1
- question_four(user_grade)
- else:
- os.system('clear')
- question_four(user_grade)
- def question_four(user_grade):
- print """
- 4. 0 != 0
- a. True
- b. False
- c. 0
- d. Error
- """
- input_answer_four = raw_input("What is your answer?\n")
- if input_answer_four == "b":
- os.system('clear')
- user_grade + 1
- question_five(user_grade)
- else:
- os.system('clear')
- question_five(user_grade)
- def question_five(user_grade):
- print """
- 5. What does += do?
- a. Adds to the original integer
- b. Sets a sum equal to a new value
- c. Signifies if a sum is equal to a number, the code will execute something
- d. Adds two of the same numbers
- """
- input_answer_five = raw_input("What is your answer?\n")
- if input_answer_five == "a":
- os.system('clear')
- user_grade + 1
- question_six(user_grade)
- os.system('clear')
- else:
- os.system('clear')
- question_six(user_grade)
- def question_six(user_grade):
- print """
- 6. What output would you get for this statement:
- y = 2
- x = 3 += y
- Print x
- a. 3+y
- b. 3y
- c. 5
- d. 2
- """
- input_answer_six = raw_input("What is your answer?\n")
- if input_answer_six == 'c':
- os.system('clear')
- user_grade = user_grade + 1
- question_seven(user_grade)
- else:
- os.system('clear')
- question_seven(user_grade)
- def question_seven(user_grade):
- print """
- 7. What is the difference between '==' and '=' ?
- a. They both do the same thing
- b. == means not equal to, while = simply means equal to
- c. == globally sets a variable equal to something
- d. = sets a variable equal to something, == simply means something is equal to something else in that instance.
- """
- input_answer_seven = raw_input("What is your answer?\n")
- if input_answer_seven == "d":
- os.system('clear')
- user_grade = user_grade + 1
- question_eight(user_grade)
- else:
- os.system('clear')
- question_eight(user_grade)
- def question_eight(user_grade):
- print """
- 8. What line is the error in this code on?
- 1: x = raw_input("What is the time?")
- 2: int(raw_input)
- 3: if x < 10:
- 4: print "Good morning"
- 5: elif x < 12:
- 6: print "Soon time for lunch"
- 7: elif x < 18:
- 8: print "Good day"
- 9: elif x < 22:
- 10: print "Good evening"
- 11: else:
- 12: print "Good night"
- """
- input_answer_eight = raw_input("What is your answer?\n")
- if input_answer_eight == "2":
- os.system('clear')
- user_grade = user_grade + 1
- question_nine(user_grade)
- else:
- os.system('clear')
- question_nine(user_grade)
- def question_nine(user_grade):
- print """
- 9. What line is the error in this code on?
- 1: allowed_users = ['bill', 'steve']
- 2: username = raw_input("What is your login? : ")
- 3: if username is allowed_users:
- 4: print "Access granted"
- 5: else:
- 6: print "Access denied"
- """
- input_answer_nine = raw_input("What is your answer?\n")
- if input_answer_nine == "3":
- os.system('clear')
- user_grade = user_grade + 1
- question_ten(user_grade)
- else:
- os.system('clear')
- question_ten(user_grade)
- def question_ten(user_grade):
- print """
- 10. What does this code do?
- for x in range(1,50):
- even_check = x / 2
- print even_check
- a. Prints all the whole numbers that would be given if you divided the range by 2 excluding 50
- b. Prints all numbers divided by 2
- c. Prints all numbers in the range
- d. Prints all the numbers that would would be given if you divided by 2 including 50
- """
- input_answer_ten = raw_input("What is your answer?\n")
- if input_answer_ten == "a":
- os.system('clear')
- user_grade = user_grade + 1
- quiz_end(user_grade)
- else:
- os.system('clear')
- quiz_end(user_grade)
- def quiz_end(user_grade):
- print "Okay %s, you got a %s out of 10" % (user_name, user_grade)
- if user_grade > 6:
- print "You passed the quiz!"
- else:
- print "You failed the quiz, Study more next time!"
- question_one(0) # starts the quiz
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement