The equation for the intersection of two lines y1 = a1*x + b1 and y2 = a2*x + b2 is x = (b2 - b1) / (a1 - a2).
By making use of broadcasting it is easy to compute all intersections between any number of lines:
import numpy as np
# lines of the form y = a * x + b
# with lines = [[a0, b0], ..., [aN, bN]]
lines = np.array([[1, 0], [0.5, 0], [-1, 3], [1, 2]])
slopes = lines[:, 0] # array with slopes (shape [N])
slopes = slopes[:, np.newaxis] # column vector (shape [N, 1])
offsets = lines[:, 1] # array with offsets (shape [N])
offsets = offsets[:, np.newaxis] # column vector (shape [N, 1])
# x-coordinates of intersections
xi = (offsets - offsets.T) / (slopes.T - slopes)
# y-coordinates of intersections
yi = xi * slopes + offsets
This works by appling the element-wise - operator to a column vector of shape [N, 1] and it's transpose of shape [1, N]. The vectors are broadcast to a matrix of shape [N, N].
The final result are two symmetric matrices xi and yi. Each entry xi[m, n] is the intersection of lines m and n.
nan means the lines are identical (they intersect in every point). inf means the lines do not intersect.
Let's show off the result:
#visualize the result
import matplotlib.pyplot as plt
for l in lines:
x = np.array([-5, 5])
plt.plot(x, x * l[0] + l[1], label='{}x + {}'.format(l[0], l[1]))
for x, y in zip(xi, yi) :
plt.plot(x, y, 'ko')
plt.legend()
plt.show()

mis the slope?itertools.combinationsto generate the combinations