(A) (7, 8, 9)
(B) [7, 8, 9]
(C) {}
(D) {7, 8, 9}
Correct Answer: (A). (7, 8, 9)
Python program to Create a Tuple
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# Different types of tuples # Empty tuple Tuple_Example = () print(Tuple_Example) # Tuple having integers Tuple_Example = (4, 5, 9) print(
Tuple_Example) # tuple with mixed datatypes Tuple_Example = (1, "Hello", 3.4) print(Tuple_Example) # nested tuple Tuple_Example = ("T4Tutorials", [3, 1, 6], (7, 8, 2)) print(Tuple_Example) |
Output
()
(4, 5, 9)
(1, ‘Hello’, 3.4)
(‘T4Tutorials’, [3, 1, 6], (7, 8, 2))
Which of the following are legal Python Tuples?
(A). a tuple with mixed datatypes
(B). nested tuple
(C). (4, 5, 9)
(D). All of these
Correct Answer: (D). All of these
Which of the following operator is used to access an item in a tuple, where the index starts from 0?
(A). [ ]
(B). ( )
(C). { }
(D). None of these
Correct Answer: (A). [ ]