Correct option is D
The given statement:
Msg = ('Good Day')
will assign the string
'Good Day' to the variable
Msg. Although the value is enclosed in parentheses,
'Good Day' is a string and not a tuple because there is only one value (the string itself). In Python, parentheses are used for grouping, but if there is only one element and no comma, it does not create a tuple; it simply creates the value it contains, which in this case is a
string.
Important Key Points:
1.
Tuples vs. Strings: In Python, a tuple is created using parentheses and a comma between elements (e.g., (1, 2)), whereas a string is a sequence of characters enclosed in quotes (e.g., 'Good Day').
2.
Single Element Tuple: To create a tuple with a single element, a comma must be included, such as ('Good Day',) (note the comma).
3.
Resulting Data Type: Since there is no comma,
Msg is assigned a string, not a tuple.
Knowledge Booster:
·
Option (a):
tuple is incorrect because a tuple with a single element requires a comma (e.g., ('Good Day',)), and without a comma, this is a string.
·
Option (b):
list is incorrect because lists in Python are defined using square brackets (e.g., ['Good Day']), not parentheses.
·
Option (c): There is
no error in the statement. The syntax is valid, and it correctly assigns a string to the variable Msg.