OLevel M3-R5 Top 100 MCQs

Python M3 R5 Top 100 MCQs For July 2023 Exam

Hello Guys! In this Blog You will learn OLevel M3-R5 Top 100 MCQs For July 2023 Exam. So must check out the full blog and also comment..

1. Which type of programming does Python support?
a) Object-oriented programming b) structure programming
c) functional programming d) all of the mentioned
Ans. d

2. Is Python case sensitive when dealing with identifiers?
a) no b) yes c) Machine dependent d) None of the mentioned
Ans. b




3. All keywords in Python are in ________
a) Capitalized b) lower case
c) UPPER CASE d) None of the mentioned
Ans. d

4. What will be the value of the following Python expression?
4 + 3 % 5
a) 7
b) 2
c) 4
d) 1
Ans. a

5. Which of the following is used to define a block of code in Python language?
a) Indentation
b) Key
c) Brackets
d) All of the mentioned
Ans. a

6. What will be the output of the following Python code?
i = 1
while True:
if i%3 == 0:
break
print(i)
i + = 1
a) 1 2 3 b) error c) 1 2 d) None of these
Ans. b

7. Python supports the creation of anonymous functions at runtime, using a construct called ____
a) pi
b) anonymous
c) lambda
d) none of the mentioned
Ans. c

8. What is the order of precedence in python?
a) Exponential, Parentheses, Multiplication, Division, Addition, Subtraction
b) Exponential, Parentheses, Division, Multiplication, Addition, Subtraction
c) Parentheses, Exponential, Multiplication, Division, Subtraction, Addition
d) Parentheses, Exponential, Multiplication, Division, Addition, Subtraction
Ans. d

9. What will be the output of the following Python code snipped if x=1 ?
X<<2
a) 4
b) 2
c) 1
d) 8
Ans. a

10. Which of the following is true for variable names in Python?
a) underscore and ampersand are the only two special characters allowed
b) unlimited length
c) all private members must have leading and trailing underscores
d) none of the mentioned
Ans. b

11. What are the values of the following Python expressions?
2**(3**2)
(2**3)**2
2**3**2
a) 512, 64, 512
b) 512, 512, 512
c) 64, 512, 64
d) 64, 64, 64
Ans. a

12. Which of the following is the truncation division operator in Python?
a) | b) // c) / d) %
Ans. b




13. Which of the following is the use of id() function in python?
a) Every object doesn’t have a unique id
b) Id returns the identity of the object
c) All of the mentioned
d) None of the mentioned
Ans. b

14. The following python program can work with ____ parameters.
def f(x):
def f1(*args, **kwargs):
print(“Heetson”)
return x(*args, **kwargs)
return f1
a) any number of b) 0 c) 1 d) 2
Ans. a

15. What will be the output of the following Python expression if x=56.236?
print(“%.2f”%x)
a) 56.236 b) 56.23
c) 56.0000 d) 56.24
Ans. d

16. Which of these is the definition for packages in Python?
a) A set of main modules
b) A folder of python modules
c) A number of files containing Python definitions and statements
d) A set of programs making use of Python modules
Ans. b

17. What will be the output of the following Python function?
len([“hello”,2, 4, 6])
a) Error
b) 6
c) 4
d) 3
Ans.4

18. What is the order of namespaces in which Python looks for an identifier?
a) Python first searches the built-in namespace, then the global namespace and finally the local namespace
b) Python first searches the built-in namespace, then the local namespace and finally the global namespace
c) Python first searches the local namespace, then the global namespace and finally the built-in namespace
d) Python first searches the global namespace, then the local namespace and finally the built-in namespace
Ans. c

19. What will be the output of the following Python code snippet?
for i in [1, 2, 3, 4][::-1]:
print (i)
a) 4 3 2 1
b) error
c) 1 2 3 4
d) none of the mentioned
Ans. a

20. What will be the output of the following Python statement?
>>>”a”+”bc”
a) bc
b) abc
c) a
d) bca
Ans. a

21. Which function is called when the following Python program is executed?
f = foo()
format(f)
a) str()
b) format()
c) __str__()
d) __format__()
Ans. c

22. Which one of the following is not a keyword in Python language?
a) pass
b) eval
c) assert
d) nonlocal
Ans. b

23. Which module in the python standard library parses options received from the command line?
a) getarg b) getopt c) main d) os
Ans. b
24. What arithmetic operators cannot be used with strings in Python?
a) * b) –
c) + d) All of the mentioned
Ans. b

