Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a variable in computing?
A variable is like a labeled box where you can store information. You can put data inside it, change it, and use it later in your program.
Click to reveal answer
beginner
Why do we use variables instead of writing values directly?
Variables let us reuse and change data easily without rewriting everything. It's like using a nickname instead of a full name every time.
Click to reveal answer
beginner
What types of data can variables store?
Variables can store numbers, words (text), true/false values, and more. Think of it like different kinds of items you can keep in boxes.
Click to reveal answer
intermediate
How does a computer remember the value stored in a variable?
The computer uses memory (like a big set of tiny boxes) to keep the value. The variable name is a label that points to the right box.
Click to reveal answer
beginner
What happens if you change the value of a variable?
The old value is replaced with the new one in the memory box. It's like erasing what was written on a whiteboard and writing something new.
Click to reveal answer
What is a variable best compared to in real life?
AA fixed number on a calculator
BA book with unchangeable pages
CA labeled box that holds items
DA locked safe you cannot open
✗ Incorrect
A variable is like a labeled box where you can store and change data, just like a box you can open and put things in.
Which of these can a variable NOT store?
AA physical object
BText
CTrue or False
DNumbers
✗ Incorrect
Variables store data inside the computer, not physical objects.
What happens when you assign a new value to a variable?
AThe old value is kept and the new one is ignored
BThe old value is replaced by the new one
CThe variable creates a new box
DThe computer shuts down
✗ Incorrect
Assigning a new value replaces the old value stored in the variable.
Why do programmers use variables?
ATo store and reuse data easily
BTo make programs slower
CTo confuse the computer
DTo avoid using memory
✗ Incorrect
Variables help programmers store data and reuse or change it easily.
In a computer, where is the data of a variable stored?
AIn the keyboard
BOn the internet
COn a paper note
DIn the computer's memory
✗ Incorrect
The computer stores variable data in its memory, which is like many tiny boxes inside the computer.
Explain what a variable is and why it is useful in programming.
Think about how you store things in labeled containers at home.
You got /3 concepts.
Describe how changing a variable's value works inside a computer.
Imagine writing on a whiteboard and then erasing it to write something else.
You got /3 concepts.
Practice
(1/5)
1. What is a variable in computing? Example: Think of a variable as a labeled box where you can store something.
easy
A. A container that holds data values
B. A type of computer hardware
C. A program that runs automatically
D. A tool to clean computer screens
Solution
Step 1: Understand the concept of variables
A variable is like a labeled box where you can store data such as numbers or words.
Step 2: Match the description to the options
A container that holds data values describes a container holding data values, which matches the idea of a variable.
Final Answer:
A container that holds data values -> Option A
Quick Check:
Variable = labeled box for data [OK]
Hint: Variables store data like boxes hold items [OK]
Common Mistakes:
Confusing variables with hardware
Thinking variables run programs
Mixing variables with tools or devices
2. Which of the following is the correct way to create a variable named age and store the number 25 in it?
easy
A. int age = 25
B. age = 25
C. age := 25
D. 25 = age
Solution
Step 1: Identify the correct assignment syntax
In many programming languages, assigning a value to a variable uses the format: variable = value.
Step 2: Check each option
age = 25 uses age = 25, which is the standard way to assign 25 to variable age.
Final Answer:
age = 25 -> Option B
Quick Check:
Variable assignment uses = sign [OK]
Hint: Variable name on left, value on right with = [OK]
Common Mistakes:
Putting value before variable
Using wrong assignment symbols
Confusing variable declaration syntax
3. What will be the value of total after running this code?
price = 10
quantity = 3
total = price * quantity
medium
A. 30
B. 13
C. 103
D. Error
Solution
Step 1: Understand the variables and operation
price is 10, quantity is 3, and total is assigned price multiplied by quantity.
Step 2: Calculate the multiplication
10 * 3 = 30, so total will be 30.
Final Answer:
30 -> Option A
Quick Check:
10 x 3 = 30 [OK]
Hint: Multiply values stored in variables [OK]
Common Mistakes:
Adding instead of multiplying
Concatenating numbers as strings
Expecting syntax error
4. Identify the error in this code snippet:
number = 5
Number = 10
print(number + Number)
medium
A. Missing semicolon at the end of lines
B. Cannot add two variables together
C. Variables must start with a capital letter
D. Variable names are case-sensitive, so both are different variables
Solution
Step 1: Check variable names and case sensitivity
Variables number and Number differ by case and are treated as two separate variables.
Step 2: Understand the addition operation
Adding number (5) and Number (10) is valid and results in 15.
Final Answer:
Variable names are case-sensitive, so both are different variables -> Option D
Quick Check:
Case matters in variable names [OK]
Hint: Remember variable names are case-sensitive [OK]
Common Mistakes:
Assuming variables with different cases are same
Expecting syntax error for missing semicolons
Thinking variables can't be added
5. You want to store the names and ages of three friends in variables. Which approach correctly uses variables to store this data for easy access later?
Step 1: Understand the need for easy access to names and ages
We want to link each friend's name to their age clearly and accessibly.
Step 2: Evaluate each option's data structure
friends = {'Anna': 20, 'Ben': 22, 'Cara': 19} uses a dictionary (key-value pairs) where names are keys and ages are values, making access easy and clear.