Variables: Storing and Changing a Value

8 questions · 8 points · Grade 7 · English · Preview the 8 questions

Made by Aisha Varrick · LessonRally (AI-assisted)

Digital classroom activity

What is a digital classroom activity?

Teachers who sign in can assign LessonRally activities to their Google Classroom classes: students open them in Classroom and answer online, and their grades go to the teacher's Classroom gradebook. Practice lets you try it first, the way students see it.

Free for teachers. Sign in to assign activities to your Google Classroom classes.

Printable worksheet

Students trace steps that store and change values in variables: setting a value, adding to it, replacing it, copying one variable into another, swapping two values, and joining words. Each question asks for a value at a named step or at the end. Coding and computer science practice with no programming language.

Learning goal: Trace steps that set, change, copy and swap the values of variables, and find a variable's exact value at the end or at a named step.

Estimated reading level 4.0

  1. Grade 2Hard
  2. Grade 3Stretch
  3. Grade 4On level
  4. Grade 5Easier
  5. Grade 6Easy
About this estimate

The estimate is the middle score of five readability formulas. Their scores run from 1.9 to 7.0.

  • Flesch-Kincaid GradeSentence length and syllables per word3.1
  • Gunning FogSentence length and words of three or more syllables5.6
  • Coleman-Liau Middle scoreLetters per word and sentences per 100 words4.0
  • Automated Readability IndexCharacters per word and words per sentence1.9
  • SMOGWords of three or more syllables, for texts of 30 sentences or more7.0
Flesch Reading Ease
88.5 on a 0 to 100 scale where higher is easier: easy. Not part of the estimate.
Text measured
444 words, 45 sentences

Adapted from common readability formulas (Flesch-Kincaid, Gunning Fog, Coleman-Liau and ARI, plus SMOG for long texts), which look at sentence length and word length. Answer choices count toward word length only. Grades below the estimate will likely find the text harder, grades above it easier. It does not measure ideas, background knowledge or images.

Topic: Programming and Algorithms Chosen by LessonRally

Question types: number answer, multiple choice.

Student preview

The questions as students see them, without the answers.

A variable is a name that stores a value, like a labeled box that holds one thing at a time. In these steps, "Set" replaces whatever value a variable was holding, and each step changes only the variable it names. Work through the steps in order, one at a time.

Question 1

A soccer video game keeps track of a player's score during a match by running these steps in order.

  1. Set score to 5.
  2. Add 3 to score.
  3. Multiply score by 4.

What is the value of score after step 3 has finished?

Enter a number.

Question 2

Rory wrote a savings program that tracks the money in his piggy bank, and it runs these steps in order.

  1. Set savings to 12.
  2. Set savings to 4.
  3. Add 6 to savings.

What is the value of savings after step 3 has finished?

Enter a number.

Question 3

A gardening program tracks the height of a hedge as it grows and then gets trimmed.

  1. Set height to 20.
  2. Add 15 to height.
  3. Subtract 8 from height.
  4. Double height.

What is the value of height right after step 3, before step 4 runs?

Enter a number.

Question 4

These steps use two variables named original and backup. The step "Set backup to original" gives backup the value that original has at that moment.

  1. Set original to 7.
  2. Set backup to original.
  3. Add 5 to original.

What is the value of backup after step 3 has finished?

Enter a number.

Question 5

A variable can store words as well as numbers. Follow these steps from a word-building game.

  1. Set word to "rain".
  2. Set word to word followed by "bow".

What is stored in word after step 2?

Choose one answer.

  • rainbow
  • bowrain
  • bow
  • rain

Question 6

Dina's program stores 3 in a variable named first and 8 in a variable named second. She wants to swap them, so that first ends at 8 and second ends at 3. Which steps do that?

Choose one answer.

  • Add second to first. Then set second to first.
  • Set second to first. Then set first to second.
  • Set temporary to first. Then set first to second. Then set second to temporary.
  • Set first to second. Then set second to first.

Question 7

A hiking app keeps track of how far a hiker has walked on a trail and how much of the trail is left.

  1. Set trail to 10.
  2. Set hiked to 3.
  3. Set remaining to trail − hiked.
  4. Set hiked to hiked + remaining.

What is the value of hiked after step 4 has finished?

Enter a number.

Question 8

A school supply program counts the pencils and markers in a classroom bin by running these steps in order.

  1. Set pencils to 4.
  2. Set markers to pencils + 6.
  3. Set pencils to markers × 2.
  4. Set markers to markers + pencils.

What is the value of markers after step 4 has finished?

Enter a number.

Reviews

No reviews yet.

Reviews come from teachers who assigned this activity to a class.

Sign in to write a review

Have a topic of your own? Make a printable worksheet and online quiz, free.

Create an activity

Answer key

Answer keys come with Premium

Print this worksheet with the correct answers marked. The key includes any explanations, sample answers, and rubrics supplied with the activity.

Answer keys aren't public: only teachers with Premium and the people who can edit an activity can download one, so students can't get a ready-to-print key from this page.

Premium includes:

  • No ads for you, and no ads for your students on the assignments you post.
  • Answer keys for printable worksheets, with the correct answers marked and any explanations, sample answers, and rubrics.
  • Create with AI: up to 100 activities a year (5 during the free trial), with every answer checked before you see the draft.

$29 a year, plus sales tax where it applies.

New Premium teachers can try it free for 7 days. A card or other payment method is needed to start. Unless you cancel before the trial ends, you are charged then and the plan renews every year.

Already have Premium or edit this activity? Sign in