Recall & Review
beginner
What symbol is used to start a single-line comment in Python?
The # symbol is used to start a single-line comment in Python. Anything after # on that line is ignored by the Python interpreter.
Click to reveal answer
beginner
How do you write a multi-line comment in Python?
Python does not have a special multi-line comment syntax. Instead, you can use multiple single-line comments starting with # or use a multi-line string with triple quotes (
''' or """) which is ignored if not assigned to a variable or used as a docstring.Click to reveal answer
beginner
Why are comments important in Python code?
Comments help explain what the code does in simple words. They make the code easier to understand for others and for yourself when you come back later.
Click to reveal answer
beginner
Can comments affect how a Python program runs?
No, comments do not affect the program's behavior. The Python interpreter ignores comments completely when running the code.
Click to reveal answer
beginner
Example: What will this code output?<br>
print('Hello') # This prints HelloThe output will be:<br>
Hello<br>The comment after
# is ignored and does not affect the output.Click to reveal answer
Which symbol starts a comment in Python?
✗ Incorrect
In Python, the # symbol starts a comment. Other symbols are used in different languages.
What happens to comments when Python runs the code?
✗ Incorrect
Comments are ignored by Python and do not affect the program.
How can you write a multi-line comment in Python?
✗ Incorrect
Python uses multiple single-line comments starting with # for multi-line comments.
Which of these is NOT a reason to use comments?
✗ Incorrect
Comments do not affect speed; they only help with understanding.
What will this code print?<br>print('Hi') # This is a greeting
✗ Incorrect
The comment after
# is ignored, so only 'Hi' is printed.Explain how to write comments in Python and why they are useful.
Think about how you would explain your code to a friend.
You got /4 concepts.
Describe the difference between comments and code in Python.
Focus on what Python does with comments versus code.
You got /4 concepts.