私信  •  关注

Mudits

Mudits 最近创建的主题
Mudits 最近回复了
6 年前
回复了 Mudits 创建的主题 » 如何在python中将数字转换为符号(数学)

您可以使用字典执行此操作:

operators = {
   1: "+",
   2: "-",
   3: "/",
   4: "*"
}
operators = operator[z] // where z is the random integer for gettig the operator.

在你的书面声明中

print("What is " + str(x)+" " + str(operator)+" " + str(y)+"?")