Python sample question with answer 5

Question:
Which of the following code blocks contains a valid Python comment?

  1. comment: This prints a "Try again" message
    print("Try again")
  2. # This prints a "Try again" message
    print("Try again")
  3. This prints a "Try again" message
    print("Try again")
  4. : This prints a "Try again" message
    print("Try again")
Answer:
B - is the correct answer. The following code block contains a valid Python comment: A comment is a note programmers make about the intention behind their code. Comments begin with the hash symbol (#)