Solution (source code)

= Solution

The density is symmetric about $7/2$, giving <expected value> $\mathbb E[X]=7/2$. Its second <moment> is $\mathbb E[X^2]=\frac14(\int_1^3x^2dx+\int_4^6x^2dx)=89/6$. Therefore
$$
\boxed{\operatorname{Var}(X)=\frac{89}{6}-\frac{49}{4}=\frac{31}{12}.}
$$
Equivalently, each equally weighted interval has variance $1/3$ and its centre is $3/2$ from the overall mean, giving $1/3+9/4$ by the <law of total variance>.