Mathematical arithmetic _ Arithmetic mental arithmetic practice program with Python (add subtraction)

Source: Internet
Author: User
Recently fascinated by Python

Use Python to do the math arithmetic mental Arithmetic Practice Program (January 2015 add arithmetic)!

Mental arithmetic game for Xiao Bao:

#用Python给小宝做的数学算数口算练习程序 (January 2015 add arithmetic)! #给小宝做的口算游戏: Import string import random input=11 nums=10 num=0 righ1t=0 #分数 # Flagwrong=0 #没错过print e[1;34mthis text is bold blue.e[0m print there are altogether%d titles:% (nums) print e[33;45;1mbold yellow on magenta.e[0 m; While true:flagwrong=0 if Num>=nums:print altogether (1 times) did the right%d/%d road title% (righ1t,nums), if righ1t>=10:print you're awesome! 100 points Ah!!! Elif Righ1t>=8:print you good ah, 80 points above Ah!!! Else:print also need to refuel Oh! Break Elif num num=num+1 x=random.randint (1, +) #100以内的数字y =random.randint (1,) print Symbol=random.randint (0,3) #symbol =3 #测试除法 # if 0==symbol: #加法 # inner Loop-do print title%d:%d+%d=% (num,x,y), Input=raw_input () intp=string.atoi (input) print INTP while Intp!= (x+y): Print is wrong! %d+%d is not equal to%d% (X,Y,INTP) flagwrong=1; #错过一次, you can't do the result (score). Print again, title%d:%d+%d=% (num,x,y), Input=raw_input () intp=string.atoi (input) if intp==x+y:break; Continue if intp = = (x+y): Print Yes! %d+%d is equal to%d% (X,Y,INTP) if flagwrong==0:righ1t=righ1t+1 continue; Break Elif 1==symbol: #减法 # Inner Loop-do title if x print%d question:%d-%d=%(Num,x,y), Input=raw_input () intp=string.atoi (input) print INTP while intp!= (X-y): print is wrong! %d-%d is not equal to%d% (X,Y,INTP) flagwrong=1; #错过一次, you can't do your grades. Print again, title%d:%d-%d=% (num,x,y), Input=raw_input () intp=string.atoi (input) if intp==x-y: break; Continue if intp = = (X-y): Print right! %d-%d is equal to%d% (X,Y,INTP) if flagwrong==0:righ1t=righ1t+1 continue; Break Elif 2==symbol: #乘法 # Inner Loop-do the title # if x print title%d:%d*%d=% (num,x,y), Input=raw_input () intp=string.atoi (input) print INTP while I Ntp!= (x*y): Print is wrong! %d*%d is not equal to%d% (X,Y,INTP) flagwrong=1; #错过一次, you can't do the result (score). Print again, title%d:%d*%d=% (num,x,y), Input=raw_input () intp=string.atoi (input) if intp==x*y:break; Continue if intp = = (x*y): Print Yes! %d*%d is equal to%d% (X,Y,INTP) if flagwrong==0:righ1t=righ1t+1 continue; Break Elif 3==symbol: #除法 # Inner Loop-do title if x print%d title:%d/%d=% (num,x,y), print quotient?:, Input=raw_input () intp=string.atoi (input) print remainder Yes?:, Input2yushu=raw_input () intp2yushu=string.atoi (Input2yushu) Print vendor:, print intp, print remainder is:, print Intp2yushu WHILe x! = ((INTP * y) +intp2yushu): Print is wrong! %d/%d is not equal to quotient%d, more than%d!% ( X,y,intp,intp2yushu) flagwrong=1; #错过一次, you can't do it. Print again, title%d:%d/%d's =?% ( 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 Yes! %d/%d is equal to quotient%d, more than%d!% ( X,y,intp,intp2yushu) if flagwrong==0:righ1t=righ1t+1 continue; Break #100以内的 addition/subtraction/multiplication/Division Num=0
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.