COMS
COMS
3. The Python code can be used on different platforms; it means that Python is a
language.
Independent Cross-platform Independent All of these
Page 1 of 52
A. Both (A) and (R) are true and (R) is the correct explanation of (A)
B. Both (A) and (R) are true but (R) is not the correct explanation of (A)
C. (A) true but (R) false (or partially true)
D. (A) false (or partially true) but (R) is true
Column A Column B
I. Open-source programming language A. Python distributions
12. Special meaningful expressions in static Python for specific functionality are called—
Identifiers Functions Keywords Literals
Page 2 of 52
13. The different parts of a Python program —
Identifiers Functions Keywords Literals
19. 123.45E-9 =
124 1234.5E-9 12345 123.45*10.9
Page 3 of 52
20. spam = "eggs" >>> print (spam*3)
What will be the output of this code?
Spamspamspam eggseggseggs "spamspamspam” spam*3
Page 4 of 52
A. Both (A) and (R) are true and (R) is the correct explanation of (A)
B. Both (A) and (R) are true but (R) is not the correct explanation of (A)
C. (A) true but (R) false (or partially true)
D. (A) false (or partially true) but (R) is true
33. Which of the following is not a legal integer type value in Python?
Decimal Octal Roman Hexadecimal
Page 5 of 52
34. Which of the following symbols is not valid for octal values?
7 8 9 Both B & C
36. Lines beginning with a certain character are ignored and not executed by the compiler—
operators operands functions comments
Page 6 of 52
41. What should be written in the blank to produce zero Division Error for (25+36)/(-8+_)
6 -8 7 8
47. To convert the value obtained through input() to integer type, use—
Floating Float Int Integer
48. To convert the value obtained through input() to a floating-point number, use—
Floating Float Int Integer
Page 7 of 52
A. \a B. \t C. [ ] D. \n
51. A B
i. @ A. Python prompt
ii. \n B. Punctuators
iii. ‘’ ‘’ C. Escape Sequence
iv. >>> D. Quotation
52, To print "Python is fun", fill in the blanks: print ("Python" + “_____+_____)
Is, fun is ” , “ fun” “is”,”fun NA
55. Which argument should be used with print () to print a text without ending a line with a
newline?
Page 8 of 52
Sep Newline End Next
58. The operator used to check whether both operands refer to the same object in memory—
In Is Id --
59. For two objects x and y, the expression x is y will be true only and only if —
Id(x)id(y) Len(x) len(y) XY All of these
60. Examples of mutable data types are— i. List ii. Dictionaries iii. Set
Correct pair below is:
(i) & (iii) (i) & (ii) (i), (ii) & (iii) (ii) & (iii)
62. A B
i. True, False A. String
Page 9 of 52
Choose the correct option
i-A, ii-B, iii-C, iv-D i-B, ii-C, iii-D, iv-A i-C, ii-A, iii-D, iv-B i-D, ii-B, iii-C, iv-A
63. Fill in the blanks to declare a variable, multiply it by 2, and print its value:
>>> num = 12;
num _____ = 2; print ___
++, num / , num *, num None of these
>>> 9 = 9 or 1==1 >>> 3==4 or 7==7 >>> 7 != 1 or 5==5 >>> 4<1 or 1>6
67. In Python, the variable that must be declared before being assigned a value:
True False Only in Functions Onl in modules
68. In Python, a variable that is assigned a value of one type and then assigned a value of a
different type. The result we get —
Warning None Error No Error
69. In Python, a variable is once assigned a value of one type and later to a different type, this
concept is known as
Mutability Static typing Dynamic typing Immutability
Page 10 of 52
70. Is it safe to use the operator directly to determine whether an object of type float is equal?
Yes No Yes, if the values are <100 Yes, if the values are >100
73. A B
i. str(x) A. Converts x to a floating point value
Page 11 of 52
76. Observe the following sentences—
i. python is the fastest language
ii. Dividing two integers yields an integer
iii. Each variable has a unique name
79. Which of the following operators has the lowest precedence in Python?
Not % And + **
81. To increase the value of x by five times using an augmented assignment operator, the
correct expression will be—
x += 5 x ^=5 x=x^…5 NA
Page 12 of 52
A. Both (A) and (R) are true and (R) is the correct explanation of (A)
B. Both (A) and (R) are true but (R) is not the correct explanation Of (A)
C. (A) true but (R) false (or partially true)
D. (A) false (or partially true) but (R) is true
84. A B
i. * A. Calculates the quotient by dividing the value on the left-hand side of the operator
by the value on the right-hand side, and usually skips the number after the decimal
point.
ii. % B. Multiplies two operands.
iii. ** C. Returns the remainder after dividing the 1st Operand by the 2nd Operand.
86. >>> print(format(56.78901, ‘3f’)) What will be the output of this code?
56.789 5.6789 0.56789 56789
Page 13 of 52
89. The result of 5 or 10 —
0 1 True False
93. Logical operator used to perform logical operations in Python program is—
i. and
ii. or
iii. not
The correct pair below is—
(i) & (iii) (ii) & (iii) (i) & (ii) All of these
95. A B
i. Unary Plus A. ++
ii. Unary minus B. -
iii. Decremental operator C. --
Iv. Incremental operator D. +
Page 14 of 52
96. (_____7*-3) + 9 = 30, fill in the missing number.
* - + /
104. Operators used to determine whether a variable is a member of a particular list, tuple, or
string are called membership operators. Examples of membership operators are —
is in not not in
Page 15 of 52
Assertion (A): To evaluate an expression of mixed type, Python performs implicit type
conversion.
Reason (R): In implicit type conversion, all operands are converted to the type of the largest
operand.
The correct option is —
A. Both (A) and (R) are true and (R) is the correct explanation of (A)
B. Both (A) and (R) are true but (R) is not the correct explanation of (A)
C. (A) true but (R) false (or partially true)
D. (A) false (or partially true) but (R) is true
106. A B
i. a >= b A. Is the value of a less than or equal to the value of b?
Page 16 of 52
110. Result of 'false' and False—
false False ‘false’ ‘False’
113. A B
i. This operator is used to set the product of the both side operands as the A. %=
value of the variable on the left side.
ii. This operator is used to subtract the right-hand operand from the B. *=
left-hand operand and set the difference as the value of the left-hand
variable.
iii. This operator is used to assign the value of the right-hand operand or C. -=
operands to the value of the left-hand variable.
iv. This operator is used to divide the left-hand operand by the right-hand D. =
operand and set the quotient as the value of the left-hand variable.
Page 17 of 52
5 6 4 0
117. B
A
i. & A. Bitwise AND logic operation between two data.
Page 18 of 52
break
1 2 3 4
Page 19 of 52
124. Note the two Assertion and Reason statements below—
A: Run-time errors occur during the execution of a program.
R: Run-time errors mainly occur due to lack of resources required for program
A. Both (A) and (R) are true and (R) is the correct explanation of (A)
B. Both (A) and (R) are true but (R) is not the correct explanation of (A)
C. (A) true but (R) false (or partially true)
D. (A) false (or partially true) but (R) is true
129. What will be the output of the three numbers of the following code?
a=5
b=-3
c=25
d=-10
a+b+c>a+c-b
str (a+b+c > a+c-b*d) == 'True'
Page 20 of 52
len(str(a+b+c > a+c - b*d)) = = len(str(bool(1)))
True, False, True True, True, False False, False, True True, True, True
True
133. From top to bottom, the order of execution of statements in construct form is known as
_____
construct.
Selection Sequence Flow Repetition
134. The ____ construct allows execution of the choose statement depending on the result of
the condition.
Selection Sequence Flow Repetition
135. ________ condition is true. A construct repeats a set of statements a specified number of
times or as long as a condition holds.
Selection Repetition Sequence Flow
Page 21 of 52
ii. A for loop is called a determinable loop
iii. A while loop is an exit-controlled loop
Page 22 of 52
Reason-(R): This empty statement does nothing
The correct option below is—
A. Both (A) and (R) are true and (R) is the correct explanation of (A)
B. Both (A) and (R) are true but (R) is not the correct explanation of (A)
C. (A) true but (R) false (or partially true)
D. (A) false (or partially true) but (R) is true
Page 23 of 52
The correct option below is—
A. Both (A) and (R) are true and (R) is the correct explanation of (A)
B. Both (A) and (R) are true but (R) is not the correct explanation of (A)
C. (A) true but (R) false (or partially true)
D. (A) false (or partially true) but (R) is true
146. A B
i. Used to check if a string starts with a specific sequence of characters. A. find ()
ii. Used to return the lowest index value of the first occurrence of the B. count ()
substring from the string.
iii. Used to find the position of a specified substring within a specified string C. startswith ()
147. A B
i. Returns a Boolean value depending on the character in the A. islower()
string and the existence of the text character.
iii. iii. Built-in function that can be used to check whether all C. Isalnum ()
characters in a given string are numeric.
iv. The string method determines whether all case-sensitive D. Isdigit ()
characters in the string are lowercase.
Page 24 of 52
148. Which of the following statements will not execute successfully?
if (1, 2): print('foo') if (1, 2): print(“foo") if (l1, 2) print('foo') B and C both
150. If the user inputs 2<ENTER>, what will the following code print?
x=float(input())
if(x==1):
print("Yes")
elif (x>=2):
print("Maybe")
else:
print ("No")
Yes No Maybe NA
Page 25 of 52
The correct pair of true statements is—
i i, ii ii NA
Page 26 of 52
Reason-(R): Python strings are stored consecutively as individual characters in contiguous
memory locations.
The correct option below is—
A. Both (A) and (R) are true and (R) is the correct explanation of (A)
B. Both (A) and (R) are true but (R) is not the correct explanation of (A)
C. (A) true but (R) false (or partially true)
D. (A) false (or partially true) but (R) is true
161. A B
i. Returns True if the given input string contains all uppercase letters. A. lstrip ()
ii. Used to check if the string contains white space characters. B. isspace()
Page 27 of 52
iii. The function is used to remove extra whitespace and specific C. strip ()
characters from the beginning and end of the strip, regardless of how
the parameter is passed.
iv. Removes leading whitespace characters from a string. D. isupper ()
162.
i. replace() A. Removes trailing whitespace characters from a string.
ii. rstrip () B. Replaces all occurrences of a specified substring in string and returns
string without changing the original string.
iii. join () C. Replaces all occurrences of a specified substring in a string and returns
string without changing the original string.
iv. replace() D. Used to concatenate an iterable element (such as a list, tuple, or set)
into a
string.
Page 28 of 52
i. If the user enters 0 for a and 0 for b, which characters will be printed?
only X Only W Only Y Only Z
ii. If the user enters 1 for a and 1 for b, which characters will be printed?
W and X X and Z X and Y W and Y
iii. If the user enters 1 for a and -1 for b, which characters will be printed?
W and X X and Y Y and Z X and Z
iv. If the user enters 1 for a and 0 for b, which characters will be printed?
W and X X and Y Y and Z X and Z
v. What characters will be printed if the user enters -I for a and -I for b?
Only W only Z Only Y Only X
Page 29 of 52
I. A function can call only one function.
II. Code recycling is one of the main reasons for using functions.
iii. Larger programs generally follow the WET principle.
Page 30 of 52
172. Note the two Assertion and Reason statements below—
Assertion-(A): String slices and substrings, although subparts of strings, are not the same.
Reason-(R): While the substring contains a continuous subpart of the string, the slice may or
may not contain a continuous subpart of the string.
The correct option below is —
A. Both (A) and (R) are true and (R) is the correct explanation of (A)
B. Both (A) and (R) are true but (R) is not the correct explanation of (A)
C. (A) true but (R) false (or partially true)
D. (A) false (or partially true) but (R) is true
Page 31 of 52
176.
i. split() A. Splits or separates
strings into strings.
ii. partition () B. A built-in string
method that allows
splitting
a string into three
parts based on a
specified separator.
iii. len() C. The Python string
method is
length of a string.
iv. title() D. The Python
function is used to
change the initial
letter of each word to
uppercase and
subsequent letters to
lowercase.
Matched colums are
i-A, ii-B, iii-C, iv-D i-B, ii-C, iii-D, iv-A i-C, ii-A, iii-D, iv-B i-D, ii-B, iii-C, iv-A
177. A B
i. A mathematical A. floor()
constant,
approximately
equal to 3.14159
ii. Built-in math B. pi ()
function that returns
the smallest integer
greater than or
equal to n.
iii. Used to C. ceil ()
calculate the
square root of a
given number.
iv. A built-in D. sqrt ()
arithmetic function
Page 32 of 52
that returns the
largest integer not
greater than n.
Matched colums are
i-A, ii-B, iii-C, iv-D i-B, ii-C, iii-D, iv-A i-C, ii-A, iii-D, iv-B i-D, ii-B, iii-C, iv-A
Page 33 of 52
i i, ii ii NA
Page 34 of 52
B. Both (A) and (R) are true but (R) is not the correct explanation of (A)
C. (A) true but (R) false (or partially true)
D. (A) false (or partially true) but (R) is true
190. A B
i. Generates a random integer within a A. The method is used to calculate the
specified range, including both lower cosine value of an angle in radians.
and upper bounds.
Page 35 of 52
191. A B
i. Used to calculate the power of a number, A. fabs()
ii. A float is used to calculate the absolute value of a number. B. radius()
iii. Python methods are used to calculate the sine value of an angle. C. pow()
iv. An angle can be converted to degrees using the method D. sin()
192. When the following code runs, how many times is the line "x = x*2" executed?
x=1
while(x<20):
x=x*2
2 5 19 4
Page 36 of 52
i. clear() removes all the elements of a dictionary, but doesn’t delete empty dictionary
ii. max(), min() works with tuples, if all elements are of same data type.
Choose the true statements:
i I, ii ii NA
Page 37 of 52
D. (A) false (or partially true) but (R) is true
201. A-The break statement can be used with all selection and iteration statements
R-Using break with if statement will not cause an error
A. Both (A) and (R) are true and (R) is the correct explanation of (A)
B. Both (A) and (R) are true but (R) is not the correct explanation of (A)
C. (A) true but (R) false (or partially true)
D. (A) false (or partially true) but (R) is true
203. A B
i. The function is used to generate a random number within the range specified A. randrange()
in its parameters.
ii. The function returns the average of the data passed in its argument. B. mean()
iii. The function can be used to calculate the median value from a C. median()
non-increasing data list.
iv. Returns the maximum number of occurrences. D. mode()
204. A B
i. Calculating the size of a Python list. A. list()
ii. The function is used to create list from iterable object. B. extend()
iii. A built-in function used to add an item to the end of a list. C. len()
iv. Used to add items from one list to the end of another list. D. append()
Page 38 of 52
Matched options are:
i-A, ii-B, iii-C, iv-D i-B, ii-C, iii-D, iv-A i-C, ii-A, iii-D, iv-B i-D, ii-B, iii-C, iv-A
205. What will be the output when the code below is executed?
strl = "Mission 999'
str2 = "999"
print(strI.isdigit(),str2.isdigit())
False True False False True False True True
208. Assertion-(A): After importing a module through the import statement, all its function
definitions, variables, constants, etc., are available to the program.
Reason-(R): imported module definitions do not become a part of the namespace of the
program imported via an import <module> statement.
A. Both (A) and (R) are true and (R) is the correct explanation of (A)
B. Both (A) and (R) are true but (R) is not the correct explanation of (A)
C. (A) true but (R) false (or partially true)
D. (A) false (or partially true) but (R) is true
Page 39 of 52
C. (A) true but (R) false (or partially true)
D. (A) false (or partially true) but (R) is true
213. A B
i. An object is inserted into a list at a specified position. A. dremove()
ii. Used to remove an element from a list of specified indices and return that B. pop()
element.
iii. Searches for a specific element from the beginning of the list and returns the C. index()
lowest index at which the element appears.
iv. Removes the first occurrence of the given item from the list. D. insert()
Page 40 of 52
Matched options are
i-A, ii-B, iii-C, iv-D i-B, ii-C, iii-D, iv-A i-C, ii-A, iii-D, iv-B i-D, ii-B, iii-C, iv-A
214. A B
i. A built-in method that reverses the order of list elements. A. sort()
ii. A built-in function that allows you to sort the elements of a list in B. min()
ascending or descending order.
iii. Returns a newly sorted or sorted list from any iterable element (eg. C. reverse()
list, tuple, string).
iv. The function finds the smallest element or value within a given D. sorted()
iterable element.
Page 41 of 52
Assertion-(A): A parameter that defaults to the function header is made optional by the function.
Reason-(R): A function call may or may not contain values for default arguments.
The correct option below is —
A. Both (A) and (R) are true and (R) is the correct explanation of (A)
B. Both (A) and (R) are true but (R) is not the correct explanation of (A)
C. (A) true but (R) false (or partially true)
D. (A) false (or partially true) but (R) is true
221. Assertion-(A): A function that declares a variable with the same name as the name of a
global variable, that global variable can’t be used as variable.
Reason-(R): function of a local variable with the same name as the global variable is hidden by
the global variable
A. Both (A) and (R) are true and (R) is the correct explanation of (A)
B. Both (A) and (R) are true but (R) is not the correct explanation of (A)
C. (A) true but (R) false (or partially true)
D. (A) false (or partially true) but (R) is true
Page 42 of 52
import random as r
print (random.randomint (1, 10)))
An error occurs 1 10 Any other random value
227. In Python, the following code will create a block compound statement —
colon Any form of indentation If the following indented statements ()
are on the same level
Page 43 of 52
230. Which statement below will terminate the entire loop and proceed to the statement after the
loop?
continue break goto pass
231. Which of the following statements will only terminate the current pass of the loop and
proceed with the iteration of the loop?
pass break continue goto
231. Which of the following statements will only terminate the current pass of the loop and
proceed with the iteration of the loop?
pass break continue goto
Page 44 of 52
239.Which below is not a valid string operator?
in + * /
240.Which Of the following functions will return the total number of characters in a string?
count() index() len() all of these
241.Which of the following functions will return the last three characters of a string s?
s[3:1 s[:3] s[-3:] s[:-3]
242. Which of the following functions will return the first three characters of a string s?
s[3:1 s[:3] s[-3:] s[:-3]
243. Which of the following functions will return the string in all uppercase letters?
upper() toupper() isupper() to-upper()
244. Which of the following string functions will replace 'K' with 'z’?
find() index() replace() split()
245. Which of the following functions will return a list containing all words in a string?
find() index() partition() split()
247. Which of the following functions removes all leading and trailing spaces from a string?
strip rstrip() Istrip ( All of these
248. Which of the following functions will throw an error if the given substring is not found?
replace () index () find () All of these
Page 45 of 52
250. If the number of arguments in the function definition and the function call do not match,
what type of error will be returned
NameError NumberError TypeError ImportError
252. What symbols for arbitrary arguments precede parameter names in function definitions?
& # % *
253. Modules are files saved with __ extension
.py mod mdl imp
254. This import statement imports all module names, except names beginning with
% $ - !
255. A .py file containing constants/ variables, classes, functions, etc., related to a particular
task and can be used in other programs, is called —
Library Module Classes Documentation
256. A collection of modules and packages that fulfil a specific type of application or requirement
is
Documentation IO Classes Library Module
257. Which of the following random module functions generates a floating-point number?
random() randint() uniform() both A&C
Page 46 of 52
261. Which of the following is not a function/ method of Python's random module?
random() randint () radfloat () randrange()
270. How to output the string "May the odds favour you" in Python?
A. print("May the odds favour you")
B. echo("May the odds favour you")
C. system.out("May the odds favour you")
D. printf("May the odds favour you")
Page 47 of 52
271. How to create a variable using Python's 22.6 value?
int a 22.6 a = 22.6 integer a 22.6 None of these
274. In python function, to avoid argument or pass in any way while calling a function, we should
use—
Keyword arguments Required Arguments Default Arguments Arbitrary Arguments
275. python fetches the last element from a list using a negative index—
A. print("Last element = ",mylist[0])
B. print("Last element = ",mylist[])
C. print("Last element = ",mylist[-1])
D. NA
277. Which of the following will print five rows with five '*' in each row?
for i in range(0,5): for i in range(0,5): for i in range(1,5): for i in range(0,5):
print("*" * i) (print)"*" * 5 print("*" * 5) print("*" * i)
278. Which of the following operations is not valid for tuples in Python?
Concatenation Indexing Appending Slicing
Page 48 of 52
279. What will be the output of the following Python code snippet?
my_tuple (1, 2, 3, 4, 5)
print(my_tuple[1:4])
(1, 2, 3, 4) (2, 3, 4) (2, 3, 4, 5) (1, 2, 3)
280. Which of the following methods is used to find the index of a particular element in a tuple?
index() find() search() locate()
281. What will be the output of the following Python code snippet?
my_tuple = ('a', 'b', 'c', 'd', 'e')
print(my_tuple.index('c'))
2 3 4 error
282. Which of the following methods is used to count the number of occurrences of a particular
element in a tuple in Python?
count() occurrences() find() search()
283. What will be the output of the following Python code snippet?
my_tuple (1, 2, 3, 4, 5)
reversed_tuple=my_tuple [::-1]
print(reversed_tuple)
(1, 2, 3, 4, 5) (5,4,3,2) (5, 4, 3, 2, 1) Error
285. Which of the following methods is used to get a list of all keys in a python dictionary?
keys() getkeys() lists() NA
288. What will be the output of the following Python code snippet?
my_dict = {'a': 1, 'b': 2, 'c': 3)
result = my_dict.values()
Page 49 of 52
print(result)
[1, 2, 3] (1, 2, 3) dict_values([1, 2, 3]) {1, 2, 3}
289. Which of the following methods is used to get a list of all key-value pairs in a Python
dictionary?
items() get_items() list() None of these
290. Which of the following methods is used to remove key-value pairs from a Python
dictionary?
delete() pop remove() None of these
291. Which of the following methods is used to delete all items from a Python dictionary.
remove_all() clear() None of these delete_all()
292. Which of the following methods is used to remove key-value pairs from a Python
dictionary?
delete() pop() remove() None of these
294. What will be the output of the following Python code snippet?
my_dict {'a': 1, 'b': 2, 'c': 3}
result = my_dict.popitem()
print(result)
295. What will be the output of the following Python code snippet?
my_dict = {'a': 1, 'b': 2, 'c': 3)
(‘a’,1) (‘b’,2) (‘c’,3) (‘a’, 1, ‘b’, 2)
295. What will be the output of the following Python code snippet?
my_dict = {'a': 1, 'b': 2, 'c': 3)
result = my_dct.setdefault('d': 4)
print(result)
1 82 3 4
Page 50 of 52
296. Which of the following methods is used to determine the length of a tuple in Python
size() length() count() len ()
299. Which of the following val= will complete val to 20 from a Tuple?
aTuple = ("Orange", (10, 20, 30), (5, 15, 25))
val = ____
@ val = aTuple[1:2][1] val = aTuple[1:2](1) val = aTuple[1][1] val = aTuple[1][1]
300. The type of the tuple will be printed when the following code is executed—
aTuple = ("Orange")
print type(aTuple)
list str tuple
Page 51 of 52
("Yellow", 20, "Red") Yellow 20 Red
302. Which of the following options will give the same output?
tupl1 = (5, 3, 1, 9, 0)
# options i, ii, iii, or iv
print(tup1[:-1]) print(tup1[0:5]) print(tup1[0:4]) print(tup1[-4:])
i, ii ii, iv i, iv i, iii
Page 52 of 52