The slope is defined as ratio of change is y-coordinate to the corresponding change in x-coordiante. So formula for the slope is,

Part 1:
If line is horizontal, then y-coordinate remain same for the changes is x-coordinate, means if x-coordinate change by certain number then y coordinate does not change or value of dy is 0.
So slope of horizontal line is,

Thus slope of horizontal line is 0.
Part 2:
If line is vertical then x-coordinate remain same for the change is y -coordinates, means if y-coodinate change by certain number then change in x-cordinate is 0 or value of dx is 0.
So slope of vertical line is,
![\begin{gathered} m=(dy)/(0) \\ =\text{undefined} \end{gathered}]()
Thus slope of vertical line is undefined.