Four arithmetic random number

Random Import
COUNT = 0
right = 0
the while True:
A = the random.randint (0,. 9)
# as the divisor
B = the random.randint (. 1,. 9)
OP = [ '+', '-', '*', ' // ']
D = the random.choice (OP)
Print ('% S% D = D% '% (a, D, B))
Question = iNPUT (' enter your answer: (q exit) ')
RESULT1 A + B =
result2 = A - B
result3 = A * B
result4 A // B =
IF Question == STR (RESULT1):
Print ( 'the correct answer')
right. 1 + =
COUNT + =. 1
elif Question == STR ( result2):
Print ( 'the correct answer')
right. 1 + =
COUNT + =. 1
elif Question == STR (result3):
Print ( 'the correct answer')
right += 1
count += 1
Question == STR elif (result4):
Print ( 'the correct answer')
right. 1 + =
COUNT + =. 1
elif Question == 'Q':
BREAK
the else:
Print ( 'wrong answer')
COUNT = +. 1

right = Percent / COUNT
Print ( 'end of the test, were answered questions% d,% d is the correct number, the correct rate .2f %%%'
% (COUNT, right, Percent *
100)) ----- -----------
Disclaimer: this article is CSDN blogger original article "sura_1988", and follow CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/weixin_43314056/article/details/86514047

Guess you like

Origin www.cnblogs.com/smiorboy/p/11518667.html