PYTHON BASIC MCQ
[Link] is the output of the following program?
y=8
z = lambda x: x * y
print z (6)
A. 48
B. 14
C. 64
D. None of the above
[Link] is the output of the following program?
import re
sentence = 'horses are fast'
regex = [Link]('(?P<animal>w+) (?P<verb>w+) (?P<adjective>w+)')
matched = [Link](regex, sentence)
print([Link]())
A. {‘animal’: ‘horses’, ‘verb’: ‘are’, ‘adjective’: ‘fast’}
B. (‘horses’, ‘are’, ‘fast’)
C. ‘horses are fast’
D. ‘are’
[Link] is the output of the following code?
print 9//2
A. 4.5
B. 4.0
C. 4
D. Error
[Link] operator is overloaded by the or () function?
A. ||
B. |
C. //
D. /
5. What is the output of the following program?
print 0.1 + 0.2 == 0.3
A. True
B. False
C. Machine dependent
D. Error
[Link] is the output of the following program?
print "Hello World"[::-1]
A. dlroW olleH
B. Hello Worl
C. d
D. Error
[Link] data type is the object below? L = [1, 23, ‘hello’, 1]
A. List
B. Dictionary
C. Tuple
D. Array
[Link] is the output of the following program?
def myfunc(a):
a=a+2
a=a*2
return a
print myfunc(2)
A. 8
B. 16
C. Indentation Error
D. Runtime Error
[Link] is the output of the following program?
print '{0:.2}’. format (1.0 / 3)
A. 0.333333
B. 0.33
C. 0.333333: -2
D. Error
[Link] is the output of the following program?
i=0
while i < 3:
print i
i += 1
else:
print 0
A. 01230
B. 0120
C. 012
D. Error
[Link] is the output of the following program?
import numpy as np
[Link]((2,2))
A. array ([[0., 0.], [0., 0.]])
B. array ([[0., 0.])
C. array ([0., 0.], [0., 0.])
D. error
[Link] is the output of the following program?
import numpy as np
e = [Link]([(1,2,3), (4,5,6)])
print(e)
[Link](3,2)
A. array([[1, 2],[3, 4],[5, 6]])
B. array([[1, 2],[5, 6]],[3, 4])
C. array([[5, 6]],[1, 2],[3, 4])
D. error
[Link] is the output of the following program?
## Horitzontal Stack
import numpy as np
f = [Link]([1,2,3])
g = [Link]([4,5,6])
print('Horizontal Append:', [Link]((f, g)))
A. Horizontal Append: [4 5 6 1 2 3]
B. Horizontal Append: [1 2 3 4 5 6]
C. Horizontal Append: [1 2 3]
D. All the above
[Link] is the output of the following program?
x = [Link]([1,2,3], dtype=np.complex128)
[Link]
A. 16
B. 61
C. 6
D. Error
[Link] is the output of the following program?
f = [Link]([1,2])
g = [Link]([4,5])
[Link](f, g)
A. 31
B. 12
C. 14
D. Error
[Link] is the output of the following program?
h = [[1,2],[3,4]]
i = [[5,6],[7,8]]
[Link](h, i)
A. array([[43, 50],[19, 22]])
B. array([[19, 22],[43, 50]])
C. error
D. All the above
[Link] is the output of the following program?
import numpy np
[Link](1, 11)
A. array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
B. array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
C. array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
D. error
[Link] is the output of the following program?
[Link](1.0, 5.0, num=5, endpoint=False)
A. array([1. , 1.8, 2.6, 3.4, 4.2])
B. array([1. , 1.8, 2.6, 3.4, 4.2, 5])
C. error
D. All the above
[Link] is the output of the following program?
import numpy as np
x = [Link]([[1, 2], [3, 4], [5, 6]])
y = x [[0,1,2], [0,1,0]]
print y
A. [5 4 1]
B. [1 4 5]
C. [4 1 5]
D. Error
[Link] is the output of the following program?
import numpy as np
print [Link]([1,2,3,4])
A. 1.25
B. 1
C. 1.0
D. Error
[Link] is the output of the following program?
import pandas as pd
s = [Link]([1,2,3,4,5],index = ['a','b','c','d','e'])
print s[0]
A. 1
B. 0
C. 2
D. Error
[Link] is the output of the following program?
import pandas as pd
import numpy as np
df = [Link](index=[0,1,2,3,4,5],columns=['one','two'])
print df['one']. sum ()
A. 0
B. nan
C. error
D. All the above
[Link] is the output of the following program?
import pandas as pd
print [Link]('2017-03-01')
A. 2017-03-01 00:00
B. 2017-03-01 [Link]
C. 2017-03-01 00:01
D. All the above
[Link] is the output of the following program?
import pandas as pd
import numpy as np
cat = [Link](["a", "c", "c", [Link]], categories=["b", "a", "c"])
print [Link]
A. True
B. False
C. Error
D. All the above
[Link] is the output of the following program?
import pandas as pd
if [Link]([False, True, False]).any():
print ("I am any")
A. I am any
B. I any
C. any
D. Error
[Link] of the following input can be accepted by DataFrame ?
A. Structured ndarray
B. Series
C. DataFrame
D. All of the Mentioned
[Link] of the following takes a dict of dicts or a dict of array-like sequences and returns a
DataFrame ?
A. DataFrame.from_items
B. DataFrame.from_records
C. DataFrame.from_dict
D. All of the Mentioned
[Link] out the wrong statement:
A. A DataFrame is like a fixed-size dict in that you can get and set values by index label
B. Series can be be passed into most NumPy methods expecting an ndarray
C. A key difference between Series and ndarray is that operations between Series
automatically align the data based on label
D. None of the Mentioned
[Link] data is an ndarray, index must be the same length as data.
A. True
B. False
30. 1. Which of the following thing can be data in Pandas?
A. a python dict
B. a ndarray
C. a scalar value
D. all of the Mentioned