0% found this document useful (0 votes)
2 views24 pages

Lesson 3 Python Pbr

The document outlines the learning outcomes for a Python programming lesson, focusing on commenting code, creating a maths test, and using if statements. It emphasizes the importance of converting variables to integers and includes practical exercises such as adding questions to a quiz and creating a 12 times table test. Additionally, it discusses the significance of code comments for clarity and debugging.

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)
2 views24 pages

Lesson 3 Python Pbr

The document outlines the learning outcomes for a Python programming lesson, focusing on commenting code, creating a maths test, and using if statements. It emphasizes the importance of converting variables to integers and includes practical exercises such as adding questions to a quiz and creating a 12 times table test. Additionally, it discusses the significance of code comments for clarity and debugging.

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/ 24

COMPUTER

PROGRAMMING
PYTHON
Learning Outcomes
–Lesson 3
Demonstrate and explain the
practice of commenting on code
Create a simple maths test.
Explain the need to convert a
variable to an integer
Make use of if statements to
create a 12 times table
Last lesson
You saved a file called questions.
Can you find the file?
Can you open it?
Add another question and response
Add another question – ask the
user to name a place where they
have been on holiday.
The response must be;
“Hmmm…. “ + holiday_location +
“sounds like a nice place
to go”
Commenting code
Comments are added to
computer programs to help
people understand the intentions
of the person who created the
code – especially where it is not
obvious what is going on.
################

# Now add comments to all of your


lines of code
Add comments to your program
Think, pair, share
1. How would you add some
information about the program,
creator, date etc
2. Is it necessary to comment on
every line?
3. If everything is ignored after the
#, how could this be useful?
Answers
1. Add a top line comment with
name, date etc
2. Only comment when it is not
clear to another person
3. You can use the # to “comment
out” sections of code that are not
working to help with debugging
Creating a maths quiz
Open a new program editor
window (open the interpreter and
select File, New Window)
Here is the code:
save as maths_questions
Add more questions to your game
Can you add 5 more maths
questions to your game
questions?
Can you answer this question?
Answer = int(answer)
Thinking back to the use of
integers in the last lesson, what
does this do and what does int
mean?
Answer = int(answer)
This converts the text string into
a number or integer. If it was not
converted to an integer, it could
not be compared to another
integer, the answer 4.
Can you answer this question?
if answer ==4:
What does the == translate to in
plain English?
if answer ==4:
This means ‘equal’ to, as in “is it
equal to?”
Can you answer this question?
else
else
Or else
Can you answer this question?
Why are the indents necessary
after the if and else statements?
Indents
This means follow the these
instructions if the statement
above is true.
Can you answer this question?
What happens if the colons are
not there after the 4 or else?
Colons
You get a syntax error
12 times table
Create a test that will check the user’s
knowledge of the 12 times multiplication
table.
The test should have between 4 and 12
questions.
Save the file as 12_times_table
It must include a header (description,
your name and date)
You must make use of comments (#)
Review
–Lesson 3
Demonstrate and explain the
practice of commenting on code
Create a simple maths test.
Explain the need to convert a
variable to an integer
Make use of if statements to
create a 12 times table
Homework - wordsearch

You might also like