First of all I know this question has been solved, but none of the online forums really explain it well, I am really confused with this question.
Suppose you choose at random a real number X from the interval $[2; 10]$.
(a) Find the density function $f(x)$ and the probability of an event $E$ for this experiment, where $E$ is a subinterval $[a; b]$ of $[2; 10]$.
(b) From (a), find the probability that $X > 5$, that $5 < X < 7$, and that $X^2 -12X + 35 > 0$.
For instance for part a, $f(x)= 1/8$. Why? If $X$ is chosen from the interval $[2;10]$, which means $2\le x\le 10$, from here there are nine numbers, so why is it $1/8$?
You are dealing with continuous random variable, not a discrete one.
The interval is a real number line segment of length $8$. The uniform selection of REAL numbers from this interval will thus require a probability density of $\tfrac 1 8$, in order that this integral is unity.
$$\int_{[2;10]} f_X(x)\operatorname d x = \int_2^{10} \frac 1 8 \operatorname d x = 1$$
This leads into (b):
$$\mathsf P(a\leq X\leq b) = \int_a^b \tfrac 1 8\operatorname d x = \frac {b-a}{8} \qquad \mbox{iff }\Big[ 2\leq a\leq b\leq 10\Big]$$
PS:
As mentioned above, you are dealing with a real number interval, so there are many, many, many more real numbers in the interval than those integers. As to why the interval is of length $8$ when there are nine integers in the interval, refer to what is known as the "Fence Post Error".
Consider this: If I have nine fence posts placed in a line one metre apart, what length of fencing do I need?