Python MCQ - Curious Programmer
Python MCQ - Curious Programmer
with Answer
and
Explanation
@curious_.programmer
Python MCQ (Multi Choice Questions)
Q. What is the maximum possible length of an identi er?
a. 16
b. 32
c. 64
d. None of these above
fi
fi
fi
Answer: (b) C
Explanation: Python is written in C programming
language, and it is also called CPython.
fi
Answer: (c) #
Explanation: "#" character is used in Python to make a
single-line comment.
fi
fi
d. 5
Answer: (d) 5
= = 0:
break
prin
t(x)
x+
=1
What will be the output of this code?
a. error
b. 2 1
c. 0 3 1
d. None of these
Q. Study the
following code:
x = ['XX', 'YY']
for i
in a:
i.low
er()
fi
fi
fi
fi
fi
fi
fi
print(a)
What will be the output
of this program? a.
['XX', 'YY']
b. ['xx', 'yy']
c. [XX, yy]
d. None of these
Answer: (a) t
Explanation: The correct output of this program is "t"
because -1 corresponds to the last index.
Answer: (a) 33
Explanation: A, B and C are hexadecimal integers with
values 10, 11 and 12 respectively, so the sum of A, B and C
is 33.
7. obj = page(32)
8. print "%d %d" % (obj.o1, obj.o2)
Which of the following is the correct output of this program?
a. 32
b. 32 32
c. 32 None
d. Error is generated
fi
fi
fi
fi
fi
fi
fi
d. Wick Nick
Q. Study the
following program:
1. x = ['xy', 'yz']
2. for i in a:
3. i.upper()
4. print(a)
Which of the following is correct
output of this program? a. ['xy',
'yz']
b. ['XY', 'YZ']
c. [None, None]
d. None of these
Q. Study the
following program:
1. i = 1:
2. while True:
3. if i%3 == 0:
4. break
5. print(i)
Which of the following is the
correct output of this program? a.
123
b. 3 2 1
c. 1 2
d. Invalid syntax
Q. Study the
following program:
1. a = 1
2. while True:
3. if a % 7 = = 0:
4. break
5. print(a)
6. a += 1
Which of the following is correct
output of this program? a. 1 2 3
45
b. 1 2 3 4 5 6
c. 1 2 3 4 5 6 7
d. Invalid syntax
Answer: (b) 1 2 3 4 5 6
Explanation: None
Q. Study the
following program:
1. i = 0
2. while i < 5:
3. print(i)
4. i += 1
5. if i == 3:
6. break
7. else:
8. print(0)
What will be the output
of this statement? a. 1
23
b. 0 1 2 3
c. 0 1 2
d. 3 2 1
Answer: (c) 0 1 2
Explanation: None
Q. Study the
following program:
1. i = 0
2. while i < 3:
3. print(i)
4. i += 1
5. else:
6. print(0)
What will be the output of this statement?
a. 0 1
b. 0 1 2
c. 0 1 2 0
d. 0 1 2 3
Answer: (c) 0 1 2 0
Explanation: None
4. print (x)
Which of the following is the correct output of this program?
a. PQRS
b. pqrs
c. qrs
d. None of these
Q. Study the
following program:
1. d = {0: 'a', 1: 'b',
2: 'c'}
2. for i in d:
3. print(i)
What will be the output of this statement?
a. a b c
b. 0 1 2
c. 0 a 1 b 2 c
d. None of these above
Answer: (b) 0 1 2
Explanation: None
Q. Study the
following program: 1.
d = {0, 1, 2}
2. for x in d:
3. print(x)
What will be the output
of this statement? a.
{0, 1, 2} {0, 1, 2} {0, 1,
2}
b. 0 1 2
c. Syntax_Error
d. None of these above
Answer: (b) 0 1 2
Explanation: None
fi
d. ValueError
Q. Study the
following
statement z =
{"x":0, "y":1}
Which of the following is the correct statement?
a. x dictionary z is created
b. x and y are the keys of dictionary z
c. 0 and 1 are the values of dictionary z
d. All of the above
NUMPY :
Question:
Correct syntax of the reshape() function in Numpy array
python is -
1.array.resha
pe(shape)
2.reshape(sha
pe,array)
3.reshape(arr
ay,shape)
4.reshape(sha
pe) Answer:3
Question:
How we can change the shape of the Numpy array in
python?
1.By
Shape()
2.By
reshape
() 3.By
ord()
4.By
change(
)
Answer:
2
Question:
How we can convert the Numpy array to the list in python?
1.list(arra
y)
2.list.arra
y
3.array.li
st
4.None of
the above
Answer:1
Question:
How we can nd the type of numpy array in python ?
1.dty
pe
2.typ
fi
e
3.typ
ei
4.ityp
e
Answ
er:1
Question:
How we install Numpy in the system ?
1.install numpy
2.pip install
python numpy
3.pip install
numpy
4.pip install
numpy python
Answer:3
Question:
It is possible to convert the Numpy array to list in python ?
1.Y
es
2.
No
3.Sometim
es 4.None
of the
above
Answer:1
Question:
Minimum number of argument to pass in full() function in
Numpy array ?
1.0
2.1
3.2
4.3
Answer:3
Question:
Numpy in the Python provides the
1.Function
2.Lambda
function
3.Type
casting
4.Array
Answer:4
Question:
Numpy.array(list), what it does ?
1.It convert
array to list
2.It convert
list to array
3.It convert
array to
array 4.Error
Answer:2
Question:
Shape() function in Numpy array is used to
Question:
What is the use of the size attribute in Numpy array in
python ?
Question:
what is the use of the zeros() function in Numpy array in
python ?
Question:
Which of the following argument we need to pass in
reshape() function?
1.Array
fi
fi
fi
2.Shap
e
3.only
array
4.Both array
and shape
Answer:4
Question:
Which of the following counts the number of elements in
Numpy array ?
1. c o
unt()
2.ret
urn(
)
3.sh
ape(
)
4.size
()
Answ
er:4
Question:
Which of the following nd the maximum number in the
Numpy array ?
1.max(arra
y)
2.array.ma
x()
3.array(ma
x) 4.None
of the
above
Answer:2
Question:
Which of the following is correct way to import the
Numpy module in your program ?
1.import
fi
numpy
2.import
numpy as np
3.from
numpy
import * 4.All
of the above
Answer:4
Question:
Which of the following is not valid to import the numpy
module ?
1.import
numpy as np
2.import
numpy as n
3.import
numpy as p
4.None of the
above
Answer:4
Question:
Which of the following is the essential argument to pass in
full() function of Numpy array ?
1.sh
ap
e
2.v
alue
3.Bot h of
the above
4.None of
the above
Answer:3
Question:
Which of the following is used to convert the list data type
to the Numpy array ?
1.array(list
)
2.array.list
3.Numpy.a
rray(list)
4.None of
the above
Answer:3
Question:
Which of the following keyword is used to access the
numpy module in python ?
1.acc
ess
2.imp
ort
3.fetc
h
4.fro
m
Answ
er:2
A.minor_axis
B.major_axis
C.items
D.None of
the above
View Answer
Ans : B
B.an ndarray
C.a scalar value
D.All of
the above
View
Answer
Ans : D
A.yhat
B.Seaborn
C.Vincent
D.P y c
h a r t
View
Answe
r Ans :
B
fi
View
Answer
Ans : C
fi
A.science library
B.source library
C.signi cant library
D.scienti c
library Ans :
A.scipy.cluster
B.scipy.source
C.scipy.interpolate
D.scipy.signal
fi
fi
fi
fi
Ans : B
the above
Ans : D
Ans : C
A.import scipy.constants
B.from scipy.constants
C.import scipy.constants.package
D.from
scipy.constants.pac
kage Ans : B
A.G
B.e
C.R
D.
Ans
:D
fi
from scipy
import linalg
import
numpy as np
a = np.array([[3, 2, 0], [1, -1, 0], [0, 5, 1]])
b=
np.array([2,
4, -1]) x =
linalg.solve(
a, b) print x
A. array([ 2., -2., 9., 6.])
B. array([ 2., -2., 9.])
C. array([ 2., -2.])
D. array([ 2., -2., 9., -9.])
Ans : B
A.determinant()
B.SciPy.determinant()
C.det()
D.SciPy.
det() Ans
:C
A.Av = lambda*v
B.Av =Constant * lambda*v
C.Av =10 * lambda*v
D.Av !=
lambda*v
Ans : A
or method.
C.The main focus of ML is to allow computer
systems learn from experience without being
explicitly programmed or human intervention.
D.All of
the above
Ans : D
Q. p → 0q is not a?
A.hack clause
B.horn clause
C.structural clause
D.system
fi
fi
clause Ans
:B
A.STACK(A,B)
B.LIST(A,B)
C.QUEUE(A,B)
D.ARRAY
(A,B) Ans :
A
A.bottow-up parser
B.top parser
C.top-down parser
D.bottom
parser Ans
:C
A.System Unit
B.structural units.
C.data units
D.empiric
al units Ans
:B
A.Introduction
B.Analogy
C.Deduction
D.Memor
ization Ans
:A
is known as ?
A.Batch learning
B.Of ine learning
C.Both A and B
D.None of
the above Ans
:C
fl
Q. In Model based learning methods, an iterative process
takes place on the ML models that are built based on
various model parameters, called ?
A.mini-batches
B.optimizedparameters
C.hyperparameters
D.superpa
rameters
Ans : C
A.Decision Tree
B.Regression
C.Classi cation
D.Random
Forest Ans :
D
fi
A.Factor analysis
B.Decision trees are robust to outliers
C.Decision trees are prone to be over t
D.None of
the above Ans
:C
fi
fi
fi
A.Drop missing rows or columns
B.Replace missing values with mean/median/mode
C.Assign a unique category to missing values
D.All of
the above
Ans : D
fi
A.Stemming
B.Lemmatization
C.Stop Word Removal
D.None of
the above Ans
:C
A.1 and 2
fi
fi
B.2 and 3
C.1 and 3
D.All of
the above
Ans : D