我正在制作一个数学求解程序,它不断将整数打印为小数。就像 1 是 1.0,5 是 5.0,我的代码是:
print("Type in the cooridinates of the two points.")
print("")
print("---------------------")
print("First point:")
x1 = int(input("X: "))
y1 = int(input("Y: "))
print("")
print("---------------------")
print("Second point:")
x2 = int(input("X: "))
y2 = int(input("Y: "))
m = (y1-y2) / (x1-x2)
b = y1 - m * x1
round(m, 0)
round(b, 0)
print("Completed equation:")
print("")
if b < 0:
print("Y = "+ str(m) +"X - "+ str(b) +".")
elif b > 0:
print("Y = "+ str(m) +"X + "+ str(b) +".")
elif b == 0:
print("Y = "+ str(m) +"X.")
input("Press enter to continue.")