I am taking a course on real analysis online and I encountered the $\epsilon-\delta$ definition for a function to be continuous.
But I wonder if I can apply it to functions which are straight lines parallel to axes. Because if say $f(x)=2$ then $\epsilon$ will be never greater than zero, because the codomain is restricted to a single value. But in $\epsilon-\delta$ definition we check for $\epsilon>0$. So does the $\epsilon-\delta$ definition to check continuity of a function applies here?
You have to keep in mind what $\epsilon$ is requiring the function to do. Take a constant function $f(x) = 2$ as you asked.
The $\epsilon-\delta$ definition demands that, for any $\epsilon > 0$ we can find a $\delta >0$ so that if $x$ is within $\delta$ of $a$, $f(x)$ is within $\epsilon$ of $f(a)$ But in the case of our constant function, $f(x)=2$ and $f(a) = 2$, so $f(x)$ is within $\epsilon$ of $f(a)$ for any $\epsilon$. Therefore any $\delta$ will do.
I think your question comes from thinking of $\epsilon$ as something that comes from the function; $\epsilon$ does not care about $f$!