Glossary
Assignment
The process of giving a variable a value for the first time. In many programming languages, this is done using an assignment operator like `=`.
Example:
When you write player_name = "Alice", you are performing an assignment, giving the player_name variable the value "Alice".
Booleans (bool)
A data type that represents truth values, holding either `True` or `False`. They are fundamental for conditional logic and decision-making in programs.
Example:
In a game, a variable is_game_over might be set to True when the player loses all their lives, triggering the end screen.
Data types
Categories that classify the kind of value a variable can hold. They determine what operations can be performed on the data.
Example:
Understanding data types helps you know that you can add two numbers together, but you can't directly add a number to a word.
Floats (float)
A numerical data type used to store numbers that have a decimal point. They are used for values that require fractional precision.
Example:
A temperature reading like 98.6 degrees Fahrenheit or a price like $19.99 would be stored as a float.
Integers (int)
A numerical data type used to store whole numbers, including positive numbers, negative numbers, and zero, without any decimal points.
Example:
The number of students in a class, like 25, would be stored as an integer because you can't have half a student.
Lists (list)
An ordered collection of items, which can include elements of different data types. They are mutable, meaning their contents can be changed after creation.
Example:
A shopping cart containing ["milk", "eggs", "bread"] is a list of items, and you can add or remove items from it.
Reassignment
The act of changing the value of an already existing variable. The variable will then hold the new value, overwriting its previous content.
Example:
If lives = 3 initially, and then later lives = lives - 1 is executed, this is a reassignment that updates the lives variable to 2.
Strings (str)
A data type used to store sequences of characters, such as letters, words, numbers, or symbols. They are typically enclosed in quotation marks.
Example:
Your name, "Alex Johnson", or a message like "Game Over!" are examples of strings.
Variable
A named storage location in a computer's memory that holds a value. It acts as a container for data that can be used and manipulated within a program.
Example:
In a game, score could be a variable that stores the player's current points, starting at 0 and increasing as they play.