Which symbol is used to create a single-line comment in Python?
Quiz 140 - Comments in Python code

Quiz
•
Computers
•
9th Grade
•
Hard
Jonathan Saurine
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
--
//
/* */
#
Answer explanation
In Python, the symbol used to create a single-line comment is '#'. This symbol indicates that everything following it on that line is a comment and will not be executed as code. The other options are not valid for comments in Python.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will happen if you write this code?
Only the first comment will be ignored.
The interpreter will ignore the comments.
The comments will be printed.
Python will raise a syntax error.
Answer explanation
In Python, comments are preceded by a '#' symbol and are ignored by the interpreter. Therefore, regardless of how many comments are present, they will not affect the execution of the code.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you write a multi-line comment in Python?
''' This is a multi-line comment '''
-- This is a multi-line comment --
# This is a multi-line comment
/* This is a multi-line comment */
Answer explanation
In Python, multi-line comments can be created using triple quotes (''' or """). The correct choice is ''' This is a multi-line comment '''. Other options are not valid for multi-line comments in Python.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following are ways to write a multi-line comment in Python?
-- This is a multiline comment in Python --
/* This is a multiline comment in Python */
" This is a multiline comment in Python "
# This is a multiline # comment in Python
Answer explanation
In Python, multi-line comments are typically written using triple quotes (""" or ''') for docstrings, but the correct choice here is using the '#' symbol for single-line comments. The other options are not valid in Python.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
The primary purpose of comments in Python is to
increase the execution speed of the program.
define variables dynamically.
provide documentation and explanations for the code.
execute alternative versions of the code.
Answer explanation
The primary purpose of comments in Python is to provide documentation and explanations for the code, making it easier for others (and yourself) to understand the logic and purpose behind the code.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following will NOT create a comment in Python?
# This is a comment
''' This is a comment '''
print("Hello") # Comment here
// This is a comment
Answer explanation
The choice '// This is a comment' is incorrect because Python does not recognize '//' as a comment syntax. In Python, comments are created using '#' or triple quotes (''' or """).
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How can you use comments to disable code in Python?
// print("This line is disabled")
/* print("This line is disabled") */
# print("This line is disabled")
-- print("This line is disabled")
Answer explanation
In Python, comments are made using the '#' symbol. The correct choice, '# print("This line is disabled")', effectively disables the code on that line. The other options are not valid comment syntax in Python.
Create a free account and access millions of resources
Similar Resources on Quizizz
14 questions
Coding Python 1.1. Statements & Variables

Quiz
•
7th - 9th Grade
5 questions
Python- Comments

Quiz
•
9th - 12th Grade
13 questions
Fundamentals of Python

Quiz
•
9th - 12th Grade
10 questions
python quiz

Quiz
•
6th Grade - Professio...
12 questions
Python - Abstractions, Comments, Data Types, Variables

Quiz
•
9th - 12th Grade
15 questions
Python Basics Quiz

Quiz
•
6th - 10th Grade
12 questions
Project-Stem Unit 1 python coding

Quiz
•
9th - 12th Grade
8 questions
Python Comments

Quiz
•
9th Grade
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade
Discover more resources for Computers
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
20 questions
Taxes

Quiz
•
9th - 12th Grade
17 questions
Parts of Speech

Quiz
•
7th - 12th Grade
20 questions
Chapter 3 - Making a Good Impression

Quiz
•
9th - 12th Grade
20 questions
Inequalities Graphing

Quiz
•
9th - 12th Grade
10 questions
Identifying equations

Quiz
•
KG - University