FUNDAMENTALS OF COMPUTER

COMPUTER PROGRAMMING FUNDAMENTALS

PROGRAMMING LANGUAGES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
A string is surrounded by double quotes. True or false?
A
TRUE
B
FALSE
C
Either A or B
D
None of the above
Explanation: 

Detailed explanation-1: -True/False: A Python string literal is always enclosed in double quotes. False. String literals may be enclosed in double quotes or single quotes in Python as long as the same type is used to both open and close the string.

Detailed explanation-2: -A double-quoted string can have single quotes without escaping them, conversely, a single-quoted string can have double quotes within it without having to escape them. Double quotes ( ’´ ) must escape a double quote and vice versa single quotes ( )´ must escape a single quote.

Detailed explanation-3: -String literals can be enclosed by either double or single quotes, although single quotes are more commonly used.

Detailed explanation-4: -String is enclosed either with single quotes or double quotes. Both the ways (single or double quotes) are correct depending upon the requirement.

Detailed explanation-5: -Text in quotes are treated as Strings, while “True” or “False” without the quotations are treated as Boolean variables. They are different data types.

There is 1 question to complete.