Python Interview Questions - Comments
- Suhas Bhairav

- Apr 26, 2023
- 1 min read
What is the line of code that is ignored by Python called?
Constructor
Statement
Comment
Private code
Answer
Answer is 3
Comments prevents python from executing the code
In Python, where can the comments be written?
Start of the code
In between the code
End of the code
Anywhere
Answer
Answer is 4
In Python, comments can be written anywhere in the code
What is the use of comments in Python?
Short explanation of the code
To make the code more readable
To prevent Python from executing the code
All of the above
Answer
Answer is 4
In Python, which of the following is the correct syntax for comments?
#
//
$
@
Answer
Answer is 1
Comments in Python starts with # and the text / code proceeding this will be ignored
Which of the following is the correct syntax for multi-line comment?
a. '''
This is a
multi line comment
in Python
''' | b. """
This is a
multi line comment
in Python
""" |
c. # This is a
# multi line comment
# in Python |
Only option a is the correct syntax
Only option b is the correct syntax
Only option c is the correct syntax
All the above are correct syntax
Answer
Answer is 4
In Python, which of the following line of code is ignored from executing?
1. print("Hello world")
2. ''' print("Hello world") '''
3. // print("Hello world")
4. /* print("Hello world") */Answer
Answer is 2
Python treats '''...''' as comments and is ignores those lines


