Python MCQ Miscellaneous | Set 1

Python MCQ Miscellaneous Set 1 with answers and explanations for placement tests and job interviews. These solved Python MCQ Miscellaneous Set 1 are useful for the campus placement for all freshers including Engineering Students, MCA students, Computer and IT Engineers, etc.

Our Python MCQ Miscellaneous Set 1 focuses on all areas of Python and its concept. We will regularly update the quiz and most interesting thing is that questions come in a random sequence. So every time you will feel new questions.

We have already published a blog post that contains short questions on Python If you want you can also see this blog post “Python interview questions“.

 

There are several Python courses that you may have come across during your search for learning Python. Our team of experts has carefully analyzed some Python courses for you. You can check the courses, Trial of some courses is free.

 

Guideline of Python MCQ Miscellaneous Set 1:

This Python MCQ Miscellaneous Set 1 is intended for checking your Python knowledge. It takes 1 hour 40 minutes to pass the Python Quiz. If you don’t finish the Python Miscellaneous MCQ within the mentioned time, all the unanswered questions will count as wrong. You can miss the questions by clicking the “Next” button and return to the previous questions by the “Previous” button. Every unanswered question will count as wrong. MCQ on Python has features of randomization which feel you a new question set at every attempt.

In this Python MCQ Miscellaneous Set 1, we have also implemented a feature that not allowed the user to see the next question or finish the quiz without attempting the current Python MCQ.

You have 1 hours 40 minutes to take the Python MCQs

Your time has been Over.


Python MCQ

Python MCQ

Python MCQ: Python Multiple Choice Questions and Answers

1 / 144

What happens when you use the build-in function any() on a list?

2 / 144

What is the correct syntax for creating a variable that is bound to a set?

3 / 144

What is the correct way to run all the doctests in a given file from the command line?

4 / 144

Why would you use a virtual environment?

5 / 144

What is key difference between a set and a list?

6 / 144

What is the output of the following Python Programs?

L = [1, 3, 5, 7, 9]
print(L.pop(-3), end = ' ')
print(L.remove(L[0]), end = ' ')
print(L)

 

7 / 144

What is meant by the phrase "space complexity"?

8 / 144

What is the proper way to define a function?

9 / 144

What statement about static methods is true?

10 / 144

What is runtime complexity of the list's built-in .append() method?

11 / 144

What is the output of the following Python Programs?

a = 2
b = '3.77'
c = -8
str1 = '{0:.4f} {0:3d} {2} {1}'.format(a, b, c)
print(str1)

 

12 / 144

What is the output of the following Python Programs?

check1 = ['Learn', 'Quiz', 'Practice']
check2 = check1
check3 = check1[:]

check2[0] = 'Aticleworld'
check3[1] = 'Mcq'

count = 0
for c in (check1, check2, check3):
  if c[0] == 'Aticleworld':
    count += 1
  if c[1] == 'Mcq':
    count += 10

print (count)

 

13 / 144

What is the output of the following Python Programs?

dictionary1 = {'Amazon' : 1,
      'Facebook' : 2,
      'Microsoft' : 3
      }
dictionary2 = {'Atic' : 1,
      'Microsoft' : 2,
      'Youtube' : 3
      }
dictionary1.update(dictionary2);
for key, values in dictionary1.items():
  print(key, values)

 

14 / 144

Review the code below. What is the correct syntax for changing the price to 1.5?

fruit_info = {
'fruit': 'apple',
'count': 2,
'price': 3.5
}

 

15 / 144

What is the output?

count = 1

def test():

  global count

  for i in (1, 2, 3):
    count += 1

test()

print (count)

 

16 / 144

What is the output of the following Python Programs?

dictionary = {}
dictionary[1] = 1
dictionary['1'] = 2
dictionary[1] += 1

sum = 0
for k in dictionary:
  sum += dictionary[k]

print (sum)

 

17 / 144

What is the output of the following Python Programs?

list = ['a', 'b', 'c', 'd', 'e']
print (list[10:])

 

18 / 144

What is the output of the following Python Programs?

list = ['a', 'b', 'c']*-3
print (list)

 

19 / 144

What is the output of the following Python Programs?

