top of page

Python Practice Set January 2023

Updated: Dec 31, 2022


The output of the following code.

string=”my name is x”

for i in string:


A. m,y,,n,a,m,e,,i,s,x,

B. m,y,,n,a,m,e,,i,s,x

C. my,name,is,x

D. None

Answer: (A)

2. What arithmetic cannot be used with strings?

A. +

B. *


D. All of the mentioned

Answer: (C)

3. The output of the following code.

string=”my name is x”

for i in string.split():

print(i,end=”, ”)

A. m,y,,n,a,m,e,,i,s,,x,

B. m,y,,n,a,m,e,,I,s,,x

C. my,name,is,x,

D. Error

Answer: (C)

4. The output of the following code.


for a[-1] in a:


A. 0 1 2 3

B. 0 1 2 2

C. 3 3 3 3

D. error

Answer: (B)

5. The output of the following code.


for a [0] in a:


A. 0 1 2 3

B. 0 1 2 2

C. 0 2 3 4


Answer: (A)

6. The output of the following code.


i= -2

for i in not in a:



A. -2 -1

B. 0

C. Error

D.None of the mentioned

Answer: (C)

7. The output of the following code.


A. a

B. cde

C. bcd


Answer: (D)

8. The output of the following code.

>>>”abcde”[3 :]

A. ab

B. de

C. cde


Answer: (B)

9. The output of the following code.

>>>print(‘new’ ‘line’)

A. error

B. output equialent to print ‘newline’

C. newline line

Answer: (D)

10. The output of the following code.

>>>max(“what are you”)

A. u

B. t

C. m


Answer: (A)

11. Which of the following statement prints helloexample test.txt?

A. print(“helloexample est.txt”)

B. print(“helloexample test.txt”)

C. print(“hello”example”test.txt”)

D.print(“hello”example “est.txt”)

Answer: (B)

12. The output of the following code.


A. 3

B. 0

C. 2


Answer: (C)

13. The output of the following code.


>>>str1[: : -1]

A. dlrowolleh

B. Hello

C. world


Answer: (A)

14. what is the output of the below program in python:


A. True

B. False

C. Error

D.Depends on machine

Answer: (B)

15. Which is not a feature of python language.

A. interpreted language

B. portable

C. high level language insensitive

Answer: (D)

16. Python is a …………object-oriented programming language.

A. Special purpose

B. General purpose

C. Medium level programming language

D.All of the mentioned above

Answer: (D)

17. Developer of python programming?

A. Denis Ritchie

B. Y.C Khenderakar

C. Tim Berner Lee

D.Guido van Rossum

Answer: (D)

18. Which are application areas of python programming?

A. Web development

B. Game development

C. Artificial intelligence and machine learning

D. All of the above

Answer: (D)

19. What is numeric types of data types?

A. int

B. Float

C. Complex

D.All of the above

Answer: (D)

20. What is the output for below code?

a = 2

b = 3




A. 23 23

B. 23 32

C. 32 32

D.None of above

Answer: (B)

21. List tuple dictionary are which types of datatypes?

A. Binary types

B. Boolean types

C. Sequence types

D.None of the above

Answer: (C)

22. Which keyword used in python language?

A. Finally

B. Lambda

C. While

D.All of above

Answer: (D)

23. Python Dictionary is used to store the data in.

A. Key value pair

B. Set value pair

C. Tuple value pair

D.None of the above

Answer: (A)

24. Which is invalid variable?

A. my_string_1

B. _

C. Foo


Answer: (D)

25. What is the output of given code?


A. 77

B. 7

C. 3


Answer: (B)

26. The python language developed in which?

A. 1995

B. 1989

C. 1972


Answer: (B)

27. Single line comment in python?

A. /

B. //

C. #


Answer: (C)

28. Conditional statements are also known as.

A. Decision-making

B. Array

C. List


Answer: (A)

29. Which is not used as Conditional statement in python?

A. switch

B. if…else

C. elif


Answer: (A)

30. which string represent the purpose for which the file is open?

A. “file name”

B. “file handle”

C. “file mode”

D.None of above

Answer: (C)

31. File handle is also know as.

A. File name

B. File variable

C. File object

D.none of above

Answer: (C)

32. which () finf the current position of file pointer with in file?

A. Seek()

B. Tell()

C. Read()

D.All of above

Answer: (B)

33. What is packing.

A. it is used for object serialization

B. It is used for object deserialization

C. All of the mentions

D.None of above

Answer: (A)

34. Eof standed for.

A. End of file

B. End of close

C. End of open

D.None of them

Answer: (A)

35. Input device.

A. Headphone

B. Gps

C. Microphone

