Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Variable

From Groundhog Learning
Revision as of 16:09, 21 October 2025 by Groundhog (talk | contribs) (Updated via bot)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

A named place in a computer program where you can store and change a value.

Details

Variables are like labeled boxes: you can store something inside, check what’s there, and update it.

They make programs flexible by allowing handling values that change during execution.

Consider keeping track of a player’s score:

🤖 Pseudocode

score = 0                   # store the initial value
score = 10                  # change the value
"Current Score:" score      # use the current value

A variable creates a space in memory called score to hold the player’s score.

This allows the game to update the score as it changes and display it to the player.



To use a variable, we need to declare it first.

Declaring a variable, consists of telling the program to reserve a piece of memory to store some data.

Check Related Actions for details on how to perform different actions with variables.

Related Concepts

Related Actions

References