Practice Variable in CS Thinking
Use these practice problems to test your method after reviewing the concept explanation and worked examples.
Quick Recap
A named container in a program that stores a value, which can be read, updated, or replaced. Variables have a name (identifier), a value (the data stored), and in many languages a type (what kind of data it holds).
A labeled box you can put things in, take things out, or change what's inside.
Showing a random 20 of 50 problems.
Example 1
easyWhich is a clearer variable name for a person's age: 'x' or 'age'?
Example 2
easyUsing a variable before assigning it any value typically causes what kind of error?
Example 3
easyA variable's ____ tells the program what kind of data it holds (e.g., int, string).
Example 4
easyTrace: 'cat'; . Final ?
Example 5
mediumTrace: ; ; ; . Final ?
Example 6
mediumTrace swap without a temp using arithmetic: ; ; ; ; . Final ?
Example 7
easyTrace: ; . Final ?
Example 8
mediumTrace: ; . Final ?
Example 9
easyIn 'total = price', which side receives the value: total or price?
Example 10
hardIn a scope-aware language, is defined globally and a function sets locally. After the function returns, what is the global ?
Example 11
challengeTrace: ; for in range(3): . Final (range(3) is 3 passes)?
Example 12
easyWhich variable name is clearer for a student's grade: 'g' or 'grade'?
Example 13
challengeTrace: ; ; ; ; ; . Final ?
Example 14
mediumTrace: ; ; ; . Final ?
Example 15
easyWhat is the output? SET score = 0. SET score = score + 10. SET score = score + 5. OUTPUT score.
Example 16
easyTrace: ; ; . Final ?
Example 17
mediumTrace: ; ; ; . Final ?
Example 18
mediumTrace: ; ; ; . Final and โ does this swap them?
Example 19
easyWhat is wrong with: ; ?
Example 20
mediumTrace: ; for in : if : . Final ?