我正在创建一个程序来查找平均值、中位数、众数或范围。当我运行它时,它工作正常,直到它进入计算答案的部分。它给了我一个“不能使用灵活类型减少预制件”的错误。我已经搜索了这个错误,但找不到我需要修复的内容。这是我第一次使用 numpy,所以任何帮助都会很棒。
import sys
import numpy as np
welcomeString = input("Welcome to MMMR Calculator\nWhat would you like to calculate(Mean,Median,Mode,Range):")
if welcomeString.lower() == "mean":
meanNumbers = input("What numbers would you like to use?:")
print (np.average(meanNumbers))
stop = input()
if welcomeString.lower() == "median":
medianNumbers = input("What numbers would like to use?:")
print (np.median(medianNumbers))
stop = input()
if welcomeString.lower() == "mode":
modeNumbers = input("What numbers would you like to use?:")
print (np.mode(modeNumbers))
stop = input()
if welcomeString.lower() == "range":
rangeNumbers = input("What numbers would you like to use?:")
print (np.arange(rangeNumbers))
stop = input()