D = {1 : {'A' : {1 : "A"}, 2 : "B"}, 3 :"C", 'B' : "D", "D": 'E'}
print(D[D[D[1][2]]], end = " ")
print(D[D[1]["A"][2]])

 

20 / 144

What is the output of the following Python Programs?

True = False
while True:
  print(True)
  break

 

21 / 144

What is a lambda function ?

22 / 144

Why is it considered good practice to open a file from within a Python script by using the with keyword?

23 / 144

If you don't explicitly return a value from a function, what happens?

24 / 144

What are attributes?

25 / 144

 

D = {1 : [1, 2, 3], 2: (4, 6, 8)}
D[1].append(4)
print(D[1], end = " ")
L = [D[2]]
L.append(10)
D[2] = tuple(L)
print(D[2])

 

26 / 144

What is the runtime complexity of searching for an item in a binary search tree?

27 / 144

What is the runtime of accessing a value in a dictionary by using its key?

28 / 144

What is the output of the following Python Programs?

class A(object):
  val = 1

class B(A):
  pass

class C(A):
  pass

print (A.val, B.val, C.val)
B.val = 2
print (A.val, B.val, C.val)
A.val = 3
print (A.val, B.val, C.val)

 

29 / 144

What is the output of the following program?

from math import *
a = 2.13
b = 3.7777
c = -3.12
print(int(a), floor(b), ceil(c), fabs(c))

 

30 / 144

What is the output of the following Python Programs?

L1 = [1, 1.33, 'ATIC', 0, 'NO', None, 'G', True]
val1, val2 = 0, ''
for x in L1:
  if(type(x) == int or type(x) == float):
    val1 += x
  elif(type(x) == str):
    val2 += x
  else:
    break
print(val1, val2)

 

31 / 144

What is the output of the following Python Programs?

def addToList(listcontainer):
  listcontainer += [10]

mylistContainer = [10, 20, 30, 40]
addToList(mylistContainer)
print (len(mylistContainer))

 

32 / 144

What is the output of the following Python Programs?

def test():
  "I love Aticleworld.com"
  return 1

print (test.__doc__[17:21])

 

33 / 144

What does a class's init() method do?

34 / 144

What is the output of the following Python Programs?

set1 = {1, 2, 3}
set2 = set1.add(4)
print(set2)

 

35 / 144

What is the output of the following program?

List = [True, 50, 10]
List.insert(2, 5)
print(List, "Sum is: ", sum(List))

 

36 / 144

What data structure does a binary tree degenerate to if it isn't balanced properly?

37 / 144

What symbol(s) do you use to assess equality between two elements?

38 / 144

What is the purpose of the self keyword when defining or calling methods on an instance of an object?

39 / 144

Which statement does NOT describe the object-oriented programming concept of encapsulation?

40 / 144

What is the output of the following Python Programs?

L1 = [1, 2, 3, 4]
L2 = L1
L3 = L1.copy()
L4 = L3
L1[0] = [5]
print(L1, L2, L3, L4)

 

41 / 144

What happens when you use the built-in function all() on a list?

42 / 144

What is an abstract class?

43 / 144

What is the output of the following Python Programs?

values = [1, 2, 3, 4]
numbers = set(values)

def checknums(num):
  if num in numbers:
    return True
  else:
    return False

for i in filter(checknums, values):
  print (i)

 

44 / 144

What is a key difference between a set and a list?

45 / 144

What is the primary difference between lists and tuples?

46 / 144

What does calling namedtuple on a collection type return?

47 / 144

What is the output of the following Python Programs?

list1 = [1, 2, 3, 4, 5]
list2 = list1

list2[0] = 0;

print ("list1= : ", list1)

 

48 / 144

What is the output of the following Python Programs?

list1 = range(100, 110) 

print ("index of element 105 is : ", list1.index(105))

 

49 / 144

What statement about a class methods is true?

50 / 144

What is the correct syntax for defining a class called Game?

51 / 144

What is the output of the following Python Programs?

value = [1, 2, 3, 4, 5]
try:
  value = value[5]/0
except (IndexError, ZeroDivisionError):
  print('Aticleworld ', end = '')
else:
  print('GFG ', end = '')
