import os
def menu():
print(" HELLO, WELCOME TO QUIZ GAME")
print("\n press 1 for start")
print("\n press 2 for exit")
choice = input("Enter your choice : ")
os.system('cls')
if choice == '1':
question()
elif choice == '2':
os.system('cls')
else:
print("Invalid Choice")
menu()
def question():
global total
total = 0
def question1():
global total
print(r"QUESTION 1. Pointing to a photograph, a man said, 'I have no brother, and that man's father is my father's son.' Whose photograph was it?")
print("\n A.His son C.His father ")
print("\n B.His own D.His nephew")
answer = input("Enter Your ans : ")
if answer == 'A':
total+=50
print("Correct answer")
else:
total-=30
print("Wrong answer")
question1()
input("Press enter to continue ;)")
os.system('cls')
def question2():
global total
print(r"QUESTION.2 If * means /, - means *, / means + and + means -, then (3 - 15 / 19) * 8 + 3 = ?")
print("\n A.-1 C.2 ")
print("\n B.8 D.1 ")
answer = input("Enter Your ans : ")
if answer == 'D':
total+=50
return print("Corrrect answer")
else:
total-=30
print(total)
return print("Wrong answer")
question2()
input("Press enter to continue ;)")
os.system('cls')
def question3():
global total
print(r"QUESTION.3 Find the letter in the 8th position when the alphabets are written in reverse alphabetical order ?")
print("\n A.A C.B ")
print("\n B.S D.E ")
answer = input("Enter your ans : ")
if answer == 'C':
total+=50
print("Correct answer")
else:
total-=30
print("wrong answer")
question3()
input("Press enter to continue ;)")
os.system('cls')
def question4():
global total
print(r"QUESTION.4 In the following question, select the odd word from the given alternatives.")
print("\n A.Neurologist C.Dentist")
print("\n B.Architect D.Pediatrician")
answer = input("Enetr your ans : ")
if answer == 'B':
total+=50
print("Coreect Answer")
else:
total-=30
print("Wrong Answer")
print(total)
question4()
input("Press enter to continue ;)")
os.system("cls")
def question5():
global total
print(r"QUESTION.5 Use the relations defined below and answer the following question \n A + B means A is the mother of B. \n A - B means A is the sister of B. \n A * B means A is the father of B. \n A / B means A is the son of B. \n A = B means A is the brother of B. \n A != B means A is the daughter of B.")
print("\n A.P - R / Q C.P + R * Q")
print("\n B.P != R * Q D.P - R + Q")
answer = input("Enter Your ans : ")
if answer == 'D':
total+=50
print("Correct Answer")
else:
total-=30
print("wrong answer")
print(total)
question5()
input("Press enter to continue ;)")
os.system("cls")
def question6():
global total
print(r"QUESTION 6. A's mother's son's only sister is B. How is A related to C, if B is the mother of C's daughter ?")
print("\n A.Brother C.Brother-in-law")
print("\n B.uncle D.Nephew")
answer = input("Enetr your ans : ")
if answer == 'C':
total+=50
print("Correct answer")
else:
total-=30
print("Wrong answer")
print(total)
question6()
input("Press enter to continue ;)")
os.system('cls')
def question7():
global total
print("QUESTION.7 If in a certain code language, 'oka peru' means 'fine cloth' ; 'meta lisa' means 'clear water' and 'dona lisa peru' means 'fine clear weather' , which word in that language means 'weather'?")
print("\n A.peru C.oka")
print("\n B.meta D.dona")
answer = input("Enter your answer : ")
if answer == 'D':
total+=50
print("Correct answer")
else:
total-=30
print("wrong answer")
question7()
input("Press enter to continue ;)")
os.system('cls')
def question8():
global total
print("QUESTION.8 Radiant : Brilliant :: Zenith : ?")
print("\n A.Peak C.Cheerful")
print("\n B.Misery D.Abet")
answer = input("Enetr Your ans : ")
if answer == 'A':
total+=50
print("Correct answer")
else:
total-=30
print("wrong answer")
question8()
input("Press enetr to continue ;)")
os.system('cls')
def question9():
global total
print("QUESTION.9 69 - 51 + 62 * 61 / 54")
print("\n A.94.04 C.88.04")
print("\n B.92.04 D.85.04")
answer = input("Enter your ans : ")
if answer == 'C':
total+=50
print("Correct answer")
else:
total-=30
print("Wrong answer")
question9()
input("Press enter to continue;)")
os.system('cls')
def question10():
global total
print("QUESTION.10 Vinu buys Rs. 40 shares paying 9 % dividend. He wants to have an interest of 12% of his money. Find the market value of each share")
print("\n A.30 C.65")
print("\n B.85 D.33")
answer = input("Enter your ans : ")
if answer == 'A':
total+=50
print("Correct answer")
else:
total-=30
print("Wrong answer")
question10()
print("Your point is : ",total)
if total == 500:
print("You won 1 lakh ")
elif total >= 400 and total <500:
print("You Won 50K")
elif total >= 300 and total < 400:
print("You Won 25K")
elif total >= 200 and total < 300:
print("You Won 10K")
else:
print("Sorry,better luck next time ")
# question()
input("Press enter to exit ;)")
答案 0 :(得分:1)
在定义了menu()
方法之后,即在question()
之前调用input("Press enter to exit ;)")
答案 1 :(得分:0)
正如其他人指出的那样,在调用question
时尚未定义名称menu()
。因此,只需将其更改为:
import os
def menu():
print(" HELLO, WELCOME TO QUIZ GAME")
print("\n press 1 for start")
print("\n press 2 for exit")
choice = input("Enter your choice : ")
os.system('cls')
if choice == '1':
question()
elif choice == '2':
os.system('cls')
else:
print("Invalid Choice")
def question():
global total
total = 0
def question1():
global total
print(r"QUESTION 1. Pointing to a photograph, a man said, 'I have no brother, and that man's father is my father's son.' Whose photograph was it?")
print("\n A.His son C.His father ")
print("\n B.His own D.His nephew")
answer = input("Enter Your ans : ")
if answer == 'A':
total+=50
print("Correct answer")
else:
total-=30
print("Wrong answer")
question1()
input("Press enter to continue ;)")
os.system('cls')
def question2():
global total
print(r"QUESTION.2 If * means /, - means *, / means + and + means -, then (3 - 15 / 19) * 8 + 3 = ?")
print("\n A.-1 C.2 ")
print("\n B.8 D.1 ")
answer = input("Enter Your ans : ")
if answer == 'D':
total+=50
return print("Corrrect answer")
else:
total-=30
print(total)
return print("Wrong answer")
question2()
input("Press enter to continue ;)")
os.system('cls')
def question3():
global total
print(r"QUESTION.3 Find the letter in the 8th position when the alphabets are written in reverse alphabetical order ?")
print("\n A.A C.B ")
print("\n B.S D.E ")
answer = input("Enter your ans : ")
if answer == 'C':
total+=50
print("Correct answer")
else:
total-=30
print("wrong answer")
question3()
input("Press enter to continue ;)")
os.system('cls')
def question4():
global total
print(r"QUESTION.4 In the following question, select the odd word from the given alternatives.")
print("\n A.Neurologist C.Dentist")
print("\n B.Architect D.Pediatrician")
answer = input("Enetr your ans : ")
if answer == 'B':
total+=50
print("Coreect Answer")
else:
total-=30
print("Wrong Answer")
print(total)
question4()
input("Press enter to continue ;)")
os.system("cls")
def question5():
global total
print(r"QUESTION.5 Use the relations defined below and answer the following question \n A + B means A is the mother of B. \n A - B means A is the sister of B. \n A * B means A is the father of B. \n A / B means A is the son of B. \n A = B means A is the brother of B. \n A != B means A is the daughter of B.")
print("\n A.P - R / Q C.P + R * Q")
print("\n B.P != R * Q D.P - R + Q")
answer = input("Enter Your ans : ")
if answer == 'D':
total+=50
print("Correct Answer")
else:
total-=30
print("wrong answer")
print(total)
question5()
input("Press enter to continue ;)")
os.system("cls")
def question6():
global total
print(r"QUESTION 6. A's mother's son's only sister is B. How is A related to C, if B is the mother of C's daughter ?")
print("\n A.Brother C.Brother-in-law")
print("\n B.uncle D.Nephew")
answer = input("Enetr your ans : ")
if answer == 'C':
total+=50
print("Correct answer")
else:
total-=30
print("Wrong answer")
print(total)
question6()
input("Press enter to continue ;)")
os.system('cls')
def question7():
global total
print("QUESTION.7 If in a certain code language, 'oka peru' means 'fine cloth' ; 'meta lisa' means 'clear water' and 'dona lisa peru' means 'fine clear weather' , which word in that language means 'weather'?")
print("\n A.peru C.oka")
print("\n B.meta D.dona")
answer = input("Enter your answer : ")
if answer == 'D':
total+=50
print("Correct answer")
else:
total-=30
print("wrong answer")
question7()
input("Press enter to continue ;)")
os.system('cls')
def question8():
global total
print("QUESTION.8 Radiant : Brilliant :: Zenith : ?")
print("\n A.Peak C.Cheerful")
print("\n B.Misery D.Abet")
answer = input("Enetr Your ans : ")
if answer == 'A':
total+=50
print("Correct answer")
else:
total-=30
print("wrong answer")
question8()
input("Press enetr to continue ;)")
os.system('cls')
def question9():
global total
print("QUESTION.9 69 - 51 + 62 * 61 / 54")
print("\n A.94.04 C.88.04")
print("\n B.92.04 D.85.04")
answer = input("Enter your ans : ")
if answer == 'C':
total+=50
print("Correct answer")
else:
total-=30
print("Wrong answer")
question9()
input("Press enter to continue;)")
os.system('cls')
def question10():
global total
print("QUESTION.10 Vinu buys Rs. 40 shares paying 9 % dividend. He wants to have an interest of 12% of his money. Find the market value of each share")
print("\n A.30 C.65")
print("\n B.85 D.33")
answer = input("Enter your ans : ")
if answer == 'A':
total+=50
print("Correct answer")
else:
total-=30
print("Wrong answer")
question10()
print("Your point is : ",total)
if total == 500:
print("You won 1 lakh ")
elif total >= 400 and total <500:
print("You Won 50K")
elif total >= 300 and total < 400:
print("You Won 25K")
elif total >= 200 and total < 300:
print("You Won 10K")
else:
print("Sorry,better luck next time ")
# question()
menu()
input("Press enter to exit ;)")