</>Learn to Write Code
LearnPseudocodeReal CodeLanguagesVideosCode TalkAbout
Learn → Programming Fundamentals → Variables & Data

Programming Fundamentals

01Variables02Operators03Input & Output04Sequence05Conditions06Loops07Functions08Objects
Lesson 1 of 8·Beginner

Variables & Data

Give information a name so your program can remember it and change it later.

Related:variablevalueassignmentreassignmentdata

Variables are labeled boxes

A variable is a named place where the computer remembers something.

Think of a box with a label on it. The label is the variable name. The thing inside the box is its value. You can look at the value later, or replace it with a new one.

  • Name the information.
  • Store a value.
  • Use the name later.
  • Change the value when the program needs to.
The important idea is not the punctuation used by a language. The idea is: give a value a name, then use that name.
Try it: Imagine a game score. What variable name would you use, and what value should it have when the game starts?

Describe the logic before the syntax

Our pseudocode says exactly what we want the program to do without choosing a programming language yet.

Pseudocode
CREATE playerName AS "Brian"
CREATE score AS 0

CHANGE score TO 10

SHOW playerName
SHOW score
CREATE gives a value a name. CHANGE replaces the value. SHOW displays it.

The same idea in Python

Python uses = for both the first assignment and later reassignment. The variable names still play the same role as they did in pseudocode.

Python
playerName = "Brian"
score = 0

score = 10

print(playerName)
print(score)

The same idea in JavaScript

JavaScript can create variables with let when their values may change. Semicolons are syntax; the underlying logic is unchanged.

JavaScript
let playerName = "Brian";
let score = 0;

score = 10;

console.log(playerName);
console.log(score);

The same idea in C#

C# normally declares the type of data the variable stores. string holds text and int holds whole numbers.

C#
string playerName = "Brian";
int score = 0;

score = 10;

Console.WriteLine(playerName);
Console.WriteLine(score);

The same idea in Java

Java also declares variable types. The program still creates two names, changes score, and displays both values.

Java
String playerName = "Brian";
int score = 0;

score = 10;

System.out.println(playerName);
System.out.println(score);

The same idea in C++

C++ uses typed variables as well. std::cout is simply this language's way to SHOW a value.

C++
std::string playerName = "Brian";
int score = 0;

score = 10;

std::cout << playerName << '\n';
std::cout << score << '\n';
Lesson 1 of 8 · Concept
Start of courseNext Lesson: Operators →

Learn to Write Code

Learn the idea first, write it in pseudocode, then see how real programming languages express the same logic.

Learn

CurriculumPseudocode StandardLanguagesReal Code

Elsewhere

Code TalkAbout BriancodeBetter on YouTubeSupporting files on GitHubAdvertising & Promotions
© 2026 Learn to Write Code. Educational content and examples are provided for learning purposes.