CBSE Class 11 Informatics Practices Question 33 of 102

Python Programming Fundamentals — Question 10

Back to all questions
10
Question

Question 10

Which of the following is a syntactically correct string?

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

"This is great !"

Reason — 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 and when we want to include quotes within a string, we should use one type of quote to enclose the string and the other type of quote inside the string itself. The "This is great !" string uses double quotes (") to properly enclose the entire string. The other options have mismatched and same nested quotes, which cause syntax errors in Python.