A random variable X is a function mapping outcomes in a sample space to real numbers. Discrete random variables have countable ranges; continuous random variables have uncountable ranges over intervals. Random variables enable probabilistic reasoning using numerical methods.
Despite the name, a random variable is not a variable in the algebraic sense — it is a function. You already know from your study of sample spaces that an experiment has outcomes collected into a set Ω. A random variable X is a rule that assigns a real number to each outcome: X : Ω → ℝ. When you roll a die, Ω = {1, 2, 3, 4, 5, 6} and the random variable X(ω) = ω is trivially the identity. But the power comes from non-trivial assignments: X(ω) = 1 if ω is even, 0 otherwise — now X encodes a yes/no question as a number. This translation from abstract outcomes to numbers is what allows all of real analysis and calculus to enter probability.
The classification into discrete and continuous types mirrors the range of the function. A discrete random variable takes values in a countable set — a finite list or the natural numbers. Counting problems produce discrete random variables: the number of heads in ten flips, the number of defective items in a batch. A continuous random variable takes values in an uncountable set, typically an interval of ℝ. Measurement problems produce continuous random variables: the height of a randomly chosen person, the time until a lightbulb fails. The distinction matters because the two types require different mathematical machinery to describe: summation for discrete, integration for continuous.
There is a subtlety worth dwelling on: probability is not assigned to individual values of a continuous random variable, but to intervals. If X is the height of a random adult in centimeters, P(X = 170.00000) = 0 — not because it can't happen, but because a single point has zero width and thus zero "area" under any probability curve. Instead, you ask P(168 ≤ X ≤ 172), which is a positive number. This is the essential difference: discrete random variables carry probability in point masses, continuous ones spread it over regions as a density.
The notation X = x (capital X for the variable, lowercase x for a realized value) reflects this functional nature. X is the function; x is what you observe when you run the experiment. Writing P(X = 3) means "the probability that the function X assigns the value 3 to the outcome that occurs." Every question about probability eventually reduces to asking about the function X — where it lands, how often it exceeds a threshold, what value it takes on average. The random variable is the bridge from the abstract world of sample spaces and events to the concrete world of numbers where computation lives.