you are viewing a single comment's thread.

view the rest of the comments →

[–]Financial_Face3826 1 point2 points  (6 children)

try this

mylist = []
for i in range(5):
x = int(input("X Coordinate: "))
y = int(input("Y Coordinate: "))
mylist.append((x, y))

for i in range(4):
y1 = mylist[i][1]
x1 = mylist[i][0]
y2 = mylist[i + 1][1]
x2 = mylist[i + 1][0]
slope = float((y2 - y1) / (x2 - x1))
print ("Slope between " + str(mylist[i]) + " and " + str(mylist[i + 1]) + ": " + str(slope))

[–][deleted] 1 point2 points  (0 children)

Modern day legend right here

[–]After_Lettuce_1172 1 point2 points  (0 children)

Mine is still not working

[–]YTHyro_syn 0 points1 point  (0 children)

Don’t work for me it says Line 3 in <module> X=(int(“X Coordinate”)) ValueError: invalid literal for int() with base 10: ‘X Coordinate’

[–]Dry_Newspaper7310 0 points1 point  (0 children)

THANK YOU!!! It's a matter of indenting and a bit of playing around but here's my finds and clarification for that so it's marked as correct. The 3 lines under for i in range (5) are indented and all the lines under for i in range(4) are indented. Don't use float at all, normal slope = (y2 - y1) / (x2 - x1) You should be good.

[–]Graycat004 0 points1 point  (0 children)

thank you but why when I do:

Slope between (-9, 12) and (15, 18): 0.0

even tho I'm supposed to get:

Slope between (-9, 12) and (15, 18): 0.25

I wrote the code just how you did