25. Which of the following statements is used to create an empty set in Python?
a) ( )
b) [ ]
c) { }
d) set()
Ans. d
26. To add a new element to a list we use which Python command?
a) list1.addEnd(5)
b) list1.addLast(5)
c) list1.append(5)
d) list1.add(5)
Ans. c

27. Which one of the following is the use of function in python?
a) Functions don’t provide better modularity for your application
b) you can’t also create your own functions
c) Functions are reusable pieces of programs
d) All of the mentioned
Ans. c

28. What is the maximum possible length of an identifier in Python?
a) 79 characters
b) 31 characters
c) 63 characters
d) none of the mentioned
Ans. d (Identifiers can be of any length)



29. What will be the output of the following Python program?
i = 0
while i < 5:
print(i)
i += 1
if i == 3:
break
else:
print(0)
a) error
b) 0 1 2 0
c) 0 1 2
d) none of the mentioned
Ans. c

30. What will be the output of the following Python code?
x = ‘abcd’
for i in range(len(x)):
print(i)
a) error
b) 1 2 3 4
c) a b c d
d) 0 1 2 3
Ans. d

31. Which of the following is a Python tuple?
a) {1, 2, 3}
b) {}
c) [1, 2, 3]
d) (1, 2, 3)
And. D

32. What will be the output of the following Python code snippet?
z=set(‘abc$de’)
‘a’ in z
a) Error
b) True
c) False
d) No output
Ans. B

33. What will be the output of the following Python expression?
round(4.576)
a) 4
b) 4.6
c) 5
d) 4.5
Ans. c

34. Which of the following is a feature of Python DocString?
a) In Python all functions should have a docstring
b) Docstrings can be accessed by the __doc__ attribute on objects
c) It provides a convenient way of associating documentation with Python modules, functions, classes, and
methods
d) All of the mentioned
Ans. d

35. What will be the output of the following Python code?
print(“Hello {0[0]} and {0[1]}”.format((‘foo’, ‘bin’)))
a) Hello (‘foo’, ‘bin’) and (‘foo’, ‘bin’)
b) Error
c) Hello foo and bin
d) None of the mentioned
Ans. c

36. Which of the following is the use of id() function in python?
a) Every object in Python doesn’t have a unique id
b) In Python Id function returns the identity of the object
c) None of the mentioned
d) All of the mentioned
Ans. b

37. The process of pickling in Python includes ____________
a) conversion of a Python object hierarchy into byte stream
b) conversion of a datatable into a list
c) conversion of a byte stream into Python object hierarchy
d) conversion of a list into a datatable
Ans. a

38. What will be the output of the following Python code?
def foo():
try:
return 1
finally:
return 2
k = foo()
print(k)
a) error, there is more than one return statement in a single try-finally block
b) 3
c) 2
d) 1
Ans. c

39. Why are local variable names beginning with an underscore discouraged?
a) they are used to indicate a private variables of a class
b) they confuse the interpreter
c) they are used to indicate global variables
d) they slow down execution
Ans. a

40. Which of the following is true for variable names in Python?
a) unlimited length
b) all private members must have leading and trailing underscores
c) underscore and ampersand are the only two special characters allowed
d) none of the mentioned
Ans. a

41. Which of the following is an invalid statement?
a) abc = 1,000,000
b) a b c = 1000 2000 3000
c) a,b,c = 1000, 2000, 3000
d) a_b_c = 1,000,000
Ans. b

42. Which of the following cannot be a variable?
a) __init__ b) in c) it d) on
Ans.  in is a keyword.

43. Which is the correct operator for power(xy)?
a) X^y b) X**y
c) X^^y d) None of the mentioned
Ans. b

44. Which one of these is floor division?
a) /
b) //
c) %
d) None of the mentioned
Ans. b



45. What is the order of precedence in python?
i) Parentheses
ii) Exponential
iii) Multiplication
iv) Division
v) Addition
vi) Subtraction
a) i,ii,iii,iv,v,vi
b) ii,i,iii,iv,v,vi
c) ii,i,iv,iii,v,vi
d) i,ii,iii,iv,vi,v
Ans. a

46. Operators with the same precedence are evaluated in which manner?
a) Left to Right
b) Right to Left
c) Can’t say
d) None of the mentioned
Ans. a

