Two Points: Find Slope and Intercept.

Given two points, $$ p_1 = (x_1, y_1)$$ $$ p_2 = (x_2, y_2)$$ For the line passing through these two points, find the:
Fig 1. Two points. Point 1: (1, 2) and Point2: (5, 4).
Notes and Code Outcome

Slope

The slope of the line is the change in y divided by the change in x: $$ \text{slope} = \frac{\Delta y}{\Delta x}$$
For two points, the change in y and change in x are: $$ \Delta y = y_2 - y_1 $$ $$ \Delta x = x_2 - x_1 $$
The output of your program should be something like:

            The slope is: 0.5
          

Intercept

Finding the intercept requires a little algebra. Since the general equation for a straight line is: $$ y = mx+b$$ where: $$ m = \text{slope} $$ $$ b = \text{intercept}$$ so to find the intercept we solve this equation for b: $$ y - mx = b $$ therefore, $$ b = y - mx $$ since we already calculated the slope (m), and we know the x and y values of at least one point, we can substitute in the values: $$ x = x_1 $$ $$ y = y_1 $$ to get: $$ b = y_1 - m x_1 $$
The output of your program should be something like:

            The slope is: 0.5
            The intercept is: 1.5
          
Exercise: Draw a graph showing the two points and the line between them, then extend the line to the boundaries of your graph.