top of page

Python Interview Questions - Comments

What is the line of code that is ignored by Python called?
  1. Constructor

  2. Statement

  3. Comment

  4. Private code

Answer

Answer is 3

Comments prevents python from executing the code


In Python, where can the comments be written?
  1. Start of the code

  2. In between the code

  3. End of the code

  4. Anywhere

Answer

Answer is 4

In Python, comments can be written anywhere in the code


What is the use of comments in Python?
  1. Short explanation of the code

  2. To make the code more readable

  3. To prevent Python from executing the code

  4. All of the above

Answer

Answer is 4



In Python, which of the following is the correct syntax for comments?
  1. #

  2. //

  3. $

  4. @

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      


  1. Only option a is the correct syntax

  2. Only option b is the correct syntax

  3. Only option c is the correct syntax

  4. 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



🔥 Pitch Deck Analyzer 🔥: Try Now

Subscribe to get all the updates

© 2025 Metric Coders. All Rights Reserved

bottom of page