47. What is the output of this expression, 3*1**3?
a) 27 b) 9 c) 3 d) 1
Ans. c

48. Which one of the following has the same precedence level?
a) Addition and Subtraction
b) Multiplication, Division and Addition
c) Multiplication, Division, Addition and Subtraction
d) Addition and Multiplication
Ans. a

49. Which one of the following has the highest precedence in the expression?
a) Exponential
b) Addition
c) Multiplication
d) Parentheses
Ans. d

50. Which of these in not a core data type?
a) Lists
b) Dictionary
c) Tuples
d) Class
Ans. d

51. 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
Ans. d

52. What will be the output of the following Python code?
a) he b) lo c) olleh d) hello
Ans. a

53. Which of the following will run without errors?
a) round(45.8)
b) round(6352.898,2,5)
c) round()
d) round(7463.123,2,1)
Ans. a

54. What error occurs when you execute the following Python code snippet?
apple = mango
a) SyntaxError
b) NameError
c) ValueError
d) TypeError
Ans. b

55. What data type is the object below?
L = [1, 23, ‘hello’, 1]
a) list
b) dictionary
c) array
d) tuple
Ans. a

56. In order to store values in terms of key and value we use what core data type.
a) list
b) tuple
c) class
d) dictionary
Ans. d

57. Select all options that print.
hello-how-are-you
a) print(‘hello’, ‘how’, ‘are’, ‘you’)
b) print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4)
c) print(‘hello-‘ + ‘how-are-you’)
d) print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)
Ans. c

58. What is the return value of trunc()?

a) int
b) bool
c) float
d) None
Ans. a

59. What is the type of inf?
a) Boolean
b) Integer
c) Float
d) Complex
Ans. c

60. What is the result of cmp(3, 1)?
a) 1
b) 0
c) True
d) False
Ans. C

61. Which of the following operators has its associativity from right to left?
a) +
b) //
c) %
d) **
Ans. d



62. What will be the value of x in the following Python expression?
x = int(43.55+2/2)
a) 43
b) 44
c) 22
d) 23
Ans. b

63. What is the value of the following expression?
2+4.00, 2**4.0
a) (6.0, 16.0)
b) (6.00, 16.00)
c) (6, 16)
d) (6.00, 16.0)
Ans. a

64. Which of the following is the truncation division operator?
a) /
b) %
c) //
d) |
Ans. c

65. What is the value of the following expression?
8/4/2, 8/(4/2)
a) (1.0, 4.0)
b) (1.0, 1.0)
c) (4.0. 1.0)
d) (4.0, 4.0)
Ans. a

66. Which among the following list of operators has the highest precedence?
+, -, **, %, /, <<, >>, |
a) <<, >>
b) **
c) |
d) %
Ans. b

67. Which of the following expressions is an example of type conversion?
a) 4.0 + float(3)
b) 5.3 + 6.3
c) 5.0 + 3
d) 3 + 7
Ans. a

68. What will be the output of the following Python expression?
bin(29)
a) ‘0b10111’
b) ‘0b11101’
c) ‘0b11111’
d) ‘0b11011’
Ans. b

69. What will be the output of the following Python expression?
int(1011)?
a) 1011
b) 11
c) 13
d) 1101
Ans. a

70. 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)
Ans. d

71. What will be the output of the following Python expression if x=15 and y=12?
x & y
a) b1101
b) 0b1101
c) 12
d) 1101
Ans. c

72. Which of the following expressions results in an error?

a) int(1011)
b) int(‘1011’,23)
c) int(1011,2)
d) int(‘1011’)
Ans. c

73. Which of the following represents the bitwise XOR operator?
a) &
b) ^
c) |
d) !
Ans. b

74. What is the value of the following Python expression?
bin(0x8)
a) ‘0bx1000’
b) 8
c) 1000
d) ‘0b1000’
Ans. d

75. The one’s complement of 110010101 is:
a) 001101010
b) 110010101
c) 001101011
d) 110010100
Ans. a

76. 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
Ans. c

77. What is the two’s complement of -44?
a) 1011011 b) 11010100 c) 11101011 d) 10110011
Ans. b

78. What will be the output of the following Python code snippet?
[‘hello’, ‘morning’][bool(”)]
a) error b) no output c) hello d) morning
Ans. c

79. What will be the output of the following Python code?
[‘f’, ‘t’][bool(‘spam’)]
a) t b) f c) No output d) Error
Answer: a



