CS Grade 6-8

CS: Introduction to Variables and Data Types

Storing information with names and choosing the right data type

View Answer Key
Name:
Date:
Score: / 12

Storing information with names and choosing the right data type

CS - Grade 6-8

Instructions: Read each problem carefully. Show your work in the space provided.
  1. 1
    A storage box holding an object, representing a variable storing information.

    In your own words, explain what a variable is in computer programming.

  2. 2

    A program has the statement score = 25. What is the variable name, and what value is stored in it?

  3. 3

    Choose the best data type for this value: 42. Explain your choice.

  4. 4

    Choose the best data type for this value: 3.75. Explain your choice.

  5. 5

    Choose the best data type for this value: "basketball". Explain your choice.

  6. 6

    Choose the best data type for this value: true. Explain your choice.

  7. 7

    A student writes age = "12". Is age stored as a number or as text? Explain how you know.

  8. 8
    Tokens being added to a container to show a variable value increasing.

    A program has these statements: points = 10 and points = points + 5. What value does points store after both statements run?

  9. 9

    Write a variable assignment for a player's name, using the variable name playerName and the value Maya.

  10. 10

    Write a variable assignment for the number of lives in a game, using the variable name lives and the value 3.

  11. 11
    Four connected compartments with thermometer icons, representing a list of temperatures.

    The variable temperatures stores [68, 70, 72, 69]. What data type is this most likely, and why?

  12. 12
    A user icon on a computer screen next to a two-state toggle switch.

    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.

LivePhysics™.com CS - Grade 6-8

More CS Worksheets

See all CS worksheets

More Grade 6-8 Worksheets

See all Grade 6-8 worksheets