Math arithmetic _ arithmetic mental arithmetic with python for Xiao Bao (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\n"
Print "There are altogether%d titles:"% (nums)
Print "\e[33;45;1mbold yellow on magenta.\e[0m\n";
While True:
Flagwrong=0
If Num>=nums:
Print "In total (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 are good Ah, 80 points above Ah!!! "
Else
Print "also need to refuel Oh!" "
Break
Elif Num<nums:
Num=num+1

X=random.randint (1, #100以内的数字)
Y=random.randint (1, 10)
Print ""


Symbol=random.randint (0,3)
#symbol =3 #测试除法 #
If 0==symbol: #加法
# Inner Loop-do problems
Print "Question No.%d:%d+%d="% (num,x,y),
Input=raw_input ()
Intp=string.atoi (Input)
Print INTP
While intp!= (x+y):
Print "No! %d+%d not equal to%d "% (X,Y,INTP)
flagwrong=1; #错过一次, you can't do the growth of your grades (score).
Print "Calculate 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 1==symbol: #减法
# Inner Loop-do problems
If x<y:x01temp=x; X=y; Y=x01temp;
Print "Question No.%d:%d-%d="% (num,x,y),
Input=raw_input ()
Intp=string.atoi (Input)
Print INTP
While intp!= (x-y):
Print "No! %d-%d not equal to%d "% (X,Y,INTP)
flagwrong=1; #错过一次, you can't do the growth of your grades (score).
Print "Calculate 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 problems
#if x<y:x01temp=x; X=y; Y=x01temp;
Print "Question No.%d:%d*%d="% (num,x,y),
Input=raw_input ()
Intp=string.atoi (Input)
Print INTP
While intp!= (x*y):
Print "No! %d*%d not equal to%d "% (X,Y,INTP)
flagwrong=1; #错过一次, you can't do the growth of your grades (score).
Print "Calculate 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 3==symbol: #除法
# Inner Loop-do problems
If x<y:x01temp=x; X=y; Y=x01temp;
Print "Question No.%d:%d/%d="% (num,x,y),
Print "Quotient?:",

Input=raw_input ()
Intp=string.atoi (Input)
Print "Remainder is?:",
Input2yushu=raw_input ()
Intp2yushu=string.atoi (Input2yushu)


Print "Quotient:",
Print INTP,
Print "Remainder is:",
Print Intp2yushu

While x! = ((INTP * y) +intp2yushu):
Print "No! %d/%d is not equal to quotient%d, more than%d! "% ( X,y,intp,intp2yushu)
flagwrong=1; #错过一次, you can't do the growth of your grades (score).
Print "Again, section%d:%d/%d's quotient =?"% ( Num,x,y),
Input=raw_input ()
Intp=string.atoi (Input)
Print "Yu? =",
Input2yushu=raw_input ()
Intp2yushu=string.atoi (Input2yushu)

if x = = (Intp*y + Intp2yushu):
Break
Continue
if x = = ((intp*y) +intp2yushu):
Print "Right! %d/%d is equal to quotient%d,%d! "% ( X,y,intp,intp2yushu)
If flagwrong==0:
Righ1t=righ1t+1
Continue
Break


#100以内的 addition/subtraction/multiplication/division

Num=0

------------------------------------------------------------------------


"Indent Problem" temporarily select (gray) and then use the <Tab> key to achieve indentation ...

Indentation or the problem Ah!

Hopefully, Python will be able to add {} (code block, or: End with "End" to implement the block of code ...). Instead of forcing the indentation!


=====================================================================


Math arithmetic _ arithmetic mental arithmetic with python for Xiao Bao (add subtraction)

Related Article

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.