所以,我有一个函数可以生成随机整数,并在其中两个整数之间放置一个运算符,以便我的朋友可以进行数学运算。我希望有多个函数可以在每次交互后通过 while 循环调用。我需要一种方法来实际选择函数并调用它们。我从 1 个函数开始,并将代码放在函数定义的底部。
所以我认为它会弹出并询问我要加载什么东西。但什么也没发生。没有错误,没有“程序结束”,什么都没有。无论如何,这是我的代码:
from random import randint
loop = 1
while loop < 2:
def MathOnYourOwn():
opChoose = int(input("Choose an operator: type 1 for addition, 2 for subtraction, 3 for multiplication, 4 for division. "))
Math1 = randint(1, 9999999999999999999999999999999999)
Math2 = randint(1, 9999999999999999999999999999999999)
if opChoose == 1:
print(f"{Math1} plus {Math2}.")
if opChoose == 2:
print(f"{Math1} minus {Math2}.")
if opChoose == 3:
print(f"{Math1} times {Math2}.")
if opChoose == 4:
print(f"{Math1} divided by {Math2}.")
funcChoose = input("Which area do you want to load? Math... ")
if funcChoose == "Math.":
print(MathOnYourOwn())
def MeanMedianModeECT():
print("hi")