Practice understanding variables, values, and common data types such as integers, floats, strings, Booleans, and lists.
Read each problem carefully. Show your work in the space provided.
Storing information with names and choosing the right data type
CS - Grade 6-8
- 1
In your own words, explain what a variable is in computer programming.
- 2
A program has the statement score = 25. What is the variable name, and what value is stored in it?
- 3
Choose the best data type for this value: 42. Explain your choice.
- 4
Choose the best data type for this value: 3.75. Explain your choice.
- 5
Choose the best data type for this value: "basketball". Explain your choice.
- 6
Choose the best data type for this value: true. Explain your choice.
- 7
A student writes age = "12". Is age stored as a number or as text? Explain how you know.
- 8
A program has these statements: points = 10 and points = points + 5. What value does points store after both statements run?
- 9
Write a variable assignment for a player's name, using the variable name playerName and the value Maya.
- 10
Write a variable assignment for the number of lives in a game, using the variable name lives and the value 3.
- 11
The variable temperatures stores [68, 70, 72, 69]. What data type is this most likely, and why?
- 12
A program needs to store whether a user is logged in or not. Choose a good variable name and data type, then explain your answer.