0% found this document useful (0 votes)
100 views52 pages

COMS

This document contains a series of multiple-choice questions (MCQs) related to Python programming, covering topics such as data types, syntax, programming concepts, and specific functions. Each question presents options for answers, testing knowledge on various aspects of Python. The document serves as a quiz or study material for individuals looking to assess or enhance their understanding of Python.

Uploaded by

Soma Sagarika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views52 pages

COMS

This document contains a series of multiple-choice questions (MCQs) related to Python programming, covering topics such as data types, syntax, programming concepts, and specific functions. Each question presents options for answers, testing knowledge on various aspects of Python. The document serves as a quiz or study material for individuals looking to assess or enhance their understanding of Python.

Uploaded by

Soma Sagarika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

Python MCQs

1.​ Python is a _____ language.

Middle level Object oriented Procedural Difficult

2.​ Python uses to convert source code into object code —

Interpreter Compiler Combination Of Interpreter and Special virtual engine


compiler

3. The Python code can be used on different platforms; it means that Python is a
language.
Independent Cross-platform Independent All of these

4. Python programs are typed in an


Interactive mode Script mode Combination of interactive and All of these
script modes

5. Python's _____ gives immediate results of typed statements.


Interactive mode Script mode Combination of interactive and All of these
script modes

6. Features of Python programming are —


i. Python is a readable language because it closely resembles the English language
(Readable).
ii. Python has few keywords, simple structures, and a clearly defined syntax (easy to learn).
iii. Python is available and runs on various operating systems (eg, Mac, Windows, Linux, Unix,
etc.) (cross-platform).
iv. Python is an open-source programming language.
The correct pair below is—
(i), (ii) & (iii) (ii), (iii) & (iv) (i), (iii) & (iv) All of these
7. Note the two Assertion and Reason statements below—
Assertion-(A): In Python, operations can be performed in interactive mode and script mode.
Reason-(R): Interactive mode outputs commands interactively, whereas script mode does not.

The correct option below is—

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

8. Note the left column and right column below—

Column A Column B
I.​ Open-source programming language A. Python distributions

II.​ Pandas B. Django

III.​ Libraries for Artificial Intelligence C. Python Programming

IV.​ Python web development framework D. Keras

Match the following and say which is 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

9.​ Python source code _____ converts into an intermediate form.

Compilecode Executecode Bytecode Runningcode

10.​Which line of code below produces an error?

"one" + "2" ‘5’ + 6 3+4 “7” + ‘8’

11.​Observe the following sentences —


i.​ Programs can be created in Python's script mode
ii.​ Python code is compiled before execution
iii.​ Python is an interpreted language

The correct pair of the true statements is—


(i) &(iii) (i) & (ii) (ii) & (iii) NA

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

14. Data items with specific values are called —


Identifiers Functions Keywords Literals

15. Which Of the following is the correct way to generate string?


Name Jiya Name ‘Jiya’ Name “Jiya” Both B & C

16. Which below is the keyword(s)?


Name Input Print Both B & C

17. Notable applications of Python programming are —


i. Embedded Scripting Language ii. 3D Software
iii. Web Development iv. GUI based Desktop Applications
(i), (ii), (iii) & (iv) (ii), (iii) & (iv) (i), (iii) & (iv) (i), (ii) & (iv)

18. Note the left & right column below:

i.​ Odoo A.​ Civilization-IV

ii.​ Maya B.​ Web Application

iii.​ Language development C.​ Image processing &Graphics design

iv.​ Gaming SW D.​ CoffeeScript

Match the following and say which is 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

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

21. Observe the following sentences —


i.​ Set is a mutable data type
ii.​ The real value of an empty string is false
iii.​ Value false in Python is a legal literal value

The correct pair of the true statements is—


(i) & (iii) (i) & (ii) (ii) & (iii) (i), (ii) & (iii)

22. Which below is a valid identifier?


My name My—name Myname Both B & C

23. Which of the following are literals?


Myname ‘Radha” 24.5 Both B & C

24. Escape sequences are called—


Strings Characters Integers NA

25. Which of the following is an escape sequence for a tab character?


\a \n \t \b

26. Which of the following is an escape sequence for a newline character?


\a \n \t \b

27. Python programming can be done with which mobile application?


i. Pyroid ii. Sololearn iii.QPython
(i), (ii), (iii)​ (ii), (iii) (i), (iii) None of these

28. Note the two Assertion and Reason statements below—


Assertion-(A): Python's script mode is suitable for creating programs.
Reason-(R): Interactive mode can be saved later as a program with a name.
The correct option below is—

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

