Lesson 4 Python Pbr
Lesson 4 Python Pbr
PROGRAMMING
PYTHON
Learning Outcomes
–Lesson 4
Demonstrate use of variables
to add score to a game
Design a coding solution using
Pseudocode
Add responsive score feedback
to the game
Remember this from last lesson?
Maintaining score throughout game
With just a few lines of extra
code you should be able to
maintain the score throughout
the game and give some
feedback at the end.
Open your file saved from last
lesson called maths_questions
Code to add the score
Score = score + 1
Think, pair share
Do you understand what
score = score + 1
means?
Display the score at the end of the game
What code would you have to
type in to display the score at the
end of the game?
Answer
print (score)
Even better if you did this:
print (“Your score was “ +str
(score))
Why do you need to type in
str (score) ?
str (score)
The score variable is an integer
Python cannot add it to the end of
a string.
So the str() function converts it to
a string for the purpose of this line
of code.
Python cannot add strings and
integers together when printing
12_times_table
Open the 12_times_table saved
from last lesson.
Add a scoring feature to each
question.
Add a line that prints out the
score at the end.
(Optional) How could you deduct a
point if the answer is wrong?
Plan a solution using Pseudocode
Think, pair, share
Find out what is meant by
Pseudocode
Pseudocode
Pseudocode is a name given to a
technique for designing and planning
a coding solution that does not
involve the actual code or
programming language.
The aim is enable someone to code a
solution without using the correct
syntax and therefore think more
creatively.
Pseudocode it from lesson 2