# Lesson 4 – Adding Scores, Pseudocode and Responsive Feedback

Learning Outcomes

• Demonstrate use of variables to add a score to the game
• Designing a coding solution using pseudocode
• Add responsive score feedback to the game

Keywords

Words to learn: variable, integer, string, convert, pseudocode

Starter – Adding Scores

In the last lesson, you used the following script to create the beginning of a maths quiz and then developed it into a 12 times table test: The quiz is OK, but it doesn’t give us much reason to keep coming back to it.  If we added in a score system would help engage people as they would want to get the highest score possible.  So how can we do this?

We need to add a variable called score to keep track of… well the score!  Change the code from above to the following: At the end of your script you will want to display the final score.  Try the following:

`print("The final score is: " + score)`

Try running it – you will get the following error: Why do you think you get this error?

The reason is the score is stored as an integer (whole number) but the print command uses strings (text) to display things on the screen.  We therefore need to tell Python to convert the integer into a string.  So let’s change our code to the following:

`print("The final score is: " + str(score))`

The str command tells Python to convert the integer to a string.

You can also add a conditional if to give you interactive feedback: Main Task 1 – Understanding Pseudocode

In the next task we are going to alter your 12 times table program so that it keep score and gives feedback on how good (or bad) the student’s score was.  To work out what we are going to do we can use a design technique called pseudocode.

Pseudocode is a bit like a cross between normal English and a programming language (like Python).  It is designed so you can write out a possible solution to a problem, but you don’t get “bogged down” in how to write it as code.  The following example shows pseudocode for a teacher entering 10 class grades to get an average:

`Start`
```Set total to zero
Set grade counter to one```
```While grade counter is less than or equal to ten
Input the next grade
`Print the class average`
`End`