Let's just talk about the definition of slope. It's the change in y divided by the change in x.
In a vertical line, there is no change in x. It remains constant. Therefore,
= undefined (dividing by zero is undefined)
And in a horizontal line, there is no change in y. So,