  ## Python Certification Exam Preparation Set 27

##### What is the output when we execute list("hello")?

Options are :

• ['h', 'e', 'l', 'l', 'o'] (Correct)
• ['hello']
• ['llo']
• ['olleh']

Answer :['h', 'e', 'l', 'l', 'o']

Options are :

• 5 (Correct)
• 4
• None
• Error

##### What will be the output of the following Python code?`x = ['ab', 'cd']for i in x: x.append(i.upper())print(x)`

Options are :

• none of the mentioned (Correct)
• ['AB', 'CD']
• ['ab', 'cd']
• ['ab', 'cd', 'AB', 'CD']

##### What will be the output of the following Python code snippet?`['hello', 'morning'][bool('')]`

Options are :

• no output
• error
• morning
• hello (Correct)

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

Options are :

• Data type with unordered values
• Mutable data type
• Allows duplicate values
• Immutable data type (Correct)

##### Which of the following Boolean expressions is not logically equivalent to the other three?

Options are :

• not(-6<10 or-6==10)
• -6>=0 and -6<=10
• not(-6<0 or-6>10)
• not(-6>10 or-6==10) (Correct)

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

Options are :

• None
• Error
• False (Correct)
• True

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

Options are :

• [1, 4, 8] (Correct)
• (1, 4, 8)
• [1, 2, 4, 3, 8, 9]
• [2, 3, 9]

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

Options are :

• Error (Correct)
• 2
• 1
• 5

##### What will be the output of the following Python code?`>>>t=(1,2,4,3)``>>>t[1:-1]`

Options are :

• (2, 4, 3)
• (1, 2, 4)
• (2, 4) (Correct)
• (1, 2)

##### What will be the output of the following Python code snippet?`X="get-job"print("%56s",X)`

Options are :

• 56 blank spaces after get-job
• 56 blank spaces before get-job (Correct)
• 56 blank spaces before get-job
• no change

Answer :56 blank spaces before get-job

##### What will be the output of the following Python code?`import math[str(round(math.pi)) for i in range (1, 6)]`

Options are :

• ['3.1', '3.14', '3.142', '3.1416', '3.14159', '3.141582']
• ['3', '3', '3', '3', '3'] (Correct)
• ['3', '3', '3', '3', '3', '3']
• ['3.1', '3.14', '3.142', '3.1416', '3.14159']

Answer :['3', '3', '3', '3', '3']

##### What will be the output of the following Python code?`l1=[1,2,3]l2=[4,5,6]l3=[7,8,9]for x, y, z in zip(l1, l2, l3): print(x, y, z)`

Options are :

• Error
• 1 4 7 2 5 8 3 6 9 (Correct)
• [(1, 4, 7), (2, 5, 8), (3, 6, 9)]
• (1 4 7) (2 5 8) (3 6 9)

Answer : 1 4 7 2 5 8 3 6 9

##### What will be the output of the following Python code?`x = ['ab', 'cd']for i in x: i.upper()print(x)`

Options are :

• none of the mentioned
• [None, None]
• ['AB', 'CD']
• ['ab', 'cd'] (Correct)

##### Which of the following statements is used to create an empty set?

Options are :

• [ ]
• ( )
• set() (Correct)
• { }

Options are :

• 45
• "john"
• "peter"
• 40 (Correct)

##### What will be the output of the following Python code?`>>>t=(1,2,4,3)``>>>t[1:3]`

Options are :

• (1, 2)
• (2, 4, 3)
• (2, 4) (Correct)
• (1, 2, 4)

Options are :

• f
• Error
• t (Correct)
• No output

##### What will be the output of the following Python code?`l=[1, 0, 2, 0, 'hello', '', []]list(filter(bool, l))`

Options are :

• [1, 0, 2, 0, 'hello', ", []]
• Error
• [1, 0, 2, 'hello', ", []]
• [1, 2, 'hello'] (Correct)

##### 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]]) (Correct)
• {1,2,3,4}

##### Which of the following is a Python tuple?

Options are :

• {1, 2, 3}
• (1, 2, 3) (Correct)
• [1, 2, 3]
• {}

##### What will be the output of the following Python code?`l=[[1 ,2, 3], [4, 5, 6], [7, 8, 9]][[row[i] for row in l] for i in range(3)]`

Options are :

• Error
• (1 4 7) (2 5 8) (3 6 9)
• [[1, 4, 7], [2, 5, 8], [3, 6, 9]] (Correct)
• 1 4 7 2 5 8 3 6 9

Answer :[[1, 4, 7], [2, 5, 8], [3, 6, 9]]

Options are :

• 33 (Correct)
• 24
• 30
• 12

##### What will be the output of the following Python code?`class Truth: passx=Truth()bool(x)`

Options are :

• pass
• true (Correct)
• false
• error

##### What will be the output of the following Python code?`>>>t = (1, 2)``>>>2 * t`

Options are :

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

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

Options are :

• False
• True (Correct)
• {1,2}
• Invalid operation

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

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

##### What will be the output of the following Python code?`if (9 < 0) and (0 < -9): print("hello")elif (9 > 0) or False: print("good")else: print("bad")`

Options are :

• error
• hello
• good (Correct)

##### What will be the output of the following Python code snippet?`X="hi"print("05d"%X)`

Options are :

• hi000
• 00000hi
• error (Correct)
• 000hi

##### 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 7 7 7 (Correct)
• 5 6 7
• 5 5 6
• 5 6 7 7 7

Answer :5 5 6 7 7 7

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions