This article mainly introduces the mathematical arithmetic exercise program (after Addition, subtraction, multiplication, division, and so on) made by Python. if you need it, you can refer to the recently fascinated Python program.
The math calculation exercise program for Xiaobao using Python (four arithmetic operations added in January 2015 )!
The oral computing game for Xiaobao:
# The math arithmetic exercise program that I used for Xiao Bao using Python (four arithmetic operations added in January 2015 )! # The Script game for Xiaobao: import string import random input = 11 nums = 10 num = 0 righ1t = 0 # score # flagwrong = 0 # print e [1; 34 mThis text is bold blue. e [0 m print a total of % d questions: % (nums) print e [33; 45; 1 mBold yellow on magenta. e [0 m; while True: flagwrong = 0 if num> = nums: print (once in total) correct % d path/% d path question % (righ1t, nums), if righ1t> = 10: print! 100 points !!! Elif righ1t> = 8: print you are good, 80 points or more !!! Else: print. come on! Break; elif num = num + 1 x = random. randint (1,100) # number less than 100 y = random. randint (1, 10) print symbol = random. randint () # symbol = 3 # Test Division # if 0 = symbol: # Addition # Inner Loop-print question % d: % d + % d = % (num, x, y), input = raw_input () intp = string. atoi (input) print intp while intp! = (X + y): print is incorrect! % D + % d is not equal to % d % (x, y, intp) flagwrong = 1; # If you miss one time, you cannot increase the score (score). print and calculate it again, question % d: % d + % d = % (num, x, y), input = raw_input () intp = string. atoi (input) if intp = x + y: break; continue; if intp = (x + y): print is correct! % D + % d is equal to % d % (x, y, intp) if flagwrong = 0: righ1t = righ1t + 1 continue; break; elif 1 = symbol: # subtraction # Inner Loop-question if x print question % d: % d-% d = % (num, x, y), input = raw_input () intp = string. atoi (input) print intp while intp! = (X-y): print is incorrect! % D-% d is not equal to % d % (x, y, intp) flagwrong = 1; # If you miss one time, you cannot increase the score (score). print and calculate it again, question % d: % d-% d = % (num, x, y), input = raw_input () intp = string. atoi (input) if intp = x-y: break; continue; if intp = (x-y): print is correct! % D-% d is equal to % d % (x, y, intp) if flagwrong = 0: righ1t = righ1t + 1 continue; break; elif 2 = symbol: # Multiplication # Inner Loop-question # if x print question % d: % d * % d = % (num, x, y), input = raw_input () intp = string. atoi (input) print intp while intp! = (X * y): print is incorrect! % D * % d is not equal to % d % (x, y, intp) flagwrong = 1; # If you miss one time, you cannot increase the score (score). print and calculate it again, question % d: % d * % d = % (num, x, y), input = raw_input () intp = string. atoi (input) if intp = x * y: break; continue; if intp = (x * y): print is correct! % D * % d is equal to % d % (x, y, intp) if flagwrong = 0: righ1t = righ1t + 1 continue; break; elif 3 = symbol: # Division # Inner Loop-question if x print question % d: % d/% d = % (num, x, y), print operator? :, Input = raw_input () intp = string. atoi (input) print remainder? :, Input2yushu = raw_input () intp2yushu = string. atoi (input2yushu) print operator:, print intp, print remainder:, print intp2yushu while x! = (Intp * y) + intp2yushu): print is incorrect! % D/% d is not equal to quotient % d, remainder % d! % (X, y, intp, intp2yushu) flagwrong = 1; # If you miss one time, you cannot increase the score (score) by calculating print again. question % d: % d/% d Operator =? % (Num, x, y), input = raw_input () intp = string. atoi (input) print remainder? =, Input2yushu = raw_input () intp2yushu = string. atoi (input2yushu) if x = (intp * y + intp2yushu): break; continue; if x = (intp * y) + intp2yushu): print is correct! % D/% d is equal to quotient % d, remainder % d! % (X, y, intp, intp2yushu) if flagwrong = 0: righ1t = righ1t + 1 continue; break; # addition/subtraction/multiplication/Division num = 0 within 100