To use, place your own values in the main loop, where the array pxc is the probabilities, and c the values to find the EV and VAR.
A discrete random variable is a type of random variable that can take on a countable set of distinct values. Common examples include the number of children in a family, the outcome of rolling a die, ...