import random
operators = ['+', '-', '*', '/']
operator = random.choice(operators)
num1 = random.randint(1, 100)
num2 = random.randint(1, 100)
if operator == '/':
# Ensure division results in a whole number or a decimal with two decimal places
if num1 % num2 != 0:
num1 = num1 + (num2 - num1 % num2)
num2 = random.randint(1, 10)
expression = f'{num1} / {num2:.2f}'
else:
expression = f'{num1} / {num2}'
else:
expression = f'{num1} {operator} {num2}'
print(expression)
程序流程图