406C - Python Programming
406C - Python Programming
406C - Python Programming
9. _____________ datatype represents a group of elements written in the form of several key values pairs.
A. complex
B. byte
C. bytearray
D. dict
ANSWER: D
16. When there are multiple words in a construct, they should be given with _________
A. Dot (.)
B. Hyphen (-)
C. Underscore (_)
D. Comma (,)
ANSWER: C
17. Triple double quotes or triple single quotes at the beginning and end of the block are used for
___________
A. Strings
B. Constants
C. Multiline comments
D. characters
ANSWER: C
24. What will be the output of the following Python code? x = ['ab', 'cd'] for i in x: i.upper() print(x)
A. ['ab', 'cd']
B. ['AB', 'CD']
C. [None, None]
D. none of the mentioned
ANSWER: A
25. Which one of the following has the highest precedence in the expression?
A. Exponential
B. Parentheses
C. Addition
D. Multiplication
ANSWER: B
26. Which one of the following has the same precedence level?
A. Multiplication, Division and Addition
B. Multiplication, Division, Addition and Subtraction
C. Addition and Multiplication
D. Addition and Subtraction
ANSWER: D
27. In order to store values in terms of key and value, which ore data type is used?
A. list
B. tuple
C. class
D. dictionary
ANSWER: D
29. Given a function that does not return any value, What value is thrown by default when executed in shell.
A. int
B. bool
C. void
D. none
ANSWER: D
30. What will be the output of the following Python code? >>>str="hello" >>>str[:2]
A. he
B. lo
C. olleh
D. hello
ANSWER: A
35. Py_compile module converts python source file into _______________ file.
A. .py
B. .pyc
C. .pc
D. .xpy
ANSWER: B
36. __________ module displays the byte code instruction in human readable format.
A. Dis
B. Pandas
C. Xlrd
D. py
ANSWER: A
38. ________________ package is useful to extract data from excel spreadsheet file.
A. Dis
B. Pandas
C. Xlrd
D. py
ANSWER: C
39. Pypy is a just in time compiler used to ________________ execution of the python program.
A. reduce
B. elongate
C. bring down
D. Speed up
ANSWER: D
45. Operators with the same precedence are evaluated in which manner?
A. Cannot predict
B. Right to Left
C. Left to Right
D. None of the mentioned
ANSWER: C
46. Which is the membership operator used for testing if an element is present in a sequence or not?
A. like, unlike
B. is, is not
C. ismember
D. in, not in
ANSWER: D
58. What will be the output of the following Python code? Â def cube(x): return x *x*x x = cube(3) print x
A. 9
B. 6
C. 27
D. 36
ANSWER: C
59. Python supports the creation of anonymous functions at runtime, using a construct called __________
A. lambda
B. pi
C. none
D. all of the above
ANSWER: A
60. What will be the output of the following Python code? def f(x, y, z): return x + y + z f(2, 30, 400)
A. 433
B. 432
C. 431
D. 430
ANSWER: B
62. What will be the output of the following Python expression? Â round(4.576)
A. 4
B. 3
C. 5
D. 6
ANSWER: C
63. What will be the output of the following Python function? all([2,4,0,6])
A. True
B. error
C. false
D. 0
ANSWER: C
64. What will be the output of the following Python expression? round(4.5676,2)?
A. 4.5
B. 5
C. 4.56
D. 4.57
ANSWER: D
65. What will be the output of the following Python function? sum(2,4,6) sum([1,2,3])
A. Error, 6
B. Error, 17
C. Error, 12
D. Error, 20
ANSWER: A
66. What will be the output of the following Python function? complex(1+2j)
A. 1
B. 2
C. 1+2j
D. 2+1j
ANSWER: C
69. Which of the following functions will not result in an error when no arguments are passed to it?
A. float()
B. all()
C. div()
D. divall()
ANSWER: A
70. What will be the output of the following Python function? hex(15)
A. 0Xf
B. 0xf
C. 1Xf
D. 1xf
ANSWER: B
72. What will be the output of the following Python function? len(["hello",2, 4, 6])
A. 4
B. 5
C. 6
D. 7
ANSWER: A
82. Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0], Which of the following is correct syntax for slicing operation?
A. print(list1[0])
B. print(list1[:2])
C. print(list1[:-2])
D. all of the mentioned
ANSWER: D
83. Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1]?
A. Error
B. None
C. 25
D. 2
ANSWER: C
84. Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1]?
A. [2, 33, 222, 14]
B. [ 33, 222, 14]
C. [2, 33, 14]
D. [2, 33, 222, 214]
ANSWER: A
89. Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.reverse()?
A. [3, 1, 25, 5, 20, 4, 3]
B. [3, 1, 5, 20, 5, 4, 3]
C. [3, 25, 5, 20, 5, 4, 3]
D. [3, 1, 25, 5, 20, 5, 4, 3]
ANSWER: D
90. Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.pop(1)?
A. [3, 5, 20, 5, 25, 1, 4,3]
B. [3, 5, 20,4, 5, 25, 1, 3]
C. [3, 5, 20, 5, 25, 1, 3]
D. [3,4, 5, 20, 5, 25, 1, 3]
ANSWER: C
92. To read two characters from a file object infile, we use ____________
A. infile.read(2)
B. infile.read()
C. infile.readline()
D. infile.readlines()
ANSWER: A
93. To read the next line of the file from a file object infile, we use ____________
A. infile.read(2)
B. infile.read()
C. infile.readline()
D. infile.readlines()
ANSWER: C
95. Which of the following functions does not accept any argument?
A. re.purge
B. re.compile
C. re.findall
D. re.match
ANSWER: A
96. What will be the output of the following Python code? #generator def f(x): yield x+1 g=f(8) print(next(g))
A. 9
B. 8
C. 7
D. 6
ANSWER: A
100. In the following options which are python libraries which are used for data analysis and scientific
computations
A. Numpy
B. Scipy
C. Pandas
D. all the above
ANSWER: D
104. Which of the following is required to create a new instance of the class?
A. class
B. method
C. constructor
D. values
ANSWER: C
108. Suppose d = {"john":40, "peter":45}. To obtain the number of entries in dictionary which command do
we use?
A. d.size()
B. len(d)
C. size(d)
D. d.len()
ANSWER: B
110. To which of the following the "in" operator can be used to check if an item is in it?
A. Lists
B. Dictionary
C. Set
D. All of the mentioned
ANSWER: D
111. Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0], Which of the following is correct syntax for slicing operation?
A. print(list1[0])
B. print(list1[:2])
C. print(list1[:-2])
D. all of the mentioned
ANSWER: D
118. Where are the arguments received from the command line stored?
A. sys.argv
B. os.argv
C. argv
D. none of the mentioned
ANSWER: A
120. Which module in the python standard library parses options received from the command line?
A. getopt()
B. main
C. module
D. os
ANSWER: A
121. How are variable length arguments specified in the function heading?
A. one star followed by a valid identifier
B. one underscore followed by a valid identifier
C. two stars followed by a valid identifier
D. two underscores followed by a valid identifier
ANSWER: A
122. Which of the following functions will not result in an error when no arguments are passed to it?
A. min()
B. divmod()
C. all()
D. float()
ANSWER: D
123. What will be the output of the following Python function any([2>8, 4>2, 1>2])?
A. Error
B. True
C. False
D. 4>2
ANSWER: B
125. What will be the value of X in the following Python expression? X = 2+9*((3*12)-8)/10
A. 27.6
B. 27.7
C. 22.2
D. 27.2
ANSWER: D
126. Which among the following list of operators has the highest precedence? +, -, **, %, /, <<, >>, |
A. **
B. |
C. <<
D. >>
ANSWER: A
127. What will be the value of the following Python expression? float(4+int(2.39)%2)
A. 5.0
B. 5
C. 4.0
D. 4
ANSWER: D
129. What will be the value of the following Python expression? 4+2**5//10
A. 3
B. 7
C. 77
D. 0
ANSWER: B
130. What will be the output of the following Python code snippet if x=1? x<<2
A. 8
B. 1
C. 2
D. 4
ANSWER: D
132. What will be the output of the following Python expression? int(1011)?
A. 1011
B. 10
C. 1101
D. 1111
ANSWER: A
133. To find the decimal value of 1111, that is 15, we can use the function:
A. int(1111,10)
B. int('1111',10)
C. int(1111,2)
D. int('1111',2)
ANSWER: D
135. What will be the output of the following Python expression? 0x35 | 0x75
A. 115
B. 116
C. 117
D. 118
ANSWER: C
136. Bitwise _________ gives 1 if either of the bits is 1 and 0 when both of the bits are 1.
A. OR
B. AND
C. XOR
D. NOT
ANSWER: C
142. The expression a{5} will match _____________ characters with the previous regular expression.
A. more than 5 elements
B. less than 5 elements
C. exactly 5 elements
D. none
ANSWER: C
144. What will be the output of the following Python code? >>>a={3,4,5} >>>a.update([1,2,3]) >>> a
A. {1.2.3.4.5}
B. {3,4,5}
C. {1,2,3}
D. Error
ANSWER: A
145. What will be the output of the following Python code? import time time.asctime()
A. Current date only
B. UTC time
C. Current date and time
D. Current time only
ANSWER: C
146. What will be the output of the following Python code, if the time module has already been imported? 4 +
'3'
A. NameError
B. IndexError
C. ValueError
D. TypeError
ANSWER: D
147. What will be the output of the following Python code? x = (i for i in range(3)) for i in x: print(i)
A. 0 1 2
B. error
C. 0 1 2 0 1 2
D. none of the mentioned
ANSWER: A
149. Which is the function used to remove the given item as parameter?
A. pop()
B. remove()
C. del()
D. delete()
ANSWER: B
150. Which is the type code that has to given to given for array of double type?
A. d
B. D
C. L
D. l
ANSWER: A
Staff Name
Srividhya R .