D.All of above


36. To reped the list up to a spacify a number of iteam. Which operater required?

A. +

B. *

C. :



37. What type of data is?


A. array of tuple

B. tuples of list

C. List of tuple

D.invalid list


38. What will be print?

Import numpy as np

a = np. array([1,2,3,5,8])

b = np. array([0,3,4,2,1])

c = a+b

c = c*a


A. 7

B. 12

C. 10

D. 21

Answer: D

39. import numpy as np.

a = np.array([[1,2,3],[0,1,4]])


A. 1

B. 5

C. 6

D. 4

Answer: C

40. import numpy as np

a = np.array([1,2,3,5,8])


A. 0

B. 1

C. 2

D. 3

Answer: B

41. Numpy stands for.

A. Numbering Python

B. Number in Python

C. Numerical Python

D. Number Python

Answer: C

42. numpy is used along with package like?

A. Node Js

B. Matplotlib

C. Scipy

D. Both(B)and(C)

Answer: D

43. the sets the size of the buffer used in ufuncs?

A. bufsize(size)


C. set bufsize(size)

D. Size(size)

Answer: C

44. import numpy as np

dt=dt= np.dtype(‘i,4’)


A. int 32

B. int 64

C. int 128

D. int 16

45. if a dimension is given as _ in a reshaping operation, the other dimensions are Automate cally calculated.

A. Zero

B. One

C. Negative one

D. Infinite

Answer: (C)

46. Testing process first goal.

A. Testing

B. Analysis

C. Bug preventation

D. All of above

Answer: (C)

47. Sorting means.

A. Arranging the data

B. Processing the data

C. Calegrizing

D.None of above

Answer: (A)

48. Medium of comonunication.

A. Network

B. Compiler

C. Language

D.All of above

Answer: (C)

49. Bug means.

A. An insert in the program

B. Data input to the program

C. The error in the program

D.All of the above

Answer: (C)

50. Identifire maxium possible lenth.

A. 31 character

B. 63 character

C. 79 charater

D.None of the above

Answer: (C)

51. Which of the following is an invalid variable.

A. my_string_1

B. 5 st_string

C. Too


Answer: (B)

52. Which function do you use to read a string?

A. input(“enter a string”)

B. eval(input(“enter a string”))

C. enter(“enter a string”)

D.eval(enter(“enter a string”))

Answer: (A)

53. What will be the output of the following python code?

print(“abc DEF”.capitalize())

A. abc def


C. Abc def

D. Abc Def

Answer: (C)

54. What will the output of the following python code?

A. 0.33

B. 0.33%

C. 33.33%


Answer: (C)

55. Which are methods of list?

A. Append()

B. Extend()

C. Insert()

D.All of the above

Answer: (D)

56. Which keyword used in python language?

A. Finally

B. Lambda

C. While

D.All of above

Answer: (D)

57. The list.pop([i]) is used for removing the item at the given position in the list?

A. Yes

B. No

Answer: (A)

58. Which not a keyword in python language?

A. Val

B. Raise

C. Try


Answer: (A)

59. The output of below python program is.

X = [‘ab’,’cd’]


A. 1

B. 2

C. Error

D.Not specified

Answer: (C)

60. In python, the primary use of the tell() method is that:

A. Within the file, it tells the current position

B. Within the file, it tells the end position

C. It tells us if the file is opened

D.None of the above

Answer: (A)

61. What is output of below python code.

Str = [‘career’, ‘bodh’, ‘sansthan’] ‘ ‘join(str)

A. [‘careerbodhsansthan’]

B. ‘careerbodhsansthan’

C. [‘career bodh sansthan’]

D.‘career bodh sansthan’

Answer: (B)

62. ---------- is a connector showing the relationship between the representative shapes.

A. Line

B. Arrow

C. Process


Answer: (B)

63. ---------scans the rntire program and translates it as a whole into machine code.

A. Compiler

B. Interpreter

C. Debugger

D.None of above

Answer: (A)

64. Function header items present.

A. Function name

B. Parameter list

C. Return value

D.Both (a) and (b)

Answer: (D)

65. Function class defind.

A. Class

B. Function

C. Method


Answer: (C)

66. Recursive function.

A. Function other function call

B. A function which calls itself

C. Both(a) and (b)

D.None of these

Answer: (B)

67. Python id() use.

A. Id() return the size of object

B. Id() returns the idenity of the object

C. Both(a) and(b)

D.None of above

Answer: (B)

68. Function header correct.

A. def fun(a=2,b=3,c)

B. def fun(a=2,b,c=3)

C. def fun(a,b=2,c=3)

D.def fun(a,b,c=3,d)

