python mcq
python mcq
6)What is an identifier?
input eval
false None
Answer : Correct Option is : (d)
as While
with def
Answer : Correct Option is : (b)
S.I. 1stNo
class _12
Answer : Correct Option is : (d)
MyNo No 1
Value My_result
Answer : Correct Option is : (b)
+ =>
<= not
Answer : Correct Option is : (c)
>= or
in %
Answer : Correct Option is : (b)
2.6 2
3 0.6
Answer : Correct Option is : (c)
0 7
0.7 Error
Answer : Correct Option is : (b)
0 5
1.7 1
Answer : Correct Option is : (d)
0 0.9
1 Error
Answer : Correct Option is : (a)
21)"123" is a_______
variable string
string literal integer literal
Answer : Correct Option is : (c)
constant variable
string value
Answer : Correct Option is : (b)
23)Which one of the following is a relational operator?
= ==
=> and
Answer : Correct Option is : (b)
int float
decimal All of these
Answer : Correct Option is : (c)
True False
0 1
Answer : Correct Option is : (b)
47 2324
'2324' Error
Answer : Correct Option is : (c)
99 4455
'4455' Error
Answer : Correct Option is : (d)
Sequence List
Tuple None
Answer : Correct Option is : (a)
32)Which built in function in Python returns the unique number assigned to an object?
identity() ref()
reference() id()
Answer : Correct Option is : (d)
33)The _____ operator is used to check if two operands reference the same object
memory.
== is
id in
Answer : Correct Option is : (b)
34)For two variables a and b, the expression 'a is b' returns True if and only if -
id(a)==id(b) a==b
len(a)==len(b) all of these
Answer : Correct Option is : (a)
String Tuple
Dictionary Set
Answer : Correct Option is : (c)
True False
Only in function Only in module
Answer : Correct Option is : (b)
37)A Python variable is assigned a value of one type, later assigned a value of different
type, it will yield -
Error Warining
None No error
Answer : Correct Option is : (d)
38)A variable in Python can be assigned with any type of values, it is called-
39)Is it safe to use '==' to determine if two objects of type float is equal or not?
Yes No
Yes for small number only Yes for big number only
Answer : Correct Option is : (b)
+ **
not %
Answer : Correct Option is : (a)
0 10
True False
Answer : Correct Option is : (b)
True False
0 20
Answer : Correct Option is : (d)
0 10
True False
Answer : Correct Option is : (a)
5 10
True False
Answer : Correct Option is : (a)
True False
a b
Answer : Correct Option is : (d)
46)An empty or null statement in Python is ____
go pass
over None
Answer : Correct Option is : (b)
flow repeatation
selection sequence
Answer : Correct Option is : (d)
48)The construct that repeat a set of statements for a specific number of times.
selection sequence
repeatation None of these
Answer : Correct Option is : (c)
for while
if-else none of these
Answer : Correct Option is : (c)
for if-else
both (a) and (b) none of these
Answer : Correct Option is : (a)
selection repeatation
sequence none of these
Answer : Correct Option is : (a)
52)Which one of the following is not a valid loop in Python?
for do-while
while none of these
Answer : Correct Option is : (b)
continue break
pass go
Answer : Correct Option is : (b)
continue break
pass go
Answer : Correct Option is : (a)
5 0
infinite times Error
Answer : Correct Option is : (b)
[] [0,1,2,3]
[0, 1, 2] [1, 2, 3]
Answer : Correct Option is : (c)
range(1, 3) range(0,3)
range(0,4) range(1,4)
Answer : Correct Option is : (b)
2, 4, 6 2, 4
2 6
Answer : Correct Option is : (b)
8 14
16 infinite loop
Answer : Correct Option is : (a)
5 1
0 none of these
Answer : Correct Option is : (c)
1)Positive index of a string starts from-
+ *
/ in
Answer : Correct Option is : (c)
count() len()
index() none of these
Answer : Correct Option is : (b)
find() partition()
split() index()
Answer : Correct Option is : (c)
67)Which of the following functions returns the string in all capital letter?
toupper() upper()
isupper() to-upper()
Answer : Correct Option is : (b)
68)Which of the following functions will convert the string I love python
programing to I Love Python Programing?
title() capitalize()
upper() istitle()
Answer : Correct Option is : (a)
69)Which of the following functions will returns a tuple having the string in 3 pieces?
split() partition()
upper() replace()
Answer : Correct Option is : (b)
70)Which of the following functions returns the character from ASCII code?
ord() char()
character() chr()
Answer : Correct Option is : (d)
lstrip() rstrip()
strip() all of these
Answer : Correct Option is : (c)
72)Which of the following will return last three characters of the string S?
S[3::] S[-3::]
S[::-3] S[:3:]
Answer : Correct Option is : (b)
Hello2 HelloHe
HelloHello Error
Answer : Correct Option is : (c)
74)If a string contains letter and digit, then which function returns True?
isalpha() isdigit()
isalnum() none of these
Answer : Correct Option is : (c)
float integer
list all of these
Answer : Correct Option is : (d)
list(0) list()
list(empty) all of these
Answer : Correct Option is : (b)
78)If L1=[1, 2] and L2=[11, 22] then which one of the following will be returned by
L1+L2?
80)A list S having 7 elements the which one of the following will return the last
element?
S[-1] S[7]
S[len(S)] All of these
Answer : Correct Option is : (a)
L=list() L=[ ]
L=list(range(3)) All of these
Answer : Correct Option is : (d)
S[::-1] S[5:1]
S[len(S):1] S[-1:5]
Answer : Correct Option is : (a)
83)If k=[1,2,3,4,5,6,7] then which one of the following will be returned by print(k[-4:-
1])?
[4, 5, 6, 7] [4, 5, 6]
[7, 6, 5, 4] [7, 6, 5]
Answer : Correct Option is : (b)
[4, 6, 8] [2, 4, 6]
[4, 8, 12] [2, 6, 10]
Answer : Correct Option is : (c)
Error [8]
[7, 8] [3, 4, 5, 6, 7, 8]
Answer : Correct Option is : (d)
pop() remove()
len() append()
Answer : Correct Option is : (c)
pop() add()
append() insert()
Answer : Correct Option is : (c)
89)Which of the following methods is used to add more than one element at the end of
a list?
append() add()
insert() extend()
Answer : Correct Option is : (d)
del pop()
remove() all of these
Answer : Correct Option is : (d)
91)Which one of the following will create a tuple?
T=(3)*3 T=(3,)*3
T[3]=(1, 2, 3) None of these
Answer : Correct Option is : (b)
List is immutable but tuple is mutable Both list and tuple are immutable
Tuple is immutable but list is mutable Both tuple and list are mutable
Answer : Correct Option is : (c)
Tuple can contain only string Tuple can contain only integer
Tuple can contain different types of
Tuple can contain only string and integer
elements
Answer : Correct Option is : (d)
94)Which one of the following will create a tuple with single element?
T=(4,) T=(5)
T=([5]) T=tuple(5)
Answer : Correct Option is : (a)
Error 1
0 2
Answer : Correct Option is : (c)
(1, 2, 3, 4) (2, 3, 4, 5)
(1, 2, 3, 4, 5) Error
Answer : Correct Option is : (d)
99)If T=(2, 3, 4) then which one of the following will raise an error?
T.sort() sorted(T)
max(T) sum(T)
Answer : Correct Option is : (a)
10 0
1 Error
Answer : Correct Option is : (d)
0 3
4 Error
Answer : Correct Option is : (c)
Error (6,)
() (6, 7)
Answer : Correct Option is : (b)
(1, 2, 3, 4, 5, 6) (1, 2, 3, 4, 5, 6, 7)
(7,) ()
Answer : Correct Option is : (a)
(1, 2, 3, 4, 5, 6, 7) (7, 6, 5, 4, 3, 2, 1)
() (7,)
Answer : Correct Option is : (b)
105)If T=(1, 2, 3, 4, 5, 6,7) then which two of the following will give the same output.
i) print(T[0:7])
ii) print(T[0:6])
iii) print(T[:-1])
iv) print(T[0:-6])
unordered ordered
sorted unsorted
Answer : Correct Option is : (a)
values() keys()
update() items()
Answer : Correct Option is : (b)
110)Which of the following dictionary methods creates a dictionary with given keys and
common values?
default() update()
fromkeys() values()
Answer : Correct Option is : (c)
111)Which of the following dictionary methods will add a key-value pair in the
dictionary only if it does not exist?
fromkeys() setdefault()
update() items()
Answer :
112)If no values are specified in fromkeys() method then which of the following values
are assigned to the keys?
0 1
null None
Answer : Correct Option is : (d)
update() setdefault()
copy() join()
Answer : Correct Option is : (a)
114)Which of the following methods can be used to delete element from a dictionary?
pop() del
popitem() all of these
Answer : Correct Option is : (d)
115)Which of the methods of a dictionary will raise an error if the key is not there in the
dictionary
del pop()
popitem() all of these
Answer : Correct Option is : (d)
116)Which of the following statements is correct with respect to the given code?
d={'x' : 10, 'y' : 20}
a dictionary 'd' is created 'x' and 'y' are two keys of the dictionary
10 and 20 are two values of the dictionary all of these
Answer : Correct Option is : (d)
False True
Error None
Answer : Correct Option is : (b)
Error None
False True
Answer : Correct Option is : (c)
integer string
mutable immutable
Answer : Correct Option is : (d)
apple 10
Error None
Answer : Correct Option is : (c)