0% found this document useful (0 votes)
3 views20 pages

Lesson 4 Python Pbr

This lesson focuses on using variables to maintain and display scores in a Python game, including adding responsive feedback based on performance. Students are encouraged to design coding solutions using pseudocode to enhance their understanding of programming logic. The lesson concludes with a review of key concepts and a homework assignment related to pseudocode.

Uploaded by

jacoxod778
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views20 pages

Lesson 4 Python Pbr

This lesson focuses on using variables to maintain and display scores in a Python game, including adding responsive feedback based on performance. Students are encouraged to design coding solutions using pseudocode to enhance their understanding of programming logic. The lesson concludes with a review of key concepts and a homework assignment related to pseudocode.

Uploaded by

jacoxod778
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

COMPUTER

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

What would the pseudocode be


for this program? Work with a
partner and write your solution
down.
Pseudocode it from lesson 2
It could look something like this:

print “type in your name”


input user name
print “nice to meet you” + user
name
Other programs
Look at some of the other
programs you have written and
see if you can write down the
pseudocode for them.
Add responsive feedback to your game.
You could simply report the score
back at the end of the game.
Even better if – you could give an
appropriate feedback response
based on how high or low their
score was at the end of the game.
Write the pseudocode first, then
try writing it in Python.
Responsive feedback solution
score = 0
if score > 2:
print (“Well done!”)
else
print (“Oh dear”)
Responsive feedback solution
Even better if:
“Well done, you scored 3 out of 3 –
very clever”, “Oh dear, you only
scored 1 out of 3 – why not try
again to improve”
Review
–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
Homework - Pseudocode

You might also like