80. What will be the output of the following Python code?
class Truth:
pass
x=Truth()
bool(x)
a) pass
b) true
c) false
d) error
Ans. b

81. What will be the output of the following Python code snippet?
X=”hi”
print(“05d”%X)
a) 00000hi
b) 000hi
c) hi000
d) error
Answer: d

82. What will be the output of the following Python code snippet?
X=”san-foundry”
print(“%56s”,X)
a) 56 blank spaces before san-foundry b) 56 blank spaces before san and foundry
c) 56 blank spaces after san-foundry d) no change
Answer: a

83. The output of which of the codes shown below will be: “There are 4 blue birds.”?
a) ‘There are %g %d birds.’ %4 %blue b) ‘There are %d %s birds.’ %(4, blue)
c) ‘There are %s %d birds.’ %*4, blue+ d) ‘There are %d %s birds.’ 4, blue
Ans. b

84. The formatting method {1:<10} represents the ___________ positional argument, _________ justified
in a 10 character wide field.
a) first, right
b) second, left
c) first, left
d) second, right
Ans. b

85. What will be the output of the following Python code?
‘{a}{b}{a}’.format(a=’hello’, b=’world’)
a) ‘hello world’
b) ‘hello’ ‘world’ ‘hello’
c) ‘helloworldhello’
d) ‘hello’ ‘hello’ ‘world’
Ans. c

86. In the following Python code, which function is the decorator?
def mk(x):
def mk1():
print(“Decorated”)
x()
return mk1
def mk2():
print(“Ordinary”)
p = mk(mk2)
p()
a) p() b) mk() c) mk1() d) mk2()
Ans. b

87. The ______ symbol along with the name of the decorator function can be placed above the definition
of the function to be decorated works as an alternate way for decorating a function.
a) #
b) $
c) @
d) &
Ans. c

88. The following python code can work with ____ parameters.
def f(x):
def f1(*args, **kwargs):
print(“Sanfoundry”)
return x(*args, **kwargs)
return f1
a) 2
b) 1
c) any number of
d) 0
Ans. c

89. Identify the decorator in the snippet of code shown below.
def sf():
pass
sf = mk(sf)
@f
def sf():
return
a) @f
b) f
c) sf()
d) mk
Ans. d
90. What will be the output of the following Python code?
class A:
@staticmethod
def a(x):
print(x)
A.a(100)
a) Error b) Warning c) 100 d) No output
Answer: c

91. 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 these
Ans. a

92. What will be the output of the following Python code?
True = False
while True:
print(True)
break
a) True
b) False
c) None
d) none of these
Ans. d

93. What will be the output of the following Python code?
x = ‘abcd’
for i in x:
print(i.upper())
a) a b c d
b) A B C D
c) a B C D
d) error
Ans. b

94. What will be the output of the following Python code?
x = 123
for i in x:
print(i)
a) 1 2 3
b) 123
c) error
d) none of the mentioned
Ans. c




95. What will be the output of the following Python code?
d = {0, 1, 2}
for x in d:
print(x)
a) 0 1 2
b) {0, 1, 2} {0, 1, 2} {0, 1, 2}
c) error
d) none of these
Ans. a

96. What will be the output of the following Python code?
for i in range(0):
print(i)
a) 0 b) no output c) error d) none of the mentioned
Ans. b

97. What will be the output of the following Python code snippet?
x = 2
for i in range(x):
x += 1
print (x)
a) 0 1 2 3 4 …
b) 0 1
c) 3 4
d) 0 1 2 3
Answer: c

98. What will be the output of the following Python code?
for i in range(10):
if i == 5:
break
else:
print(i)
else:
print(“Here”)
a) 0 1 2 3 4 Here
b) 0 1 2 3 4 5 Here
c) 0 1 2 3 4
d) 1 2 3 4 5
Ans. c

99. 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 these
Ans. a

100. What will be the output of the following Python statement?
>>>”abcd”[2:]
a) a
b) ab
c) cd
d) dc
Answer: c

For Live Class Visit on

Thanks for Reading the blog. I hope you will understand the topic OLevel M3-R5 Top 100 MCQs For July 2023 Exam.

Check out Our more Blogs

Python list methods and List Operations

Subscribe Our Youtube Channel For Live Class

https://www.youtube.com/@olevelguruji

Leave a Comment