1. Which of the following will create a single element in tuple?
0(1)
O (1)
O ((1))
O tuple([1])
Answers
Answered by
3
Answer:
The fourth one would hope ithelps you
please mark as brainliest
Answered by
3
(d) tuple([1])
When generating a one-element tuple, if you write only one object in parentheses (), the parentheses () are ignored and not treated as a tuple. To generate a one-element tuple, a comma , is required at the end.
single_tuple = (0, )
print(single_tuple)
print(type(single_tuple))
# (0,)
# <class 'tuple'>
For example, when connecting multiple tuples with the + operator, note that an error is raised if you try to add one element and forget a comma ,. The reason why you need a comma , for a single tuple is that "tuple is an object delimited by comma ,", not "an object enclosed in parentheses ()".
Similar questions