Home > Python > Quizzes > Python Programming Basics Practice Test: Different Types Of Python Tuples
Python Programming Basics Practice Test: Different Types Of Python Tuples
Fast practice, instant feedback. Timer auto-submits when time’s up.
Avg score: 46% Most missed: “What type of data is: a=[(1,1),(2,4),(3,9)]?”
Tuples can be used for a variety of purposes, such as storing data, passing data to functions, and returning data from functions. Tuples are also often used in conjunction with other data structures, such as lists and dictionaries. Here are the different types of Python tuples: Homogenous tuples: These are tuples that contain elements of the same data type. For example, a tuple that contains only integers is a homogeneous tuple. Heterogeneous tuples: These are tuples that contain elements of different data types. For example, a tuple that contains an integer, a float, and a string is a... Show more
Python Programming Basics Practice Test: Different Types Of Python Tuples
Time left 00:00
25 Questions

1. Is the following Python code valid?
>>> a,b=1,2,3
2. What will be the output of the following Python code?
>>> a=("Check")*3>> a
3. Is the following Python code valid?
>>> a=2,3,4,5
>>> a
4. Is the following Python code valid?
>>> a=(1,2,3)
>>> b=a.update(4,)
5. What will be the output of the following Python code?
>>>t = (1, 2, 4, 3, 8, 9)
>>>[t[i] for i in range(0, len(t), 2)]
6. Suppose t = (1, 2, 4, 3), which of the following is incorrect?
7. Which of the following is a Python tuple?
8. Is the following Python code valid?
>>> a,b,c=1,2,3
>>> a,b,c
9. What will be the output of the following Python code?
>>> a=(0,1,2,3,4)
>>> b=slice(0,2)
>>> a[b]
10. If a=(1,2,3,4), a[1:-1] is _________
11. What will be the output of the following Python code?
>>> a,b=6,7
>>> a,b=b,a
>>> a,b
12. Is the following Python code valid?
>>> a=(1,2,3)
>>> b=('A','B','C')
>>> c=tuple(zip(a,b))
13. What will be the output of the following Python code?
numberGames = {}
numberGames[(1,2,4)] = 8
numberGames[(4,2,1)] = 10
numberGames[(1,2)] = 12
sum = 0
for k in numberGames:
sum += numberGames[k]
print len(numberGames) + sum
14. What will be the output of the following Python code?
>>> a=[(2,4),(1,2),(3,9)]
>>> a.sort()
>>> a
15. What will be the output of the following Python code?
>>> a=(1,2,(4,5))
>>> b=(1,2,(3,4))
>>> a
16. What will be the output of the following Python code?
>>> a=(2,3,4)
>>> sum(a,3)
17. What will be the output of the following Python code?
>>>t = (1, 2)
>>>2 * t
18. Is the following Python code valid?
>>> a=(1,2,3,4)
>>> del a
19. What will be the output of the following Python code?
>>>t=(1,2,4,3)
>>>t[1:-1]
20. What will be the output of the following Python code?
a = ('check',)
n = 2
for i in range(int(n)):
a = (a,)
print(a)
21. What will be the output of the following Python code?
>>> a=(1,2)
>>> b=(3,4)
>>> c=a+b
>>> c
22. What will be the output of the following Python code?
>>>my_tuple = (1, 2, 3, 4)
>>>my_tuple.append( (5, 6, 7) )
>>>print len(my_tuple)
23. Tuples can’t be made keys of a dictionary.
24. What will be the output of the following Python code?
>>>t1 = (1, 2, 4, 3)
>>>t2 = (1, 2, 3, 4)
>>>t1 < t2
25. What will be the output of the following Python code?
>>>t=(1,2,4,3)
>>>t[1:3]