Let $Y$ be a discrete random variable with density function: $$p(y;\theta)=\left(\frac{\theta}{2}\right)^{\lvert y\rvert}(1-\theta)^{1-\lvert y\rvert}$$ where $y\in\{-1,0,1\}$ and $\theta \in[0,1]$.
I have to find the expected value $\mathbb{E}(Y)$ and variance $\mathbb{Var}(Y)$.
Starting from the general formula for the expected value of a discrete variable $\mathbb{E}(Y) = \sum_{i=0}^n y_ip_i$:
$$p(-1)=p(1)=\left(\frac{\theta}{2}\right)^1(1-\theta)^0=\left(\frac{\theta}{2}\right),\ p(0)=\left(\frac{\theta}{2}\right)^0(1-\theta)^1=(1-\theta)$$
then
$$\mathbb{E}(Y)=(-1)\left(\frac{\theta}{2}\right)+(0)(1-\theta)+(1)\left(\frac{\theta}{2}\right)=0$$
$$\mathbb{Var}(Y)=\mathbb{E}(Y^2)-(\mathbb{E}(Y))^2=\mathbb{E}(Y^2)=(-1)^2\left(\frac{\theta}{2}\right)+(0)^2(1-\theta)+(1)^2\left(\frac{\theta}{2}\right)=\theta$$
Is that correct?