My Report

Python Tuples Test – 3


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. Is the following Python code valid?

>>> a,b,c=1,2,3
>>> a,b,c

2. What will be the output of the following Python code?

>>> a=(2,3,1,5)
>>> a.sort()
>>> a

3. Is the following Python code valid?

>>> a,b=1,2,3

4. Is the following Python code valid?

>>> a=2,3,4,5
>>> a

5. Tuples can’t be made keys of a dictionary.

6. Is the following Python code valid?

>>> a=(1,2,3)
>>> b=a.update(4,)

7. What will be the output of the following Python code?

>>> a,b=6,7
>>> a,b=b,a
>>> a,b

8. What will be the output of the following Python code?

a = ('check',)
n = 2
for i in range(int(n)):
    a = (a,)
    print(a)

9. What will be the output of the following Python code?

>>> import collections
>>> a=collections.namedtuple('a',['i','j'])
>>> obj=a(i=4,j=7)
>>> obj

10. What will be the output of the following Python code?

>>> a=[(2,4),(1,2),(3,9)]
>>> a.sort()
>>> a

11. What will be the output of the following Python code?

>>> a=(1,2)
>>> b=(3,4)
>>> c=a+b
>>> c

 

Start practicing “1000 MCQs on Python”, and once you are ready, you can take tests on all topics by attempting our “Python Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.