Write a program to compute the slope of a line between two points (x1, y1) and (x2, y2).
Slope = y2-y1/x2-x1
Code
# Python program for slope of linedef slope(x1, y1, x2, y2):if(x2 - x1 != 0):return (float)(y2-y1)/(x2-x1)return None# driver codex1 = 4y1 = 2x2 = 2y2 = 5print("Slope is :", slope(x1, y1, x2, y2))
Output
Slope is : -1.5
Happy coding :)
0 Comments
Post a Comment