【发布时间】:2017-02-11 19:51:10
【问题描述】:
所以我正在尝试编写一段代码来计算直线的斜率。我正在使用 3.6。
y1 = float(input("First y point: "))
y2 = float(input("Second y point: "))
x1 = float(input("First X point: "))
x2 = float(input("Second X point: "))
slope = (y2 - y1)/(x2 - x1)
print("The slope is:",slope)
每当我输入使答案不合理的数字时,答案就会变成小数。是否可以将其保留为分数?
【问题讨论】:
标签: python python-3.x input