How does a football game remember your score when you net a goal at Wembley?
You're playing a football game at Wembley. Your team starts on zero, then you score a goal. The display changes to one. How does the game remember the new score for the next goal?
Look at the three values. Zero and one are integers because they're whole numbers. The word goal in quotation marks is a string. To keep track of how many goals you've scored, you need a whole number.
Watch a space called score appear. The name tells you what it keeps track of, and the space is set up to hold an integer. Now zero goes in. That named space is a variable. Setting up its name and type is a declaration. Storing zero is an assignment.
You've declared score as an integer. To start a new match, you assign zero to score. What value is stored immediately after that assignment? Pick one answer.
The game reaches the line you read as score gets score plus one. First it reads the current score, zero. Then it adds one to get one. Only after that does it store one back in score, replacing the zero.
Declare score as an integer, then read the first arrow as score gets zero. Next comes score gets score plus one. Evaluate the right side using the current score: zero plus one is one. Only then store one in score, replacing zero.
Your team has already scored four goals. You reach the instruction score gets score plus one. What value is stored in score after this single instruction? Pick one answer.
If you read the arrow as equals, you'd be asking whether four equals four plus one. It doesn't. With an assignment arrow, the right side uses the value before the update, and the name on the left tells you where to store the result.
Your score can change during a match, so score is a variable. If the league always awards three points for a win, you could name that fixed value pointsPerWin. A named value that stays fixed while the program runs is a constant.