Answer: (C)

69. how is a function declared in python?

A. def function function_name():

B. declared function function_name()

C. def function_name()

D.declared function_name()

Answer: (C)

70. packages modules import operator python used.

A. *

B. .

C. ->


Answer: (B)

71. Find the output of following python code.


print(n[-3: -8: -1]

A. 7,6,5,4,3,2

B. 7,6,5,4,3

C. 1,2,3,4,5,6,7


Answer: (A)

72. What is the output of following string slice.

S= ‘CPPbuzz


A. Pbuzz

B. buzzc

C. bu


Answer: (C)

73. Which variable has in vaild statement?

A. abc = 1,000,000

B. a b c = 1000 2000 3000

C. a,b,c = 1000,2000,3000

D.a_b_c = 1,000,000

Answer: (B)

74. which can be an identify ammag in python?

A. 1abc

B. &12a

C. _xy1


Answer: (C)

75. For loop is also know as.

A. Counting loop

B. Loop

C. Both(A)and(B)

D.None of above

Answer: (A)

76. The statement written after else is executed when codition is.

A. True

B. False

C. Not lested


Answera: (B)

77. In if statement if a>b and a>c, the statement return after else is execute when.

A. Both condition are true

B. Both condition are false

C. Any of conditiion false

D.Any of condition is true

78. What is the output of following python code

a =[13,56,17]



A. [13,56,17,87,45,67]

B. [13,56,17,87,[45,67]

C. [13,56,17,[87],45,67]


Answer: (C)

79. reshape() function is numpy array using python is ?

A.reshape (shape)

B.array. reshape (shape)

C.numpy. reshape (array)

D. reshape (array,shape)

Answer: D

80. How to convert numpy array to list?

A. array.list()

B. array. List

C. list. array

D. list (array)

Answer: (D)

81. Output of following code.

T1 = (1,2,4,3)

T2 = (1,2,3,4)


A. True

B. False

C. Error


Answer: (B)

82. The name of(+) string operator is.

A. Cocatenation

B. Relational

C. Replication


Answer: (A)

83. In python string can be enclosed in is.

A. Single quotes

B. Triple quotes

C. Double quotes

D.Any of these

Answer: (D)

84. The last list of function defination is.

A. exit

B. def

C. return

D. None of these

Answer: (C)

85. Which function give ASCII code of give ()

A. str()

B. chr()

C. ord()


Answer: (C)

86. To open a file c:\tkd.txt for reading by use.

A. infile=open(“c:\scores.txt”,’I’)

B. infile=open(“c:\\tkd.txt”,’r’)

C. infile=open(file=”c:\score.txt”,’r’)

D.None of above

Answer: (B)

87. This import * statement import all names in the module except these beginning width.

A. -

B. &

C. %


Answer: (A)

88. File write lines() syntax.

A. File write lines (sequence)

B. File object.write lines ()

C. File object. Write lines (sequence)

D.None of the mentions

Answer: (C)

89. Which () is defined in pickle module and use to write data object in binarry file.

A. Load()

B. Dump()

C. Write()

D.None of these

Answer: (B)

90. Group function,class,variable,saved as python program file (.py).

A. File

B. Module

C. Package

D.None of above

Answer: (B)

91. Which of the following is reffred to as top level segement of the python program.

A. _main_

B. _top_

C. _global_

D.None of these

Answer: (C)

92. What is the output of following code.

import numpy as np

a= np.array ([1,2,3,5,8])

array = ary+1


A. 3

B. 2

C. 5


Answer: (A)

93. Software mistake during coding are known as……

A. Error

B. Bugs

C. Failures


Answer: (B)

94. Python lambda function.

A. True

B. False

C. Lambda is a function in python but user can is it.

D.None of the above

Answer: (A)

95. Fill () function requeres 2 arguments minimum to pass in it.

A. True

B. False

C. Fill () does’nt belong to numpy

D.All of above

Answer: (A)

96. In which language is python written?

A. java

B. C++

C. C

D.None of above

Answer: (C)

97. Craeting ndarry. Which is the built in function in numpy.

A. np.array()


C. np.empty()

D.all of the above

Answer: (D)

98. what will be the output of the following python code

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


A. 4 3 2 1

B. 1 2 3 4

C. 2 3 4


Answer: (A)

99. The action performed by a_____structure must eventually cause the loop to terminate.

A. Sequence

B. Case

C. Repetition

D.All of above

Answer: (c)

100. The hierachy of operations is denoted as___

a) +,-


c) *,/

d)\ , Mod

A. a,b,c,d

B. b,d,c,a

C. d,a,c,b


Answer: (B)

244 views0 comments


bottom of page