A random variable assigns a numerical value to each outcome of an experiment. A discrete random variable $X$ takes separate, countable values, such as the number of heads in three coin tosses. Its behavior is captured by a probability distribution, a table or formula giving $P(X = x)$ for every possible value $x$. Two conditions must always hold: each probability lies between $0$ and $1$, and all the probabilities sum to $1$, that is $\sum P(X = x) = 1$. This second condition is often used to solve for an unknown probability in a distribution table.
The expected value or mean of $X$ is the long-run average outcome, weighting each value by its probability: $$E(X) = \sum x\, P(X = x).$$ The expected value need not be an attainable value of $X$; for a fair die $E(X) = 3.5$. In