BACK TO DIRECTORY
Programming FoundationsAugust 18, 20264 min read

Variables and Memory: Storing Data Like a Pro

AUTHOR: elv1labs Academy // elv1labs
VARIABLES AND MEMORY: STORING DATA LIKE A PRO Programs process data. To keep track of values—such as a player's score, an email address, or a system setting—programs store data in variables. Under the hood, computer memory (RAM) is organized as a large grid of storage addresses. A variable is a named label pointing to a specific address, allowing you to read or write data without remembering physical hex addresses. DATA TYPES AND MEMORY ALLOCATION In languages like C, you must declare the variable's type before storing data. This tells the compiler how much memory to set aside. C Example: int score = 100; char grade = 'A'; float height = 5.9; - The "int" type reserves space for a whole number (typically 4 bytes). - The "char" type reserves space for a single character (1 byte). - The "float" type reserves space for a decimal number (typically 4 bytes). In dynamically typed languages like Python, the interpreter assigns the type automatically at runtime: Python Example: score = 100 grade = 'A' height = 5.9 NAMING VARIABLES AND RESERVED KEYWORDS When writing code, you cannot name variables using words reserved for the language's syntax. These are called keywords. In Python, reserved keywords include: True, False, None, import, def, class, return, if, else, while, for Naming a variable "class = 5" causes a syntax error because the compiler interprets "class" as an instruction to define a new object prototype. Variable naming rules: 1. Must begin with a letter or an underscore. 2. Cannot begin with a number. 3. Cannot contain spaces or special characters. 4. Are case-sensitive (score and Score are different variables). References: "Python Keywords.pdf" & Ray Dawson, "Programming in ANSI C", Section 2: Constants and Variables.

Interested in building an enduring custom system?

Skip the template constraints. Schedule an advisory call with our engineering team to map your relational database schema and API routing pipelines.

Book Systems Consultation