finally:
  print('Atic ', end = '')

 

52 / 144

 

tuple = {}
tuple[(1,2,4)] = 8
tuple[(4,2,1)] = 10
tuple[(1,2)] = 12
_sum = 0
for k in tuple:
  _sum += tuple[k]
print(len(tuple) + _sum)

 

53 / 144

What is the output of the following Python Programs?

D = dict()
for i in range (3):
  for j in range(2):
    D[i] = j
print(D)

 

54 / 144

What is the correct syntax for creating a variable that is bound to a dictionary?

55 / 144

 

tuple1 = (1, 2, 4, 3)
tuple2 = (1, 2, 3, 4)
print(tuple1 < tuple2)

 

56 / 144

What is the purpose of the pass statement in Python?

57 / 144

What is the output of the following Python Programs?

dictionary = {1:'1', 2:'2', 3:'3'}
del dictionary[1]
dictionary[1] = '10'
del dictionary[2]
print (len(dictionary))

 

58 / 144

What is an instance method?

59 / 144

What is the output of the following Python Programs?

print(bool('False'))
print(bool())

 

60 / 144

What is the output of the following Python Programs?

value = [1, 2, 3, 4]
data = 0
try:
  data = value[4]
except IndexError:
  print('GFG', end = '')
except:
  print('Aticleworld ', end = '')

 

 

61 / 144

What is the output of the following Python Programs?

D = {1 : 1, 2 : '2', '1' : 1, '2' : 3}
D['1'] = 2
print(D[D[D[str(D[1])]]])

 

62 / 144

Why would you use a decorator?

63 / 144

What is the output of the following Python Programs?

counter = {}

def addToCounter(country):
  if country in counter:
    counter[country] += 1
  else:
    counter[country] = 1

addToCounter('Aticleworld')
addToCounter('Apporv')
addToCounter('Mysuperblist')

print (len(counter))

 

64 / 144

What is the output of the following Python Programs?

set1 = {1, 2, 3}
set2 = set1.copy()
set2.add(4)
print(set1)

 

65 / 144

What value would be returned by this check for equality?

5 != 6

 

66 / 144

What is the output of the following Python Programs?

import re
p = re.compile('\d+')
print(p.findall("I met him once at 11 A.M. on 4th July 1886"), end = " ")
p = re.compile('\d')
print(p.findall("I went to him at 11 A.M."))

 

67 / 144

What built-in list method would you use to remove items from a list?

68 / 144

Which statement accurately describes how items are added to and remnoved from a stack?

69 / 144

Suppose a Game class inherits from two parent classes: BoardGame and LogicGame. Which statement is true about the methods of an object instantiated from the Game class?

70 / 144

What is the output of the following Python Programs?

for i in [1, 2, 3, 4][::-1]:
  print (i)

 

71 / 144

Which of these is NOT a characteristic of namedtuples?

72 / 144

What is the output of the following Python Programs?

a = "Aticleworld"

b = 13

print (a + b)

 

73 / 144

Why would you use mixin?

74 / 144

What is one of the most common use of Python's sys library?

75 / 144

What is the output of the following Python Programs?

mylist = ['Aticle', 'World']
for i in mylist:
  i.upper()
print(mylist)

 

76 / 144

Which collection type is used to associate values with unique keys?

77 / 144

What is the output of the following Python Programs?

temp = 'Aticleworld 2016'
data = [x for x in (int(x) for x in temp if x.isdigit()) if x%2 == 0]
print(data)

 

78 / 144

What is the output of the following Python Programs?

x = ['ab', 'cd']
for i in x:
  i.upper()
print(x)

 

79 / 144

What is the output of the following Python Programs?

L = list('123456')
L[0] = L[5] = 0
L[3] = L[-2]
print(L)

 

80 / 144

What is the output of the following Python Programs?

i = 1
while True:
  if i % 0O7 == 0:
    break
  print(i)
  i += 1

 

81 / 144

What is the output of the following Python Programs?

data = 50
try:
  data = data/0
except ZeroDivisionError:
  print('Cannot divide by 0 ', end = '')
else:
  print('Division successful ', end = '')

try:
  data = data/5
except:
  print('Inside except block ', end = '')
else:
  print('GFG', end = '')

 

82 / 144

 

my_string = 'Aticleworld'
for i in range(len(my_string)):
  my_string[i].upper()
print (my_string)

 

83 / 144

When does a for loop stop iterating?

84 / 144

What built-in Python data type is commonly used to represent a queue?

85 / 144

What would happen if you did not alter the state of the element that an algorithm is operating on recursively?

86 / 144

What is the output of the following Python Programs?

my_string = "World"
i = "i"
while i in my_string:
  print(i, end =" ")

 

87 / 144

What is the output?

a = 4.5
b = 2
print (a//b)

 

88 / 144

What is a base case in a recursive function?

89 / 144

What is the correct syntax for defining a class called "Game", if it inherits from a parent class called "LogicGame"?

90 / 144

What is the output of the following Python Programs?

tuple=("Check")*3
print(tuple)

 

91 / 144

What is the proper way to write a list comprehension that represents all the keys in this dictionary?

fruits = {'Apples': 5, 'Oranges': 3, 'Bananas': 4}

 

92 / 144

What would this expression return?

college_years = ['Freshman', 'Sophomore', 'Junior', 'Senior']
return list(enumerate(college_years, 2019))

 

93 / 144

What is the output of the following Python Programs?

sets = {3, 4, 5}
sets.update([1, 2, 3])
print(sets)

 

 

94 / 144

What is the output of the following Python Programs?

dictionary1 = {'Atic' : 1,
      'World' : 2,
      'Superb' : 3
      }
print(dictionary1['World']);

 

95 / 144

What is the output of the following Python Programs?

class Acc:
  def __init__(self, id):
    self.id = id
    id = 555

acc = Acc(111)
print (acc.id)

 

96 / 144

What is the output of the following Python Programs?

print ('\x25\x26')

 

97 / 144

What is the algorithmic paradigm of quick sort?

98 / 144

According to the PEP 8 coding style guidelines, how should constant values be named in Python?

99 / 144

What built-in Python data type is commonly used to represent a stack?

100 / 144

Assuming the node is in a singly linked list, what is the runtime complexity of searching for a specific node within a singly linked list?

101 / 144

What is the output of the following Python Programs?

list = [1, 2, 3, None, (1, 2, 3, 4, 5), ['Aticleworld', 'test', 'Atic']]
print (len(list))

 

102 / 144

What is the output of the following Python Programs?

i = 0
while i < 3:
  print(i)
  i += 1
else:
  print(0)

 

103 / 144

What is the purpose of an if/else statement?

104 / 144

Which statement about static method is true?

105 / 144

What is the output of the following Python Programs?

temp = ['Love', 'Aticle', 'World']
arr = [i[0].upper() for i in temp]
print(arr)

 

106 / 144

What is the output?

a = True
b = False
c = False

if not a or b:
  print (1)
elif not a or not b and c:
  print (2)
elif not a or b or not b and a:
  print (3)
else:
  print (4)

 

107 / 144

When would you use a for loop ?

108 / 144

. Which statement about the class methods is true?

109 / 144

What is the output of the following Python Programs?

set1 = {1, 2, 3}
set2 = {4, 5, 6}
print(len(set1 + set2))

 

110 / 144

What is the term to describe this code?

count, fruit, price = (2, 'apple', 3.5)

 

111 / 144

What is the output of the following Python Programs?

List =[0, 5, 2, 0, 'Atic', '', []]
print(list(filter(bool, List)))

 

112 / 144

What is the output of the following Python Programs?

x = 123
for i in x:
  print(i)

 

113 / 144

What is the correct syntax for instantiating a new object of the type Game?

114 / 144

What is the output of the following Python Programs?

import sys
L1 = tuple()
print(sys.getsizeof(L1), end = " ")
L1 = (1, 2)
print(sys.getsizeof(L1), end = " ")
L1 = (1, 3, (4, 5))
print(sys.getsizeof(L1), end = " ")
L1 = (1, 2, 3, 4, 5, [3, 4], 'p', '8', 9.777, (1, 3))
print(sys.getsizeof(L1))

 

115 / 144

 Describe the functionality of a deque.

116 / 144

What is the output?

r = lambda q: q * 2
s = lambda q: q * 3
x = 2
x = r(x)
x = s(x)
x = r(x)
print (x)

 

117 / 144

What is the output of the following Python Programs?

D = dict()
for x in enumerate(range(2)):
  D[x[0]] = x[1]
  D[x[1]+7] = x[0]
print(D)

 

118 / 144

What is the runtime complexity of adding an item to a stack and removing an item from a stack?

119 / 144

What is the output of the following Python Programs?

d1 = {"john":40, "peter":45}
d2 = {"john":466, "peter":45}
print (d1 > d2)

 

120 / 144

What is the term used to describe items that may be passed into a function?

121 / 144

What is the output of the following Python Programs?

data = [2, 3, 9]
temp = [[x for x in[data]] for x in range(3)]
print (temp)

 

122 / 144

What is the output of the following Python Programs?

Aticleworld = [1, 2, 3, 4]

# List will look like as [1,2,3,4,[5,6,7,8]]
Aticleworld.append([5,6,7,8])
print(len(Aticleworld))


print(Aticleworld)

 

123 / 144

What is the output of the following Python Programs?

L1 = []
L1.append([1, [2, 3], 4])
L1.extend([7, 8, 9])
print(L1[0][1][1] + L1[2])

 

124 / 144

Which of the following is TRUE About how numeric data would be organised in a binary Search tree?

125 / 144

What is the output of the following Python Programs?

tuple = (1, 2, 3, 4)
tuple.append( (5, 6, 7) )
print(len(my_tuple))

 

126 / 144

What does the built-in map() function do?

127 / 144

What is the purpose of the "self" keyword when defining or calling instance methods?

128 / 144

What is the output of the following Python Programs?

def REVERSE(L):
  L.reverse()
  return(L)
def YKNJS(L):
  List = []
  List.extend(REVERSE(L))
  print(List)

L = [1, 3.1, 5.31, 7.531]
YKNJS(L)

 

129 / 144

What is the output of the following Python Programs?

nameList = ['Aml', 'Apporv', 'kumar', 'pritosh']

pos = nameList.index("Aticleworld")

print (pos * 5)

 

130 / 144

What is the output?

a = True
b = False
c = False

if a or b and c:
  print ("Aticleworld")
else:
  print (".com")

 

131 / 144

What is the definition of abstraction as applied to object-oriented Python?

132 / 144

What is the algorithmic paradigm of quick sort?

133 / 144

What is the output of the following Python Programs?

print(not(4>3))
print(not(5&5))

 

134 / 144

What does calling namedtuple on a collection type return?

135 / 144

What would this expression return? How does defaultdict work?

136 / 144

What is the output of the following Python Programs?

my_tuple = (6, 9, 0, 0)
my_tuple1 = (5, 2, 3, 4)
print (my_tuple > my_tuple1)

 

137 / 144

What is the output of the following Python Programs?

for i in range(2):
  print (i)

for i in range(4,6):
  print (i)

 

138 / 144

What is the output of the following Python Programs?

line = "What will have so will"
L = line.split('a')
for i in L:
  print(i, end=' ')

 

139 / 144

What is the output of the following Python Programs?

sets = {1, 2, 3, 4, 4}
print(sets)

 

140 / 144

What does it mean for a function to have linear runtime?

141 / 144

What is the output of the following Python Programs?

nameList = ['Harsh', 'Pratik', 'Bob', 'Dhruv']

print (nameList[1][-1])

 

142 / 144

What is the output of the following Python Programs?

data = [x for x in range(5)]
temp = [x for x in range(7) if x in data and x%2==0]
print(temp)

 

143 / 144

What is the output of the following Python Programs?

T = (1, 2, 3, 4, 5, 6, 7, 8)
print(T[T.index(5)], end = " ")
print(T[T[T[6]-3]-6])

 

144 / 144

What is the output of the following Python Programs?

class Test:
  def __init__(self, id):
    self.id = id

manager = Test(100)

manager.__dict__['life'] = 49

print (manager.life + len(manager.__dict__))

 

Your score is

The average score is 0%

0%

Recommended Articles for you: