Comments

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Comments

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What happens to # print('Hi')?
A Prints Hi
B Nothing (ignored)
2. What displays? print('Hello') # greeting
A Hello
B greeting
3. What does # do?
A Prints # symbol
B Makes text a comment
4. Which line runs? # input() vs input()
A Second line only
B Both lines
5. What displays? # 'Test'
A Nothing
B Test

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1print('Hi') greeting AValid: Comment
2// This is a comment BOk: End-of-line comment
3# This is a comment COutput: World
4print('Hi') # greeting DInvalid: Use # not //
5# print('Hi') EError: Missing #
6print('World') # test FOutput: (nothing)

Definitions

# This is a comment

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
_ This gets user's name input('Name: ')
2.
print('Hello') _ greeting message
3.
# Get student details i____('Age: ')
4.
_ Start Program p____('Press Enter')
5.
# This is a c______ print('Test')

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A print('Hello')
B // This is a comment
C input()
Question 2
A # Get user name
B input('Name: ')
C print('Age: )
Question 3
A print('Hi')
B # input('Name: ')
C print 'Done'
Question 4
A # Student form
B print('Name: ')
C -- This is commented
D input()
Question 5
A print('Start')
B input('Data: ') // end-of-line
C print('End')

Answer Key

Comments
Section A: Quick Questions
Q1
B — Nothing (ignored)
Q2
A — Hello
Q3
B — Makes text a comment
Q4
A — Second line only
Q5
A — Nothing
Section B: Match the Pairs
Q1
print('Hi') greeting → Error: Missing #
Q2
// This is a comment → Invalid: Use # not //
Q3
# This is a comment → Valid: Comment
Q4
print('Hi') # greeting → Ok: End-of-line comment
Q5
# print('Hi') → Output: (nothing)
Q6
print('World') # test → Output: World
Section C: Definitions
Q1
# This is a comment — # is used to explain code - Python ignores text after the #
Section D: Fill in the Blanks
Q1
# This gets user's name input('Name: ')
Q2
print('Hello') # greeting message
Q3
# Get student details input('Age: ')
Q4
# Start Program print('Press Enter')
Q5
# This is a comment print('Test')
Section E: Spot the Error
Q1
B — Wrong comment symbol: // should be #
Q2
C — Missing closing quote
Q3
C — Missing parentheses on print
Q4
C — Wrong comment symbol: -- should be #
Q5
B — Wrong comment symbol: // should be #