In mathematics and programming, a variable is a named entity that holds a value which can change. In programming, variables are created in RAM, require declaration with a type, and must be initialized before use. Constants, on the other hand, are identifiers whose values remain unchanged during program execution.