You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
import random
|
|
|
|
|
|
|
|
|
|
cnt = 11
|
|
|
|
|
# 乘法
|
|
|
|
|
for i in range(1, cnt):
|
|
|
|
|
a = random.randint(100, 999)
|
|
|
|
|
b = random.randint(10, 99)
|
|
|
|
|
print(str(a) + "×" + str(b) + "=", end=" ")
|
|
|
|
|
if i % 2 == 0:
|
|
|
|
|
print("")
|
|
|
|
|
print("")
|
|
|
|
|
print("")
|
|
|
|
|
print("")
|
|
|
|
|
# 除法
|
|
|
|
|
for i in range(1, cnt):
|
|
|
|
|
a = random.randint(100, 999)
|
|
|
|
|
b = random.randint(10, 99)
|
|
|
|
|
print(str(a) + "÷" + str(b) + "=", end=" ")
|
|
|
|
|
if i % 2 == 0:
|
|
|
|
|
print("")
|
|
|
|
|
print("")
|
|
|
|
|
print("")
|
|
|
|
|
print("")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 获取一个可以整除的三位数除两位数
|
|
|
|
|
def getDivStr():
|
|
|
|
|
while True:
|
|
|
|
|
a = random.randint(10, 99)
|
|
|
|
|
b = random.randint(10, 40) # 倍数
|
|
|
|
|
if a * b >= 1000:
|
|
|
|
|
continue
|
|
|
|
|
return str(a * b) + "÷" + str(a)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 获取形如 (230-182÷14) × 21
|
|
|
|
|
def getSiZe1():
|
|
|
|
|
while True:
|
|
|
|
|
a = random.randint(100, 999)
|
|
|
|
|
b = random.randint(10, 99)
|
|
|
|
|
s = "(" + str(a) + "-" + getDivStr() + ")×" + str(b)
|
|
|
|
|
s1 = s.replace("÷", "/").replace("×", "*")
|
|
|
|
|
x = eval(s1)
|
|
|
|
|
if x < 0:
|
|
|
|
|
continue
|
|
|
|
|
return s
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for i in range(1, cnt):
|
|
|
|
|
print(getSiZe1(), end=" ")
|
|
|
|
|
if i % 2 == 0:
|
|
|
|
|
print("")
|
|
|
|
|
print("")
|
|
|
|
|
print("")
|
|
|
|
|
print("")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 获取形如 [(256+88×3)] ÷ 43
|
|
|
|
|
def getSiZe2():
|
|
|
|
|
while True:
|
|
|
|
|
a = random.randint(10, 99)
|
|
|
|
|
|
|
|
|
|
x = random.randint(100, 999)
|
|
|
|
|
y = random.randint(10, 99)
|
|
|
|
|
z = random.randint(2, 9)
|
|
|
|
|
|
|
|
|
|
s = "[(" + str(x) + "+" + str(y) + "×" + str(z) + ")]"
|
|
|
|
|
s1 = s.replace("÷", "/").replace("×", "*")
|
|
|
|
|
x = eval(s1)
|
|
|
|
|
if (x[0] % a) > 0:
|
|
|
|
|
continue
|
|
|
|
|
return s+'÷'+str(a)
|
|
|
|
|
for i in range(1, cnt):
|
|
|
|
|
s=getSiZe2()
|
|
|
|
|
print(s, end=" ")
|
|
|
|
|
if i % 2 == 0:
|
|
|
|
|
print("")
|
|
|
|
|
print("")
|
|
|
|
|
print("")
|
|
|
|
|
print("")
|