29: Note the Columns below:

i.​ Assert A.​ Special literals

ii.​ Octal literal B.​ 0o45

iii.​ Complex literals C.​ 8+7i

iv.​ None D.​ Python keyword

The correct 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

30. We need operator to find xy.


** * \ ++

31. What will be the output of the code below?


>>> int("30”+”40”)
"70" “3040" 3040 ("30" + "40")

32. Observe the following sentences—


i.​ bool(O) results in False
ii.​ Do not compare two floating-point numbers for equality using
iii.​ The floor division of two integers results in an integer

The correct pair of the true sentences is—


(i) & (iii) (i) (i), (ii), (iii) NA

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

35. Which of the following are expressions?


a+b-5 b-5 -5 Both A & B

36. Lines beginning with a certain character are ignored and not executed by the compiler—
operators operands functions comments

37. Which of the following can be used to create comments?


// # “…” Both B & C

38. python keywords are —


i. if ii. Return iii. True iv. value
The correct pair of the true statements above are given below —
(i) (iii) (ii) (iii) (i), (ii), (iii) None of these

39. Note the two Assertion and Reason statements below—


Assertion-(A): Python tokens provide keywords, Identifiers, Literals, Punctuators, and
Comments.
Reason-(R): A Token is the smallest unit of a program.
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
40. Match the columns:

[4, 66, 3, 7] Tuple literals


(7, 8, 2, 9) Set literal
{‘b': ‘book’, ‘c’: ‘cat’} List literal
{‘a’, ‘e’, ‘I’, ‘o’, ‘u’} Dictionary literal

Correct option is:


i-A, ii-B, iii-C, iv-D i-C, ii-A, iii-D, iv-B i-B, ii-C, iii-D, iv-A i-D, ii-B, iii-C, iv-A

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

42. What will be the output of the code below?


>>> float ("123" * int (input ("Enter a number:”))
Enter a number: 3
“123123123” “369.0” 123123123.0 369.0

43. Observe the following sentences—


i.​ The true value of " “(a space) is False
ii.​ List is an immutable data type
iii.​ A set can contain duplicate values

The correct pair of the false sentences is—


(i) & (iii) (i) & (ii) (i), (ii) & (iii) (ii) & (iii)

44. Which of the following functions prints output to the console?


Output() Print() Echo() print()

45. Reserved keywords in Python—


else import print All of these

46. input() returns the value as type--


Integer String Floating point NA

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

49. Examples Of escape sequences are—

Page 7 of 52
A.​ \a B.​ \t C.​ [ ] D.​ \n

50. Note the two Assertion and Reason statements below—


Assertion-(A): A Python program can have executable and non-executable items.
Reason-(R): Comments are non-executable parts of a 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

51. A B
i. @ A. Python prompt
ii. \n B. Punctuators
iii. ‘’ ‘’ C. Escape Sequence
iv. >>> D. Quotation

Match the column:


i-A, ii-B, iii-C, iv-D i-C, ii-A, iii-D, iv-B i-B, ii-C, iii-D, iv-A i-D, ii-B, iii-C, iv-A

52, To print "Python is fun", fill in the blanks: print ("Python" + “_____+_____)
Is, fun is ” , “ fun” “is”,”fun NA

53. Which of the following results is true?


>>> 9 = 9 and 1==1 >>7 != 1 and 5==5 >> 3==5 and 7==3 >>4<1 and 1>6

54. Observe the following sentences—


i.​ The true value of none is not False
i.​ In implicit conversion, the data type of all operands is converted to the data type of the
largest operand
ii.​ Python is a proprietary programming language
(ii) & (iii) (i) (i), (ii) & (iii) 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

56. The default delimiter character for print() is—


Tab Space Newline Dot

57. print() is used to provide which different separator with arguments?


Sep Separator End Tab

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)

61. Note the two Assertion and Reason statements below—


Assertion-(A): In Python, a variable can hold different values at different times
Reason-(R): A variable's data type, once determined, remains constant throughout the program
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

62. A B
i.​ True, False A.​ String

ii.​ 9, -5 B.​ Integer type

iii.​ 8.6, -76.43 C.​ Float type

iv.​ ‘hello’ D.​ Boolean type

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

64. Which of the following results is false?

>>> 9 = 9 or 1==1 >>> 3==4 or 7==7 >>> 7 != 1 or 5==5 >>> 4<1 or 1>6

65. Observe the following sentences:


i.​ Python uses words like English.
ii.​ Python is derived from C.
iii.​ Python fully supports the object-oriented programming paradigm.

The correct pair for the true sentences is—


(i) & (iii) (i) & (ii) (ii), (iii) (i), (ii) & (iii)

66. Which of the following are not immutable types in Python?

String Dictionary Set Both B & C

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

71. The function of data type conversion is—


i. repr(x) ii. ceil(x) iii. float(x)
The correct pair below is—
(i) & (iii) (i) & (ii) (i), (ii) & (iii) (ii) & (iii)

72. Note the two Assertion and Reason statements below —


Assertion (A): In Python, blocks are represented by indentation.
Reason (R): Blocks in Python are compound statements.
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

73. A B
i.​ str(x) A.​ Converts x to a floating point value

ii.​ float(x) B.​ Expresses a single character as an


integer

iii.​ chr(x) C.​ Converts x to a string

iv.​ ord(x) D.​ Converts an intefer to a character

The correct 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

74.Boolean values are ___ & ___


True, False 0, 1 -1, 1 All of these

75. Identify the correct mathematical expression in Python—


(5 ^ * 6) (7 + 8) 4^*(3-2) 5***3 11*(12 + 13)

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

The correct pair of false sentences are


(i) (i) & (iii) (i), (ii) & (iii) NA

77. In the Python statement x=a + 5 + (-b), a and b are—


Operands Expression Operators Equation

78. In the Python statement x = a+5—b: a +5—b, x is—


Operators Expression Operands Equation

79. Which of the following operators has the lowest precedence in Python?
Not % And + **

80. What is the value of 10+3**3*2?


28 829 739 64

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

82. The conventions for naming identifiers are—


i.​ Identifier names start with 'A' to 'Z' or 'a' to 'z', or underscore followed by any alphabet,
underscore, or digit (0-9)
ii.​ Special symbols such as @, $, % cannot be used in Python identifiers
iii.​ Python is case-sensitive, which is A and a carry different meaning

The correct pair below is—


NA (i) & (ii) (i), (ii) & (iii) (ii) & (iii)

83. Assertion (A): Python supports dynamic typing of variables.


Reason (R): A variable can hold different values at different times in a program.
The correct option below is—

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.

iv. // D. Determines the power value using base and power.

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

85. >>> 70!=80 as an output gives


1 0 False True

86. >>> print(format(56.78901, ‘3f’)) What will be the output of this code?
56.789 5.6789 0.56789 56789

87. Observe the following sentences—


i. In Python, integers can be specified in both octal and hexadecimal number systems
ii. A string can be printed without using the print function
iii. A string cannot be multiplied by a floating-point number
The correct pair of the true Statements is—
ii, iii i i, ii, iii NA

88. What is the result of 10 or 0?


0 1 True False

Page 13 of 52
89. The result of 5 or 10 —
0 1 True False

90. The result of 5 and 10—


0 1 True False

91. The result of 15 and 10 —


0 1 True False

92. The result of sum ‘a’ or “ ” is


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

94. Note the two Assertion and Reason statements below—


Assertion-(A): Mutability means that values can be changed from place to place
Reason-(R): Immutability types mean that their value cannot be changed from place to place
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

95. A B
i. Unary Plus A. ++
ii. Unary minus B. -
iii. Decremental operator C. --
Iv. Incremental operator D. +

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

Page 14 of 52
96. (_____7*-3) + 9 = 30, fill in the missing number.
* - + /

97. The following statement will produce __ line output.


print ('Good\n Morning\n World\n— Bye')
1 2 3 4

98. Observe the following sentences —


i. Programmers should explicitly delete an unused object
ii. It is possible to add and multiply two strings
iii. python variables do not have specific types
The correct pair of the true statements is—
(i) e (iii) (i), (ii) (ii), (iii) NA

99. Types of type conversion are —


3 2 1 NA

100. The sum of 'x' and 'a' is —


‘a’ ‘x’ ‘’ 1

101. The sum of 'a' and 'x' is —


‘a’ ‘x’ ‘’ 1

102. The result of 'a' and 'None' is —


‘a’ ‘’ ‘None’ 1

103. The result of 'None' and 'a' is —


‘a’ ‘’ ‘None’ 1

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

105. Note the two Assertion and Reason statements below—

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?

ii.​ a <= b B. Is the value of a equal to the value of b?

iii.​ a != b C. Is the value of a greater than or equal to the value of b?

iv.​ a == b D. Are the values of a and b unequal?

The correct 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

107. Variable names can only contain --


punctuators, letters, underscores underscores, numbers, punctuators
letters, identifiers, constants letters, numbers, underscores

108. Identify which expressions can cause arithmetic overflow?


a ^* b a^b a/b a+b

109. Observe the following sentences —


i.​ Variable names can start with numbers
ii.​ char is a valid data type in Python
iii.​ In a string single quotes and double quotes cannot be used in a triple quote.

The correct pair of which are false is—


(ii) & (iii) (i), (ii) (i) & (iii) (i), (ii) & (iii)

Page 16 of 52
110. Result of 'false' and False—
false False ‘false’ ‘False’

111. Result of 'false' or False—


false False ‘false’ ‘False’

112. Note the two Assertion and Reason statements below—


Assertion-(A): Type conversion can be Implicit or Explicit.
Reason-(R): Only the Python interpreter can force Type Conversion, not the programmer.
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

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.

Matched columns 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

114. How many numbers will be printed?


i=5
while i > -1:
print (i)
i=i-1

Page 17 of 52
5 6 4 0

115, Observe the following sentences?


i.​ programs can be created in Python's script mode
ii.​ All spaces and tabs within a string are enclosed in quotes
iii.​ The keyword cannot be used to name the identifier

The correct pair of which is true—


(ii), (iii) (i), (ii), (iii) (iii) None of these

116. Note the two Assertion and Reason statements below—


Assertion-(A): Syntax errors are violations of the grammatical rules of a programming language.
Reason-(R): Syntax errors can be easily caught by the Python interpreter
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

117. B
A
i.​ & A. Bitwise AND logic operation between two data.

ii.​ | B, Bitwise OR logic operation between two data.

iii.​ ^ C, Bitwise exclusive OR logic operation between two data.

iv.​ ~ D. Operates on a single operand. Output I if operand value 0, output 0 if operand


value I.

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

118. How many numbers will be printed?


i=10
while True :
print(i)
i=i-1
if i <7 :

Page 18 of 52
break
1 2 3 4

119. Observe the following sentences—


i.​ A variable can be assigned a value only once
ii.​ bool('None') results in False
iii.​ Python is a case-insensitive language

The pair of which are false is?


(i) & (iii) (ii) & (iii) (ii) & (iii) (i), (ii) & (iii)

120. Note the two and Reason statements below—


A: Logical errors are the result of incorrect analysis of a problem.
R: Logical errors are missed by the interpreter.
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

121. Consider the following program —


# This is a sample program
# to output simple statements
# print (“Such as'")
print (“Take every chance.")
print (“Drop every fear.")
which is the right output?
Such as Such as Take every chance. All of these
Take every chance. Take every chance. Drop every fear.
Drop every fear. Drop every fear.

122. Which of the following are not valid strings in Python?


i. "Hello" ii. 'Hello' iii. "Hello' iv. 'Hello" v. (Hello)
iii, iv, v i, ii, iii ii. iii, iv i. iv, v

123. What is the value of 100// 125?


4 4.0 2.5 NA

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

125. What Will be the output of the following code?


5<5 or 10
True False 0 10

126. What will be the output of the following code?


>>> 10 or 5
True False 0 10

127. Note the two Assertion and Reason statements below—


Assertion-(A): Despite being error free there can be exception.
Reason-(R): Unexpected irregular situations during run-time are called exceptions.
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

128. What will be the output of the following code?


>>> 5 < (5 or 10)
True False 10 0

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

130. What will be the output of the following code?


a=3+5/8
b=int (3 + 5/8)
c = 3 + float (5/8)
3.625, 3, 3.625 3.625, 3.625,3.265 3, 3, 3 NA

131. In a python program, a control structure--


A.​ Indicates the order of execution of statements in the program
B.​ Indicates what happens before the program Starts and after it ends
C.​ Defines program-specific data structures
D.​ Handles input and output control characters

132. An empty/null statement in Python is


go over pass ;

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

136. Observe the following sentences —


i.​ An if-else tests fewer conditions than two consecutive if statements

Page 21 of 52
ii.​ A for loop is called a determinable loop
iii.​ A while loop is an exit-controlled loop

The correct pair of which is true is —


(i) & (iii) (i) & (ii) (i), (ii) & (iii) (ii) & (iii)

137. Observe the following sentences—


i.​ range() creates an iterable sequence
ii.​ A for loop can test a condition before executing the loop body

The correct pair of which is true is —


(i) & (ii) (i) (ii) NA

138. Observe the following sentences—


i.​ Only if statements can contain an else clause
ii.​ A loop can •Isn take an else clause
iii.​ A loop's else clause executes only when a break statement terminates it

The correct pair of which is false is given below—


(i) & (iii) (i) & (ii) (i), (ii) & (iii) (ii) & (iii)

139. Observe the following sentences--


i.​ A loop with an else clause executes its else clause only when the loop terminates
normally
ii.​ A loop with an else clause cannot contain a break statement

The correct pair of which is true?


(i) & (ii) (i) (ii) NA

140. Observe the following sentences?


i.​ A continue statement can replace a break statement
ii.​ An equivalent while loop can always be written for a for loop

The correct pair of which is true?


(i) & (ii) (i) (ii) NA

141. Note the two Assertion and Reason statements below—


Assertion-(A): Python's pass statement is an empty statement

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

142. Note the following two Assertion and Reason statements —


Assertion-(A): Flow of control in a program can occur sequentially, selectively, or recursively.
Reason (R): Sequence structure means that the statements will be executed sequentially.
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

143. Note the following two Assertion and Reason statements —


Assertion-(A): The Python if statement represents the selection construct.
Reason-(R): Selection construct refers to the execution of a set of statements depending on the
outcome of a condition.
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

144. Note the following two Assertion and Reason statements —


Assertion-(A): The for loop is a counting loop that operates on a sequence of values
Reason-(R): range() function creates a range of list type.
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

145. Note the following two Assertion and Reason statements —


Assertion-(A): Both break and continue are jump statements.
Reason-(R): break and continue can both stop loops, and so one can be used instead of the
other.

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 ()

iv.​ Used to count the number of non-overlapping occurrences of the D. index ()


substring specified as a function parameter.

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

147. A B
i.​ Returns a Boolean value depending on the character in the A.​ islower()
string and the existence of the text character.

ii.​ Whether a given string contains only alphabetical or B.​ Isalpha ()


numerical characters. or a combination of both.

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.

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

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

149. What does the following Python program display?


x=3
if x == 0:
print ("Am I here?", end =’ ‘)
elif x==3:
print("Or here?", end=' ‘)
else:
pass
print ("Or over here?" )
Am I here? Am I here? Or here? Or here? Or here? Or over
here?

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

151. Observe the following sentences—


i. A for loop can always be written as an equivalent for a while loop.
ii. The range() function can only be used for for loops.
Iii. The if-elif-else statement is equivalent to a nested if statement.

The correct pair of which is false?


i, iii ii ii, iii i, ii, iii

152. Observe the following sentences—


i.​ Strings have both positive and negative indices.
ii.​ Python does not support any character types; A single character is treated as a string
of one length.

Page 25 of 52
The correct pair of true statements is—
i i, ii ii NA

153. Observe the following sentences —


i.​ Strings are immutable in Python. which means that a string cannot be changed.
ii.​ Like +, all other arithmetic operators are also supported by strings,
iii.​ The capitalize() and title() functions return the same result.

The correct pair of which is false?


(i) & (iii) (i) & (ii) (i), (ii) & (iii) (ii) & (iii)

154. Observe the following sentences—


i.​ The partition() and split() functions work similarly.
ii.​ find() and index() are similar functions.

correct pair of the true statements is—


i i, ii ii NA

155. Observe the following sentences—


i.​ find() does not raise an exception if the substring is not found.
ii.​ The result of the partition() function is always a 3-element tuple.
iii.​ split() always returns a 3-element list.

Correct pair of the true statements is—


(i) & (iii) (i) & (ii) (i), (ii) & (iii) (ii) & (iii)

156. Note the two Assertion and Reason statements below—


Assertion-(A): Only while loops can use break statements.
Reason-(R): Loop while is a conditional loop in Python and terminates when its condition returns
false.
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

157. Note the two Assertion and Reason statements below—


Assertion-(A): The individual characters of a string are stored randomly in memory.

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

158, Note the two Assertion and Reason statements below —


Assertion-(A): Position and index of string characters are different.
Reason-(R): The character positions of the string are from 1 ... n, where n is the size of the
string.
index of the string ranges from 0 to n-1.
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
159. Note the following two Assertion and Reason statements —
Assertion-(A): Alongside operator and number can work with strings as well.
Reason-(R): Unlike numbers, strings can be concatenated and replicated.
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

160. Note the two Assertion and Reason statements below—


Assertion-(A): Like numbers, >, < can compare two strings.
Reason-(R): Comparison of Python strings in dictionary order using letter-by-character
comparison rules for ASCII/ Unicode is done.
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 ()

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

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.

Matched options are:


i-A, ii-B, iii-C, iv-D i-B, ii-A, iii-D, iv-C i-C, ii-A, iii-D, iv-B i-D, ii-B, iii-C, iv-A

163. Consider a code snippet for questions i-v—


a=int(input("Enter an integer: "))
b=int(input("Enter an integer: "))
if a<=0:
​ b=b+1
else:
​ a=a+1
if a>0 and b>0:
​ print("W")
elif a > 0:
​ print("X")
if b>0:
​ print("Y")
else:
​ print("Z")

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

164. Consider the loop given below—


for i in range(-5):
​ print(i)
How many times will this loop run?
5 0 Infinite Error

165. Consider the loop given below—


for i in range(10, 5, 3):
​ print(i)
How many times will this loop run?
3 2 0 Infinite

166. Observe the following sentences —


i.​ Each function can be written more or less independently of the others.
ii.​ When a function call is encountered, control passes to the calling function.

The correct pair for the true sentences is—


i, ii i ii NA

167. Observe the following sentences —

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.

correct pair for the true sentences is—


(i) & (iii) (i) & (ii) (i), (ii) & (iii) (ii) & (iii)

168. Observe the following sentences —


i.​ We can have a function that takes no input
ii.​ The calling function may or may not pass parameters to the called function.

The correct pair for the true sentences is given below—


i, ii i ii NA

169. Observe the following sentences —


i.​ The return statement is optional.
ii.​ Python does not allow assigning function names to a variable.
iii.​ The expression int(x) indicates that the variable x has been converted to an integer.

The correct pair for the true sentences is—


(i) & (iii) (i) & (ii) (i), (ii) & (iii) (ii) & (iii)

170. Observe the following sentences —


i.​ 4/(3*(2-1)) and 4/3*(2-1) have the same values
ii.​ 4/(3*(2-1)) and 4/3*(2-1) have the same values
iii.​ The equation 2*23 evaluates to: (22)*3

The correct pair of which is false is given below?


(i) & (iii) (i) & (ii) (i), (ii) & (iii) (ii) & (iii)

171. Note the two Assertion and Reason statements below —


Assertion-(A): String is and substring, both extracted subparts of a string.
String slices and substrings have the same meaning.
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 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

173. Note the two Assertion and Reason statements below—


Assertion-(A): A string slice consists of a segment of strings according to s[start : end : n],
starting at start' every nth character is contained, extends to end, and does not include the end
character
Reason-(R): Opposite the string slices, a substring consists of contiguous characters.
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

174. Note the two Assertion and Reason statements below—


Assertion-(A): In Python, unlike other types, the elements of a List can be changed from place to
place.
Reason-(R): Lists are mutable sequences.
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

175. Assertion-(A): Creates a list of any comma-separated group of values,


Reason(R): A list consists of a group of values or expressions separated by commas enclosed
in [].
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

178. Consider the loop given below—


for i in range(3):
​ pass
What will be the final value of 'i' after this loop?
0 1 2 3

179. Consider the loop given below —


for i in range(7, 4, —2):
​ break
What will be the final value of 'i' after this loop?
4 5 7 -2

180. Consider the loop given below —


What will be the final value of 'i' after this loop?
for i in range(10):
​ break
10 0 Error 9

181. Observe the following sentences?


i. A string can be surrounded by three sets of single quotation marks or three sets of double
quotation marks,
iii Variables can only be assigned once.
iii. In Python, a variable is a placeholder for data.
The correct pair of which is false is?
(i) & (iii) (i) & (ii) (i), (ii) & (iii) (ii) & (iii)

182. Observe the following statements —


i. In Python, only if statements have an else clause.
ii. Python loops can also have an else clause.
iii. In a nested loop, a break statement terminates all nested loops at once.
The correct pair of which is false is given below?

Page 33 of 52
i i, ii ii NA

183. Observe the following sentences —


i. Do the two below represent the same list?
ii. A list can contain any type of object except another list.
Below is its correct pair —
i i, ii ii NA

184. Observe the following sentences —


i. There is no conceptual limit to list size.
ii. All elements of the list must be of the same type.
iii. A given object can appear in a list more than once.
The correct pair below of which is true is given
(i) & (iii) (i) & (ii) (i), (ii) & (iii) (ii) & (iii)

185. Note the two Assertion and Reason statements below —


Assertion-(A): Lists and strings have similar indexing,
Reason-(R): Lists and strings have two-way indexing, forward indexing, and backward indexing.
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

186. Note the two Assertion and Reason statements below —


Assertion (A): Lists are similar to strings in many ways, such as indexing, slicing, and accessing
individual elements.
Reason-(R): Unlike strings, lists are mutable.
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

187. Note the two Assertion and Reason statements below —


Assertion-(A): The "in" and "not in" membership operators work on lists in the same way as they
do on strings.
Reason-(R): Some operators work differently on strings and lists, such as "+" and
The correct option below is —
A. Both (A) and (R) are true and (R) is the correct explanation of (A)

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

188. Note the two Assertion and Reason statements below —


Assertion-(A): A slice of a list is an extracted part of a list.
Reason-(R): A Slice of a list is itself a list.
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

189. Note the following two Assertion and Reason statements—


Assertion-(A): Assigning a new value to an int variable creates a new variable internally.
Reason-€R): int is an immutable data type of Python.
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

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.

ii.​ Generates random floating numbers B.​ random()


between 0.1 and 1.0.

iii.​ tan() C.​ The method is used to calculate the


tangent value of an angle in radians

iv.​ cos() D.​ randint()

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

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()

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

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

193. What will be the output when this code is executed


x=1
while (x<=5):
​ x+=1
print(x)
0 1 4 6

194. How many times is the code below executed?


x=1
while (x<=5):
​ x+1
print(x)
6 1 4 infinite

195. Observe the following sentences —


i.​ The keys of a dictionary must be of an immutable type.
ii.​ A numeric value and a string can be concatenated using symbols.

The correct pair of which is true is given below —


ii i i, ii NA

196. Observe the following sentences:

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

197. Observe the following sentences ---


i. A list of characters is similar to a string type
For any index n, s[n] + s[n:] will return the original string
iii. A dictionary can contain keys of any valid Python type
parr of which is false is given below:
ii i i, ii NA

198. Note the two Assertion and Reason statements below—


Assertion-(A) “““A Sample Python String””” is a valid python string.
Reason(R)-Triple quotation marks are not valid in Python.
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

199, Note the two Assertion and Reason statements below—


Assertion-(A): If and for are valid statements in Python.
Reason-(R): If is case sensitive in Python, and its basic selection and looping statements are
lowercase.
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

200. Note the two Assertion and Reason statements below —


Assertion-(A): The break statement can be used with all selection and iteration statements.
Reason-(R): Using the break with the 'if statement has no unless the if statement is part of a
looping construct.
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)

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

202. Assertion-(A): Python module documentation should be written in triple-quoted strings.


Reason-(R): docstring is a triple-quoted string in Python that is displayed as documentation
when the help() command is issued.
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()

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

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

206. Guess the output of the following string operations—


str1 'Wah'
print (str1*2)
WahWah WWWaahh TypeError Wah2

207. What is the output of the following string operation?


str1= "My roll no. is 12"
print(str1.isalnum())
True False Error No output

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

209. Note the following two Assertion and Reason statements—


Assertion-(A): If an item is imported from a <module>import <item> statement, then the module
name cannot be used with the imported item.
Reason-(R): The module import command modifies the program namespace and adds imported
items to it.
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)

Page 39 of 52
C. (A) true but (R) false (or partially true)
D. (A) false (or partially true) but (R) is true

210. Note the following two Assertion and Reason statements—


Assertion-(A): Python's built-in functions, which are part of the standard Python library, can be
used directly without specifying their module names.
Reason-(R): The built-in functions of Python's standard library are made available by default in a
program's namespace.
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

211. Note the two assertion and reason statements below—


Assertion-(A): A function is a sub program.
Reason A function exists within a program and operates within it when call
The correcto tion 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

212. Note the two assertion and reasons


Assertion-(A): Non-default arguments cannot follow default arguments in a function call.
Reason-(R): A function call can have different types of 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

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.

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

215. Select the correct output of the following string operations.


str1='Study'
print(str1[:3] + 'with' + str1[3:]
studywithwith stuwithudy withstudy studyith

216. Select the correct output of the following string operations.


str = "my name is SWC'
print (str.capitalize())
'My name is swc' TypeError 'My name is SWC’ 'My Name Is Anu swc'

217. How many times will the print() executed?


def display():
​ print ('a')
​ print ('b')
​ return
print ('c')
print ('d')
1 2 3 4

218. Note the following two assertion and reason statements —

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

219. Note the two assertion and reason statements below—


Assertion-(A): Variables declared inside functions cannot be used outside of.
Reason-(R): Variables created inside functions have a function scope.
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

220. Note the following two assertion and reason statements —


Assertion-(A): Parameters that have a default value in the function header are called default
parameters.
Reason-(R): Assumes the default value of a parameter only if no value is provided for that
parameter in the function call statement.
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

222. What is the output of this code?

Page 42 of 52
import random as r
print (random.randomint (1, 10)))
An error occurs 1 10 Any other random value

223. How many numbers will the code print?


def display (x):
​ for i in range (x):
​ ​ print(i)
​ return
display(10)
0 1 9 10

224. Which function header below is correct?


A. def f (a =1, b):
B. def f (a=1, b = 1. c = 2):
C. def f (a =1, b, c = 2):
D. def f (a = 1, b=1, c = 2, d);

225. Which of the following statements will create a selection structure?


If If-else for A&B both

226. Which of the following statements will create a repeating structure?


if while for Both B & C

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

228. What is meant by the end of a statement block or suit in Python?


A comment end A line that is indented less than the }
previous line

229. Which of the following is not a valid loop in Python?


for if-else do-while Both B & C

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

232. The function range(3) is equivalent to —


range (1, 3) range (0, 3) range (0, 3, 1) Both B&C

233. The function range(3) will create an iterable sequence like


[0, 1, 2] [0, 1, 2, 3] [1, 2, 3] [1, 2]

234. The blank may be filled in, for a in ____


an iterable sequence a range() function a single value both A&B

235. Which below is an entry-controlled loop?


if while for both B&C

236. else keyword can be part of which statement?


if for while all of these

237. Which is the Jump statement below?


if break continue B&C both

238. Negative exponent -1 belongs to the ____ string


1st character last character 2nd last character 2nd character

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()

246. Which function below will always return a tuple of 3 elements?


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

249. Which statement invokes which function?


Function definition Function call Function header

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

251. Determines the ______ accessibility of a variable to a part of the program.


scope lifetime data type value

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

258. Which of the following Random module function generates an integer?


random() randint() uniform() all of these

259. Which file must be part of a folder to be used as a Python package?


package.py _init_.py _package_.py _module_.py_

260. A Python module has the extension


.mod .imp .py .mpy

Page 46 of 52
261. Which of the following is not a function/ method of Python's random module?
random() randint () radfloat () randrange()

262. Which of the following is an invalid variable?


2n_day my_day_2 Day_two _2

263. Which below is an invalid identifier?


name break section mark12

264. Which below is not a keyword?


eval assert nonlocal pass

265. Which below cannot be a variable?


_init_ in it on

266. Which among these is not a core data type?


Lists Dictionary Tuples Class

267. The value of 14 + 13%15 will be—


14 27 12 0

268. If A = 16 and B = 15, evaluate the expression A%B//A, -A%B//A


0, 0 0 1, 0 1

269. x=int (13.25+ 4/2), what is the value of x?


17 14 15

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

272. The correct way to create multi-line string in Python


A. str = " "My name is Kevin and 1 live in New York""
B. str """ My name is Kevin and I live in New York"""
C. str = "My name is Kevin and I live in New York"
D. All of the above

273. To begin slicing from the end of a string Python uses —


Indexing Begin with the 0th index Negative Indexing Escape Characters

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

276. Which below will add the numbers 1 to 4?


for i in range (1,4): sum = 0 sum = 0 for I in range (1, 5):
sum = 0 for i in range(1,4): for i in range(1,5): sum=0
sum = sum + i sum = sum + i sum = sum + i sum=sum+i

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

284. What will be the output of the following Python co


tuplel = (1, 2, 3)
tuple2 = (4, 5, 6)
result tuplel + tuple2
print(result)
(1, 2, 3, 4, 5. 6) (1, 2, 3), (4, 5. 6) (4, 5, 6, 1, 2, 3) 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

293. Which of the following statements about dictionaries in Python is true?


Dictionaries are Dictionaries are Dictionaries are Dictionaries can
collected sequentially immutable indexed by integers contain duplicate keys

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 ()

297. Assertion-(A): Tuples are immutable sequences in Python.


Reason-(R): Cannot change elements of any area of the tile.
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

298. Note the two Assertion and Reason statements below—


Assertion-(A): Dictionaries are somewhat similar to lists.
Reason-(R): Dictionaries are like lists only in variability.
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

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

301. What is the ouput?


def practice (tup):
​ a, b, c = tup
​ return a
aTuple = "Yellow", 20, "Red"
practice(aTuple)

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

You might also like