Part 3: Adding Comments To Your Code
Part 3: Adding Comments To Your Code
Programming
Part 3: Adding
Comments to
your Code
How to use this resource
Skill Explanations: Pink Slides
• Within each unit, you will learn how to develop
and apply a range of Python programming skills.
Skill explanations are in pink.
Tasks: Rookie Pro Beast
• After reading the explanation of a skill, apply it
within the given tasks. The tasks are categorised
into Rookie (Easy), Pro (Medium) or Beast (Hard).
Challenges: Rookie Pro Beast
• Once you have learned how to apply your new
skills, demonstrate your ability by completing the
given challenges. Don’t forget the debugging task!
• Once complete, review your performance!
Learning Objectives
Rookie
• To understand why adding comments to your code is useful.
• To be able to add comments within your python code.
Pro
• To write comments which help to explain what programming
techniques you have used.
Beast
• To write clear and precise comments which means that someone
else can understand your programming techniques.
Skill Contents
Once you complete a skill, colour code
Contents Confidence
the box to show your level of Level
confidence. You can always revisit the Adding comments in Python #
skill later on to boost your confidence.
Comment out code
Key Colour
Code
I am very good at this skill
and could show a friend
how to do it.
I am confident I can
perform this skill on my
own.
I need to improve my
understanding of this skill.
Why do we add comments?
Programmers add comments within their code for the following reasons:
• It helps explain the programming techniques written and how they work.
• If a programmer wants to reuse their code in the future, using comments
will help identify the required piece of code.
• They provide explanations for other people who may wish to use the
code, or learn the same programming technique.
Skill 1: Adding comments in python
• To add a comment, simply type in a hashtag symbol # followed by the
required information.
• You write it like this:
Python
Skill Task 2: Solution
• Add a print screen to show • Add a print screen to show
your coding here. your output solution here.
Programming Challenges
• Now you have learned some programming skills, it’s time to
put them into practice!
• Complete the following programming challenges. Start with
the Rookie challenge and see how far you can push yourself.
• Finally, complete the debugging challenge.
• Once you have finished your challenges, complete the
review. Look back at the skills you have learned so far to help
you solve the challenge.
Add a print screen of
Programming Challenge: Rookie your solutions to the
next slide.
Write out the code below and add a suitable comment to explain
what is happening for each line of code:
1 Mark
Programming Challenge: Rookie - Answer
• Add a print screen to show • Add a print screen to show
your coding here. your output solution here.
Add a print screen of
your solutions to the
Programming Challenge: Pro next slide.
Write out the code below and add a suitable comment to explain what
is happening for each line of code:
1 Mark
Programming Challenge: Pro - Answer
• Add a print screen to show • Add a print screen to show
your coding here. your output solution here.
Add a print screen of
your solutions to the
Programming Challenge: Beast next slide.
Write out the code below and add a suitable comment to explain what
is happening for each line of code:
1 Mark
Programming Challenge: Beast - Answer
• Add a print screen to show • Add a print screen to show
your coding here. your output solution here.
Debugging Question
Which of the following lines of code below would output the following statement:
1 Mark
Complete the table below to help you identify what
Challenges Review areas you are confident at and which areas you need
to improve further:
Challenge Your Score (Max 1 mark each)
Rookie Challenge
Pro Challenge
Beast Challenge
Debugging Challenge
Unit Review
What Went Well: