Quiz
import getpass, sys
correct = 0
def questionAnswer(prompt):
print("question: " + prompt)
ans = input()
print("Answer: " + ans)
return ans
def questionRespone(prompt):
print("question: " + prompt)
ans = input()
print("I got a number :",ans)
return ans
def questi():
global correct
res = questionRespone("1 + 1 = ? ")
if res == "2":
print(res + " is correct")
correct += 1
else:
print(res + " is incorrect")
rep = questionRespone("2 + 3 = ? ")
if rep == "5":
print(rep + " is correct")
correct += 1
else:
print(rep + " is incorrect")
reg = questionRespone("3 + 5 = ? ")
if reg == "8":
print(reg + " is correct")
correct += 1
else:
print(reg + " is incorrect")
print((str)((float)(correct/quest*100)) + "%")
quest = 3
print('Hello, ' + getpass.getuser() + " running " + sys.executable)
print("You will be asked " + str(quest) + " questions.")
a = questionAnswer("Are you ready to take the test[y/n]? ")
if a == "y":
questi()
else:
print("......")