Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- # 1. Intro
- print()
- print("**** THIS IS A MATH QUIZ-CHALLENGE! THANKS FOR PLAYING! ****")
- n = int(input("Enter how many questions do you want to ask to contestants: "))
- print("Because this is an important challenge, please enter your names: ")
- name1 = input("Name of Player1: ")
- name2 = input("Name of Player2: ")
- print()
- print()
- counter1 = 0
- counter2 = 0
- # 2. For-loop for displaying the math questions
- for i in range(n):
- print(" **** R O U N D " + str(i+1) + " ****")
- # Player1
- r1 = random.randint(1, 200)
- r2 = random.randint(1, 200)
- answer1 = int(input(" It's " + name1 + "'s turn: " + str(r1) + " + " + str(r2) + " = "))
- result1 = r1 + r2
- if answer1 == result1:
- counter1 += 1
- print("YOU ARE RIGHT!")
- else:
- print("WRONG ANSWER, SORRY!")
- # Player2
- r3 = random.randint(1, 200)
- r4 = random.randint(1, 200)
- answer2 = int(input(" It's " + name1 + "'s turn: " + str(r3) + " + " + str(r4) + " = "))
- result2 = r3 + r4
- if answer2 == result2:
- counter2 += 1
- print("YOU ARE RIGHT!")
- else:
- print("WRONG ANSWER, SORRY!")
- print()
- print("* * * * * * RESULTS * * * * * * *")
- print(name1 + ": " + str(counter1) + " correct answers.")
- print(name2 + ": " + str(counter2) + " correct answers.")
- print()
- if counter1 > counter2:
- print(name1 + ", wins! ")
- print(name2 + ", better luck next time...")
- elif counter1 < counter1:
- print(name2 + ", wins! ")
- print(name1 + ", better luck next time...")
- else:
- print("It's a tier guys.")
- print(name1 + " and " + name2 + " you are in the same level in maths!")
- print("* * * * * * * * * * * * * * * *")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement