Files
python/小乔证件/chuti.py
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

80 lines
1.9 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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("")