Def number_chinese (a) :
If a<10:
If a==0:
Number="zero"
Elif a==1:
Number="a"
Elif a==2:
Number="2"
Elif a==3:
Number="three"
Elif a==4:
Number="4"
Elif a==5:
Number="5"
Elif a==6:
Number="six"
Elif a==7:
Number="7"
Elif a==8:
Number="eight"
Elif a==9:
Number="nine"
Return the number
The else:
B=a//10
If b==1:
Number1=""
Elif b==2:
Number1="2"
Elif b==3:
Number1="three"
Elif b==4:
Number1="4"
Elif b==5:
Number1="5"
Elif b==6:
Number1="six"
Elif b==7:
Number1="7"
Elif b==8:
Number1="eight"
Elif b==9:
Number1="nine"
C=a % 10
If c==0:
Number2=""
Elif c==1:
Number2="a"
Elif c==2:
Number2="2"
Elif c==3:
Number2="three"
Elif c==4:
Number2="4"
Elif c==5:
Number2="5"
Elif c==6:
Number2="six"
Elif c==7:
Number2="7"
Elif c==8:
Number2="eight"
Elif c==9:
Number2="nine"
Return (number1 + "ten" + number2)
Import the random
I=0
List=[]
For I in range (10) :
Num_1=random. Randint (0, 100)
Num_2=random. Randint (0, 100)
Way=random. Randint (0, 3)
If way==0:
Math="plus"
Right=num_1 + num_2
Elif way==1:
Math="reduction"
Right=num_1 - num_2
Elif way==2:
Math="on"
Right=num_1 * num_2
The else:
Math="addition"
Right=num_1/num_2
I +=1
First word="{0} : {1} {2} {3} how much?" The format (I, number_chinese (num_1), math, number_chinese (num_2))
Answer=input (word)
Answer=int (answer)
If the answer!=right:
List. Append (word + "your answer is: {0}, the correct answer is {1}". The format (answer, right))
The else:
The continue
For Leo in the list:
Print (Leo)
CodePudding user response:
Review, or should be translated in dict, but more than ten Numbers if there should be a better way to translate