  ## Python Practice Test MCQ Certified Go from 0 to Expert hero Set 13

Options are :

• 40
• 45
• "john"
• "peter"

Options are :

• (1, 2, 1, 2)
• [1, 2, 1, 2]
• (1, 1, 2, 2)
• [1, 1, 2, 2]

Options are :

• True
• False
• Error
• None

Options are :

• 1
• 2
• 5
• Error

Options are :

• 30
• 24
• 33
• 12

##### What is the data type of (1)?

Options are :

• Tuple
• Integer
• List
• Both tuple and integer

##### If a=(1,2,3,4), a[1:-1] is _________

Options are :

• Error, tuple slicing doesn't exist
• [2,3]
• (2,3,4)
• (2,3)

##### What will be the output of the following Python code?`>>> a=(1,2,(4,5))>>> b=(1,2,(3,4))>>> a<b`

Options are :

• True
• False
• Error, < operator is not valid for tuples
• Error, < operator is valid for tuples but not if there are sub-tuples

##### What will be the output of the following Python code?`>>> a=("Check")*3>>> a`

Options are :

• ('Check','Check','Check')
• * Operator not valid for tuples
• ('CheckCheckCheck')
• Syntax error

##### What will be the output of the following Python code?`>>> a=(1,2,3,4)>>> del(a)`

Options are :

• Now, a=(1,2,4)
• Now, a=(1,3,4)
• Now a=(3,4)
• Error as tuple is immutable

Answer :Error as tuple is immutable

##### What will be the output of the following Python code?`>>> a=(2,3,4)>>> sum(a,3)`

Options are :

• Too many arguments for sum() method
• The method sum() doesn't exist for tuples
• 12
• 9

##### Is the following Python code valid?`>>> a=(1,2,3,4)>>> del a`

Options are :

• No because tuple is immutable
• Yes, first element in the tuple is deleted
• Yes, the entire tuple is deleted
• No, invalid syntax for del method

Answer :Yes, the entire tuple is deleted

##### What type of data is: a=[(1,1),(2,4),(3,9)]?

Options are :

• Array of tuples
• List of tuples
• Tuples of lists
• Invalid type

##### What will be the output of the following Python code?`>>> a=(0,1,2,3,4)>>> b=slice(0,2)>>> a[b]`

Options are :

• Invalid syntax for slicing
• [0,2]
• (0,1)
• (0,2)

##### . Is the following Python code valid?`>>> a=(1,2,3)>>> b=('A','B','C')>>> c=zip(a,b) `

Options are :

• Yes, c will be ((1,2,3),('A','B','C'))
• Yes, c will be ((1,2,3),('A','B','C'))
• No because tuples are immutable
• No because the syntax for zip function isn't valid

Answer :Yes, c will be ((1,2,3),('A','B','C'))

##### Is the following Python code valid?`>>> a,b,c=1,2,3>>> a,b,c`

Options are :

• Yes, [1,2,3] is printed
• No, invalid syntax
• Yes, (1,2,3) is printed
• 1 is printed

##### What will be the output of the following Python code?`a = ('check',)n = 2for i in range(int(n)): a = (a,) print(a)`

Options are :

• Error, tuples are immutable
• (('check',),) ((('check',),),)
• (('check',)'check',)
• (('check',)'check',) ((('check',)'check',)'check',)

##### Is the following Python code valid?`>>> a,b=1,2,3`

Options are :

• Yes, this is an example of tuple unpacking. a=1 and b=2
• Yes, this is an example of tuple unpacking. a=(1,2) and b=3
• No, too many values to unpack
• Yes, this is an example of tuple unpacking. a=1 and b=(2,3)

Answer :No, too many values to unpack

##### What will be the output of the following Python code?`>>> a=(1,2)>>> b=(3,4)>>> c=a+b>>> c`

Options are :

• (4,6)
• (1,2,3,4)
• Error as tuples are immutable
• None

##### What will be the output of the following Python code?`>>> a,b=6,7>>> a,b=b,a>>> a,b`

Options are :

• (6,7)
• Invalid syntax
• (7,6)
• Nothing is printed

##### 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`

Options are :

• a(i=4, j=7)
• obj(i=4, j=7)
• (4,7)
• An exception is thrown

Options are :

• True
• False

##### Is the following Python code valid?`>>> a=2,3,4,5>>> a`

Options are :

• Yes, 2 is printed
• Yes, [2,3,4,5] is printed
• No, too many values to unpack
• Yes, (2,3,4,5) is printed

##### What will be the output of the following Python code?`>>> a=(2,3,1,5)>>> a.sort()>>> a`

Options are :

• (1,2,3,5)
• (2,3,1,5)
• None
• Error, tuple has no attribute sort

Answer :Error, tuple has no attribute sort

##### Is the following Python code valid?`>>> a=(1,2,3)>>> b=a.update(4,)`

Options are :

• Yes, a=(1,2,3,4) and b=(1,2,3,4)
• Yes, a=(1,2,3) and b=(1,2,3,4)
• No because tuples are immutable
• No because wrong syntax for update() method

Answer :No because tuples are immutable

##### What will be the output of the following Python code?`>>> a=[(2,4),(1,2),(3,9)]>>> a.sort()>>> a`

Options are :

• [(1, 2), (2, 4), (3, 9)]
• [(2,4),(1,2),(3,9)]
• Error because tuples are immutable
• Error, tuple has no sort attribute

Answer :[(1, 2), (2, 4), (3, 9)]

##### Which of these about a set is not true?

Options are :

• Mutable data type
• Allows duplicate values
• Data type with unordered values
• Immutable data type

##### Which of the following is not the correct syntax for creating a set?

Options are :

• set([[1,2],[3,4]])
• set([1,2,2,3,4])
• set((1,2,3,4))
• {1,2,3,4}

##### What will be the output of the following Python code?`nums = set([1,1,2,3,3,3,4,4])print(len(nums))`

Options are :

• 7
• Error, invalid syntax for formation of set
• 4
• 8

##### What will be the output of the following Python code?`a = [5,5,6,7,7,7]b = set(a)def test(lst): if lst in b: return 1 else: return 0for i in filter(test, a): print(i,end=" ")`

Options are :

• 5 5 6
• 5 6 7
• 5 5 6 7 7 7
• 5 6 7 7 7

Answer :5 5 6 7 7 7

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions