LearnViz CompSci
Home / Learn / Programming Fundamentals / Variables

Beginner Topic 1 of 54 Programming Fundamentals

Variables

Named storage locations holding values that can change during execution.

How it works

A variable binds a name to a memory location; assigning updates the value stored there. In typed languages the type is fixed, in dynamic ones the name can point to different types over time.

Where it is used

Counters, accumulators, user input and configuration are all held in variables, e.g. total = total + price.

Common pitfall

Using a variable before assigning it, or shadowing an outer name by accident, causes subtle bugs. Choose descriptive names.

Where it fits in the course

Variables is topic 1 of 54 in Programming Fundamentals, rated Beginner. It is the first topic in this area. The next topic is Data Types.

Practice and explore

How to study this topic

  1. Read the explanation above and restate the definition in your own words.
  2. Open the interactive lesson and answer its mini quiz.
  3. Read the common pitfall, then write a short example that avoids it.
  4. Check your understanding in the Programming Fundamentals quiz, and revisit the topic if you miss a question.

Frequently asked questions

What is Variables?
Named storage locations holding values that can change during execution. It belongs to Programming Fundamentals and is a beginner-level topic.
Where do people use Variables?
Counters, accumulators, user input and configuration are all held in variables, e.g.
What is the most common mistake with Variables?
Using a variable before assigning it, or shadowing an outer name by accident, causes subtle bugs.
What should I learn before this topic?
Nothing earlier in Programming Fundamentals is required. This is where the area begins.
How can I practice it?
Answer the mini quiz in the interactive lesson, then take the Programming Fundamentals quiz.
Is Variables hard to learn?
It is a Beginner topic, so it works as an entry point. If the terms are new, read the explanation twice and try the visualizer before the quiz.
How long does it take to learn Variables?
Most learners can read the explanation and finish the interactive lesson in under an hour. Fluency comes from applying the idea, so plan a few short practice sessions with the quiz.
Which topics are related to Variables?
Data Types, Operators, Expressions are closely connected. The full list is in the related topics section of this page.
What should I study after Variables?
Continue with Data Types, the next topic in Programming Fundamentals.

Related topics