Advertisement
Guest User

Untitled

a guest
Aug 12th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. #!/usr/bin/python
  2. #creating a function so I don't need to save into txt file
  3. def main():
  4. #file for answers.txt
  5. file = open("answers.txt", "w")
  6. #Asking for first and lastname
  7. fname = raw_input("Input your First Name : ")
  8. lname = raw_input("Input your Last Name : ")
  9. print ("Hello Good Luck " + fname + " " + lname)
  10. #creating questions and using if statement
  11. questions1 = raw_input("What is 1+1? ")
  12. answer1 = ("2")
  13. if questions1 == answer1:
  14. print("correct answer")
  15. elif questions1 != answer1:
  16. print("incorrect answer")
  17. question2 = raw_input("What is 1+2 ?")
  18. answer2 = ("3")
  19. if question2 == answer2:
  20. print("correct answer")
  21. elif question2 != answer2:
  22. print("incorrect answer")
  23. question3 = raw_input("What is 4+2 ?")
  24. answer3 = ("6")
  25. if question3 == answer3:
  26. print("correct answer")
  27. elif question3 != answer3:
  28. print("incorrect answer")
  29. question4 = raw_input("What is 1-1 ?")
  30. answer4 = ("0")
  31. if question4 == answer4:
  32. print("correct answer")
  33. elif question4 != answer4:
  34. print("incorrect answer")
  35. question5 = raw_input("What is 2 * 5 ?")
  36. answer5 = ("10")
  37. if question5 == answer5:
  38. print("correct answer")
  39. elif question5 != answer5:
  40. print("incorrect answer")
  41.  
  42. ~
  43. ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement