python如何使这个距离公式代码以Surd形式出现?

2024-09-30 18:34:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图为一个问题解一个距离公式,但是,我希望答案是surd形式的 python代码如下:

import math
#taking values of x and y
px1=int(input("What is value of px1?: "))
py1=int(input("What is value of py1?: "))
qx2=int(input("What is value of pqx2?: "))
qy2=int(input("What is value of qy2?: "))
#formula for the distance 
formula = ((qx2-px1)**2+(qy2-py1)**2)
i = int(math.sqrt(formula) )
print(i) 

Tags: of答案距离inputisvaluemathwhat