Answer Key
|
1. c |
2. d |
3. a |
4.c |
5. a |
6. d |
7. a |
8. a |
9. b |
10. b |
|
11. b |
12.a |
13. c |
14. d |
15. a |
16. c |
17. b |
18. a |
19. b |
20.c |
|
21. b |
22. b |
23. a |
24. d |
25. c |
26. d |
27. b |
28. c |
29. d |
30.c |
|
31. a |
32. b |
33. c |
34. b |
35. a |
36. d |
37. b |
38. c |
39. b |
40. a |
|
41. d |
42. a |
43. c |
44. b |
45. c |
46. c |
47. b |
48. d |
49. c |
50. d |
|
51. c |
52. a |
53. d |
54. b |
55. c |
56. d |
57. c |
58. a |
59. b |
60. c |
|
61.a |
62. c |
63. a |
64. d |
65. d |
66. b |
67. a |
68. a |
69. d |
70. a |
|
71. b |
72. b |
73. b |
74. b |
75. a |
76. b |
77. a |
78. c |
79. a |
80. d |
|
81. d |
82. d |
83. a |
84. a |
85. a |
86. d |
87. b |
88. a |
89. a |
90. d |
|
91. c |
92. c |
93. a |
94. c |
95. a |
96. b |
97. c |
98. c |
99. a |
100. d |
Python M3-R5 Model Paper
2022
1. Who developed Python
Programming Language?
a) Wick van Rossum
b) Rasmus Lerdorf
c) Guido van Rossum
d) Niene Stom
2. Which type of
Programming does Python support?
a) object-oriented
programming
b) structured programming
c) functional programming
d) all of the mentioned
3. Is Python case
sensitive when dealing with identifiers?
a) no
b) yes
c) machine dependent
d) none of the mentioned
4. Which of the
following is the correct extension of the Python file?
a) .python
b) .pl
c) .py
d) .p
5. Is Python code compiled or interpreted?
a) Python code is both
compiled and interpreted
b) Python code is neither compiled nor interpreted
c) Python code is only compiled
d) Python code is only interpreted
6. All keywords in Python are in _________
a) Capitalized
b) lower case
c) UPPER CASE
d) None of the mentioned
7. What will be the
value of the following Python expression?
4 + 3 % 5
a) 7
b) 2
c) 4
d) 1
8. 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
9. Which keyword is
used for function in Python language?
a) Function
b) Def
c) Fun
d) Define
10. Which of the
following character is used to give single-line comments in Python?
a) //
b) #
c) !
d) /*
11. 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 the mentioned
12. Which of the
following functions can help us to find the version of python that we are
currently working on?
a) sys.version(1)
b) sys.version(0)
c) sys.version()
d) sys.version
13. Python supports
the creation of anonymous functions at runtime, using a construct called
__________
a) pi
b) anonymous
c) lambda
d) none of the mentioned
14. 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
15. What will be the
output of the following Python code snippet if x=1?
x<<2
a) 4
b) 2
c) 1
d) 8
16. What does pip stand for python?
a) unlimited length
b) all private members must have leading and trailing underscores
c) Preferred Installer Program
d) none of the mentioned
17. 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
18. 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
19. Which of the
following is the truncation division operator in Python?
a) |
b) //
c) /
d) %
20. What will be the
output of the following Python code?
l=[1, 0, 2, 0, 'hello', '', []]
list(filter(bool, l))
a) [1, 0, 2, ‘hello’,
”, []]
b) Error
c) [1, 2, ‘hello’]
d) [1, 0, 2, 0, ‘hello’, ”, []]
21. Which of the
following functions is a built-in function in python?
a) factorial()
b) print()
c) seed()
d) sqrt()
22. 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
23. The following
python program can work with ____ parameters.
def f(x):
def f1(*args, **kwargs):
print("Sanfoundry")
return x(*args, **kwargs)
return f1
a) any number of
b) 0
c) 1
d) 2
24. What will be the
output of the following Python function?
min(max(False,-3,-4), 2,7)
a) -4
b) -3
c) 2
d) False
25. Which of the
following is not a core data type in Python programming?
a) Tuples
b) Lists
c) Class
d) Dictionary
26. 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
27. 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
28. What will be the
output of the following Python function?
len(["hello",2, 4, 6])
a) Error
b) 6
c) 4
d) 3
29. 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) error
d) A B C D
30. 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
31. 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
32. What will be the
output of the following Python statement?
>>>"a"+"bc"
a) bc
b) abc
c) a
d) bca
33. Which function is
called when the following Python program is executed?
f = foo()
format(f)
a) str()
b) format()
c) __str__()
d) __format__()
34. Which one of the
following is not a keyword in Python language?
a) pass
b) eval
c) assert
d) nonlocal
35. What will be the
output of the following Python code?
1.
class tester:
2.
def __init__(self, id):
3.
self.id = str(id)
4.
id="224"
5.
6.
>>>temp = tester(12)
7.
>>>print(temp.id)
a) 12
b) 224
c) None
d) Error
36. What will be the
output of the following Python program?
def foo(x):
x[0] = ['def']
x[1] = ['abc']
return id(x)
q = ['abc', 'def']
print(id(q) == foo(q))
a) Error
b) None
c) False
d) True
37. Which module in
the python standard library parses options received from the command line?
a) getarg
b) getopt
c) main
d) os
38. What will be the
output of the following Python program?
z=set('abc')
z.add('san')
z.update(set(['p', 'q']))
z
a) {‘a’, ‘c’, ‘c’,
‘p’, ‘q’, ‘s’, ‘a’, ‘n’}
b) {‘abc’, ‘p’, ‘q’, ‘san’}
c) {‘a’, ‘b’, ‘c’, ‘p’, ‘q’, ‘san’}
d) {‘a’, ‘b’, ‘c’, [‘p’, ‘q’], ‘san}
39. What arithmetic
operators cannot be used with strings in Python?
a) *
b) –
c) +
d) All of the mentioned
40. What will be the
output of the following Python code?
print("abc. DEF".capitalize())
a) Abc. def
b) abc. def
c) Abc. Def
d) ABC. DEF
41. Which of the
following statements is used to create an empty set in Python?
a) ( )
b) [ ]
c) { }
d) set()
42. What will be the
value of ‘result’ in following Python program?
list1 = [1,2,3,4]
list2 = [2,4,5,6]
list3 = [2,6,7,8]
result = list()
result.extend(i for i in list1 if i not in (list2+list3) and i not in result)
result.extend(i for i in list2 if i not in (list1+list3) and i not in result)
result.extend(i for i in list3 if i not in (list1+list2) and i not in result)
a) [1, 3, 5, 7, 8]
b) [1, 7, 8]
c) [1, 2, 4, 7, 8]
d) error
43. 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)
44. What will be the
output of the following Python code?
print('*', "abcde".center(6), '*', sep='')
a) * abcde *
b) *abcde *
c) * abcde*
d) * abcde *
45. What will be the
output of the following Python code?
1.
>>>list1 = [1, 3]
2.
>>>list2 = list1
3.
>>>list1[0] = 4
4.
>>>print(list2)
a) [1, 4]
b) [1, 3, 4]
c) [4, 3]
d) [1, 3]
46. 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
47. Which of the
following Python statements will result in the output: 6?
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
a) A[2][1]
b) A[1][2]
c) A[3][2]
d) A[2][3]
48. 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
49. 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
50. 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
51. What are the two
main types of functions in Python?
a) System function
b) Custom function
c) Built-in function & User defined function
d) User function
52. What will be the
output of the following Python program?
1.
def addItem(listParam):
2.
listParam += [1]
3.
4.
mylist = [1, 2, 3, 4]
5.
addItem(mylist)
6.
print(len(mylist))
a) 5
b) 8
c) 2
d) 1
53. Which of the
following is a Python tuple?
a) {1, 2, 3}
b) {}
c) [1, 2, 3]
d) (1, 2, 3)
54. 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
55. What will be the
output of the following Python expression?
round(4.576)
a) 4
b) 4.6
c) 5
d) 4.5
56. 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
57. 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
58. What is output of print(math.pow(3,
2))?
a) 9.0
b) None
c) 9
d) None of the mentioned
59. 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
60. What will be the
output of the following Python code?
x = [[0], [1]]
print((' '.join(list(map(str, x))),))
a) 01
b) [0] [1]
c) (’01’)
d) (‘[0] [1]’,)
61. 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
62. 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
63. Is Python case
sensitive when dealing with identifiers?
a) yes
b) no
c) machine dependent
d) none of the mentioned
64. What is the
maximum possible length of an identifier?
a) 31 characters
b) 63 characters
c) 79 characters
d) none of the mentioned
65. Which of the
following is invalid?
a) _a = 1
b) __a = 1
c) __str__ = 1
d) none of the mentioned
66. Which of the following is an invalid variable?
a) my_string_1
b) 1st_string
c) foo
d) _
67. 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
68. Which of the
following is not a keyword?
a) eval
b) assert
c) nonlocal
d) pass
69. All keywords in
Python are in _________
a) lower case
b) UPPER CASE
c) Capitalized
d) None of the mentioned
70. 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
71. 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
72. Which of the
following cannot be a variable?
a) __init__
b) in
c) it
d) on
73. Which is the
correct operator for power(xy)?
a) X^y
b) X**y
c) X^^y
d) None of the mentioned
74. Which one of these
is floor division?
a) /
b) //
c) %
d) None of the mentioned
75. 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
76. What is the answer to this expression, 22 % 3 is?
a) 7
b) 1
c) 0
d) 5
77. 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
78. What is the output
of this expression, 3*1**3?
a) 27
b) 9
c) 3
d) 1
79. 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
80. Which one of the
following has the highest precedence in the expression?
a) Exponential
b) Addition
c) Multiplication
d) Parentheses
81. Which of these in
not a core data type?
a) Lists
b) Dictionary
c) Tuples
d) Class
82. 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
83. What will be the output of the
following Python code?
1.
>>>str="hello"
2.
>>>str[:2]
3. >>>
a) he
b) lo
c) olleh
d) hello
84. 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)
85. What is the return
type of function id?
a) int
b) float
c) bool
d) dict
86. In python we do
not specify types, it is directly interpreted by the compiler, so consider the
following operation to be performed.
>>>x = 13 ? 2
objective is to make
sure x has a integer value, select all that apply (python 3.xx)
a) x = 13 // 2
b) x = int(13 / 2)
c) x = 13 % 2
d) All of the mentioned
87. What error occurs
when you execute the following Python code snippet?
apple =
mango
a) SyntaxError
b) NameError
c) ValueError
d) TypeError
88. What will be the
output of the following Python code snippet?
1.
def example(a):
2.
a = a + '2'
3.
a = a*2
4.
return a
5.
>>>example("hello")
a) indentation Error
b) cannot perform mathematical operation on strings
c) hello2
d) hello2hello2
89. What data type is
the object below?
L = [1, 23,
'hello', 1]
a) list
b) dictionary
c) array
d) tuple
90. 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
91. Which of the
following results in a SyntaxError?
a) ‘”Once upon a time…”, she said.’
b) “He said, ‘Yes!'”
c) ‘3\’
d) ”’That’s okay”’
92. The following is
displayed by a print function call. Select all of the function calls that
result in this output.
1.
tom
2.
dick
3.
harry
a)
print('''tom
\ndick
\nharry''')
b)
print(”’tomdickharry”’)
c) print(‘tom\ndick\nharry’)
d)
print('tom
dick
harry')
93. What is the
average value of the following Python code snippet?
1.
>>>grade1 = 80
2.
>>>grade2 = 90
3.
>>>average = (grade1 + grade2) / 2
a) 85.0
b) 85.1
c) 95.0
d) 95.1
94. 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’)
95. What is the return
value of trunc()?
a) int
b) bool
c) float
d) None
96. What is the output
of print 0.1 + 0.2 == 0.3?
a) True
b) False
c) Machine dependent
d) Error
97. Which of the
following is not a complex number?
a) k = 2 + 3j
b) k = complex(2, 3)
c) k = 2 + 3l
d) k = 2 + 3J
98. What is the type
of inf?
a) Boolean
b) Integer
c) Float
d) Complex
99. What does ~4
evaluate to?
a) -5
b) -4
c) -3
d) +3
100.Which of the
following is incorrect?
a) x = 0b101
b) x
= 0x4f5
c) x
= 19023
d) x
= 03964
Post a Comment