Your school sets a new points rule. Can you update the scoreboard in one edit?
Your school in Leeds runs a football skills challenge. Each goal earns three points. Next week, the organisers want each goal to earn five. Can you write the scoreboard so that changing the rule takes just one edit?
Python needs no separate variable declaration here. Your first assignment gives the name s a value of zero. Each of the next two assignments adds three to the current score and stores the result back in s. The score rises to three and then six.
Follow the score from zero. The first goal adds three points, taking the score to three. The second goal adds the same three points, taking it to six. The total changes after each goal. The number of points each goal earns stays fixed during the game.
The next goal takes your score from six to nine. Look at the score and the number of points each goal earns. Which value stayed the same after that goal? Pick an answer.
An identifier is a name in code. Give the fixed rule the name points per goal and define this named constant as three. Rename s to score so you know what the variable holds, and start it at zero. Both goal updates use the same rule, taking the score to three and then six.
You change the definition of points per goal from three to five and run the program again from a score of zero. What score will the two goal updates produce? Pick an answer.
You might think capital letters lock the value. In Python, you can still assign a new value to that name. Capitals are a naming convention. They tell someone reading your code that you intend to leave the value unchanged while the program runs.
Set the rule to three. The add goal subroutine returns the increased score. Start at zero. In each of two rounds, try twice. Attempt zero scores, so call add goal and store its result. Inside that decision, check if the score is six. If so, print target reached.
Start at six. The pre-condition loop checks before simulating a goal, so it skips the update and prints six. Reset to six. To test after the update in Python, start the loop unconditionally. Simulate a goal, then check whether to stop. This loop runs once and prints nine.