CBSE Class 11 Informatics Practices Question 21 of 62

Getting Started with Python — Question 2

Back to all questions
2
Question

Question 2

Which of the following is syntactically correct text?

  1. "This is great!"
  2. 'she shouted 'HELLO' loudly'
  3. "Goodbye'
  4. "This "course" is good"
Answer

"This is great!"

Reason — The "This is great!" text uses double quotes (") to properly enclose the entire string. In Python, strings enclosed in either single quotes (') or double quotes (") are valid, but the entire string must be enclosed in the same type of quote. The other options have mismatched quotes, which cause syntax errors in Python.