Skip to content

Instantly share code, notes, and snippets.

@k4kfh
Last active August 29, 2015 14:27
Show Gist options
  • Save k4kfh/ac751d2925e621895c85 to your computer and use it in GitHub Desktop.
Save k4kfh/ac751d2925e621895c85 to your computer and use it in GitHub Desktop.
Point Slope Form Equation Builder
#!/usr/bin/env python
print("Hampton [k4kfh] - blog.evilgeniustech.com")
firstx = float(input("What is the first X coordinate? "))
firsty = float(input("What is the first Y coordinate? "))
print("Ordered pair for first point: (%d, %d)") % (firstx, firsty)
secondx = float(input("What is the second X coordinate? "))
secondy = float(input("What is the second Y coordinate? "))
print("Ordered pair for second point: (%d,%d)") % (secondx, secondy)
rise = firsty - secondy
run = firstx - secondx
slope = (secondy - firsty)/(secondx - firstx)
print("Slope: %d/%d or %d") % ((firsty-secondy), (firstx-secondx), slope)
print("Point Slope Form Equation:")
print("y - %d = %d/%d(x - %d)") % (firsty, rise, run, firstx)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment