Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 问题,为什么我的程序在调用checkInteger函数时不进行处理?_Python_Function_Conditional Statements_Main_Statements - Fatal编程技术网

Python 问题,为什么我的程序在调用checkInteger函数时不进行处理?

Python 问题,为什么我的程序在调用checkInteger函数时不进行处理?,python,function,conditional-statements,main,statements,Python,Function,Conditional Statements,Main,Statements,为什么调用checkInteger函数时程序没有处理 def main(): 打印(“Kaylees质数检查器”) numChoice=int(输入(“请键入一个数字:”) checkInteger() def checkInteger(numChoice): 如果数字%2==0: 打印(“您的数字不是素数。”) 其他: 打印(“你的数字是素数。”) main() 看起来您需要checkInteger的参数,还应该命名参数编号,或者将编号更改为numChoice。无论哪种方式,它都必须是相同的您

为什么调用checkInteger函数时程序没有处理

def main():
打印(“Kaylees质数检查器”)
numChoice=int(输入(“请键入一个数字:”)
checkInteger()
def checkInteger(numChoice):
如果数字%2==0:
打印(“您的数字不是素数。”)
其他:
打印(“你的数字是素数。”)
main()

看起来您需要checkInteger的参数,还应该命名参数编号,或者将编号更改为numChoice。无论哪种方式,它都必须是相同的

您必须将一个参数传递给函数checkInteger,因为它被定义为在您的定义中使用一个。

请格式化您的代码。此外,请澄清“不处理”的含义。据我所知,这段代码应该抛出一个异常;是这样吗?我的程序将打印出“Kaylees素数检查器”,然后要求键入一个数字,但随后告诉我缺少1个必需的位置参数:“数字”。我知道你们说我需要一场辩论,但我不明白。