Which of the following is a Python Tuple?

(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

# 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

Prof.Fazal Rehman Shamil (Available for Professional Discussions)
1. Message on Facebook page for discussions,
2. Video lectures on Youtube
3. Email is only for Advertisement/business enquiries.