given that f is a bernoulli random variable with parameter p=0.3, what is expectation and variance of f?
Call that random variable $\displaystyle X$, then you have
$\displaystyle \mathrm{E}(X)=0\cdot\mathrm{P}(X=0)+1\cdot \mathrm{P}(X=1)=p$
And the variance is
$\displaystyle \mathrm{var}(X)=\mathrm{E}(X^2)-\mathrm{E}^2(X)=p-p^2=p(1-p)$
Where the value of $\displaystyle \mathrm{E}(X^2)$ is $\displaystyle p$ as well, because $\displaystyle X^2$ still is the same random variable (in this particular case).
Maybe you are wondering why $\displaystyle \mathrm{var}(X)=\mathrm{E}(X^2)-\mathrm{E}^2(X)$ should be true? That's because
$\displaystyle \mathrm{var}(X)=\mathrm{E}((X-\mathrm{E}(X))^2)=\mathrm{E}(X^2)-2\mathrm{E}^2(X)+\mathrm{E}^2(X)=\ldots$
Don't know why I'm writing this: it's almost certainly to be found in Wikipedia.