全局找不到Jython/Python名称

全局找不到Jython/Python名称,python,jython,Python,Jython,请帮助我,我遇到了以下错误: diagonal Name not found globally. A local or global name could not be found. You need to define the function or variable before you try to use it in any way. 你能帮助我如何使用print.now和显示这三个变量吗。 谢谢 您正在传递p,但在执行以下操作之前未声明: computeSquareFeatures(

请帮助我,我遇到了以下错误:

diagonal Name not found globally.
A local or global name could not be found. You need to define the function or variable before you try to use it in any way.
你能帮助我如何使用print.now和显示这三个变量吗。 谢谢

您正在传递p,但在执行以下操作之前未声明:

computeSquareFeatures(p)
您可以使用函数内的输入设置p

你还需要在函数中输入pan int,否则你的面积计算就不会像你想的那样,确保你已经导入了数学和打印。现在看起来也不正确

工作函数的一个示例:

import math
# removed p as you are taking getting it as input
def computeSquareFeatures():
  p = int(raw_input("Enter square side length: "))
  area = p*p
  perimeter = p*4
  diagonal = math.sqrt(2*(p**2))
  print("Area is %d, Perimeter is %d, Diagonal length is %d") %(area, perimeter, diagonal)

computeSquareFeatures()
其工作原理如下所示:

$jython jt.py
Enter square side length:33
Area is 1089, Perimeter is 132, Diagonal length is 46

print.Now从何而来?我如何声明为intjust ComputesQuareFeatures 123但请记住,你一输入就覆盖了123是什么意思?我的意思是传递你喜欢的任何数字,这与你在任何情况下重新分配p都没有关系。你能把它放在我代码中的位置吗?对不起,我刚开始使用这种语言
$jython jt.py
Enter square side length:33
Area is 1089, Perimeter is 132, Diagonal length is 46