Expected value of random variable that is defined by another Suppose I have a random variable:
\begin{equation}
X \sim
\begin{cases}
1 \text{ with probability } p \\
y \sim \mathit{unif}(1,k) \text{ with probability } 1 - p
\end{cases}
\end{equation}
Where $\mathit{unif}$ is the discrete uniform distribution. I am trying to compute the expected value $E[X].$ I think it should just be simply:
\begin{equation}
1 \cdot p + E[y] \cdot (1-p) = 1 \cdot p + (1 + k)/2 \cdot (1-p)
\end{equation}
But I am not sure if I am overlooking something.

Your answer is okay and is justified below.
You can  write:$$X=B+(1-B)Y$$where $B\sim\text{Bernoulli}(p)$ and $Y\sim\text{Unif}(k)$ are independent random variables.
Then:$$\mathbb EX=\mathbb EB+\mathbb E[(1-B)Y]=\mathbb EB+\mathbb E(1-B)\mathbb EY=p+(1-p)\left(\frac12+\frac12k\right)$$
This way of working is recommendable in situations where the rv is defined by means of cases.
