CBSE Class 11 Computer Science Question 52 of 114

Tuples — Question 4

Back to all questions
4
Question

Question 4

The syntax for a tuple with a single item is simply the element enclosed in a pair of matching parentheses as shown below :
t = ("a")
Is the above statement true? Why? Why not ?

Answer

The statement is false. Single item tuple is always represented by adding a comma after the item. If it is not added then python will consider it as a string.
For example:
t1 = ("a",)
print(type(t1)) ⇒ tuple
t = ("a")
print(type(t)) ⇒ string

Answer