Python program to Create a Tuple
# 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). [ ]
Computer Science MCQs
1000+ Programming C Plus Plus MCQs
Highly Recommended C++ Important MCQs with Explanation
- Which symbol is used to create multiple inheritances?
- If a derived class object is created, which constructor is called first?
- Which of the following is not a type of constructor?
- a ____ is a member function that is automatically called when a class object is __.
- What is the output of the following code in C++?
- How many times will the following code print?
- Which of the following is a procedural language?
- Which of the following is not a programming language?
- Which of the following is not an example of high-level language?
- While declaring pointer variables which operator do we use?
- To which does the function pointer point to?
- Which of these best describes an array?
- Which of the following is a Python Tuple?
Other important MCQs
Data Structure
Which of the following is not the type of queue?
Database
If one attribute is a determinant of the second, which in turn is a determinant of the third, then the relation cannot be
Python
Which of the following is a Python Tuple?