Solved paper Programming and Problem Solving Through Python M3-R5 Set 2 | NIELIT O Level
What will be output for the following code ? import numpy as np
a = np.array([[1,2,3],[0,1,4],[11,22,33]])
print (a.size)
2. What will be the output after the following statements? a = 0
b = 3
while a + b < 8:
a += 1
print(a, end='')
(A) 0 1 2 3 4 (B) 1 2 3 4 5 6 (C) 1 2 3 4 5 (D) None of these
3. Raw data assigned to a variable is called as .
(A) variable (B) literal (C) identifier (D) comment
4. What is the purpose of zeros() function used in Numpy array ?
(A) To make a Matrix with all diagonal element 0
(B) To make a Matrix with first row 0
(C) To make a Matrix with all element 0
(D) None of the above
5. NumPY stands for?
(A) Numbering Python
(B) Number in Python
(C) Numerical Python
(D) Number for Python
6. What does the following code print ?
if 2 + 5 == 8:
print("TRUE") else:
print("FALSE") print("TRUE")
(A) TRUE (B) TRUE FALSE
(C) TRUE TRUE (D) FALSE TRUE
7. lstrip() method is used for :
(A) delete all the trailing characters
(B) delete all the leading characters
(C) delete all the leading and trailing characters
(D) delete upper case characters
8. What will be the output of the following? print((range(4)))
(A) 0,1,2,3 (B) [0,1,2,3] (C) range(0,4) (D) (0,1,2,3)
9. Which of the following variable declaration is incorrect ?
(A) a_=3 (B) _a=3 (C) a?=3 (D) All of these
10. In a flow chart, which of the following is used to test the condition ?
(A) Terminal (B) Process (C) Input/Output (D) Decision
11. What will be the output of the following code ? f=open("demo.txt","r")
print(f.tell())
(A) 1 (B) 2 (C) -1 (D) 0
12. Which of the following is the basic I/O connections in file ?
(A) Standard Input (B) Standard Output
(C) Standard Errors (D) All of the mentioned
13. Which function returns the strings ?
(A) readline( ) (B) read ( )
(C) Both of the above (D) None of the above
14. What will be the output of the following code ? f=open("demo.txt","w+")
f.write("Welcome to Python") f.seek(5)
a=f.read(5) print(a)
(A) Welco (B) me to
(C) Welcome to Python (D) e to
15. The syntax of seek() is: file_object.seek(offset [, reference_point]) What does the reference_point indicate?
(A) reference_point indicates the current position of the file object
(B) reference_point indicates the starting position of the file object
(C) reference_point indicates the ending position of the file object
(D) None of the above
16. Which one is not the attribute of a file?
(A) softspace (B) mode (C) closed (D) rename
17. The process of drawing a flowchart for an algorithm is called .
(A) Performance (B) Algorithmic Representation
(C) Evaluation (D) Flowcharting
18. Which of the function takes two arguments ?
(A) dump( ) (B) laod()
(C) Both of the above (D) None of the above
19. Suppose a list with name arr, contains 5 elements. You can get the 2nd element from the list using :
(A) arr[-2] (B) arr[2] (C) arr[-1] (D) arr[1]
20. What will be the output of the following expression ? a = 2
b = 8 print(a | b)
print(a >> 1)
(A) 10 0 (B) 10 2 (C) 2 2 (D) 10 1
21. What will be the output of the following ? import numpy as np
a = np.array([[1,2,3,4], [5,6,7,8], [9,10,11,12]])
print(a[2,2])
(A) 7 (B) 11 (C) 10 (D) 8
22. What is the output of the following code ? def add(a, b):
return a+5, b+5 result = add(3, 2) print(result)
(A) 15 (B) 8 (C) (8,7) (D) Error
23. Which of the following language is understood by computer ?
(A) Machine language (B) Assembly language
(C) High-level language (D) None of the above
24. What is the maximum possible length of an identifier ? (A) 16 (B) 32
(C) 64 (D) None of these above
25. What are the three different types of algorithm constructions ?
(A) Input/Output, Decision, Repeat (B) Input, Output, Process
(C) Loop, Input/Output, Process (D) Sequence, Selection, Repeat
26. Assume q= [3, 4, 5, 20, 5, 25, 1, 3], then what will be the items of q list after q.pop(1) ?
(A) [3, 4, 5, 20, 5, 25, 1, 3] (B) [1, 3, 3, 4, 5, 5, 20, 25]
(C) [3, 5, 20, 5, 25, 1, 3] (D) [1, 3, 4, 5, 20, 5, 25]
27. In which of the following data type, duplicate items are not allowed ?
(A) list (B) dictionary
(C) set (D) None of the above
28. What is the output of the following code? import numpy as np
a = np.array([1,2,3,5,8])
b = np.array([0,1,5,4,2]) c = a + b
c = c*a print (c[2])
(A) 6 (B) 24 (C) 0 (D) None of these
29. What is the output of the following code ? import numpy as np
a = np.array([[1,2,3]]) print(a.shape)
(A) (2, 3) (B) (3, 1) (C) (1, 3) (D) None of these
30. The process of finding errors in code is called as .
(A) Compiling (B) Running (C) Testing (D) Debugging
31. What is the output of the following code ? ms = ('A', 'D', 'H', 'U', 'N', 'I', 'C')
print(ms[1:4])
(A) ('D', 'H', 'U') (B) ('A', 'D', 'H', 'U', 'N', 'I', 'C')
(C) ('D', 'H', 'U', 'N', 'I', 'C') (D) None of these
32. What is the output of >>>‟2‟+‟3‟
(A) 2 3 (B) „2+3‟ (C) ‟23‟ (D) None of these
33. What will be the output of the following Python program ? def addItem(listParam):
listParam += [1]
mylist = [1, 2, 3, 4] addItem(mylist) print(len(mylist))
(A) 5 (B) 8 (C) 2 (D) 1
34. A detailed flowchart is known as :
(A) Micro (B) Union (C) Macro (D) Stack
35. Algorithms cannot be represented by .
(A) pseudo codes (B) syntax (C) flowcharts (D) programs
36. What will be the output of the following Python code? from math import *
floor(3.7)
(A) 3 (B) 4 (C) 3.0 (D) None of these
37. How many arguments a Python program can accept from the command line ?
(A) one (B) Two (C) Three (D) any
38. What is the output of the following ? print(int())
(A) Any random number (B) 1
(C) 0 (D) Error
39. What is the output of the following code ? a = set('dcma')
b = set('mlpc') print(a^b)
(A) {'d', 'c', 'm', 'a', 'm', 'l', 'p', 'c'} (B) {'m', 'l', 'p', 'c'} (C) {'d', 'c', 'm', 'a'} (D) None
40. What is the output of the following statement ? print ((2, 4) + (1, 5))
(A) (2 , 4), (4 , 5) (B) (3 , 9) (C) (2, 4, 1, 5) (D) Invalid Syntax
41. How is a function declared in Python ?
(A) def function function_name():
(B) declare function function_name():
(C) def function_name():
(D) declare function_name():
42. What will be the output of the following ? import sys
sys.stdout.write('Welcome\n') sys.stdout.write('All\n')
(A) Welcome All
(B) Welcome All
(C) Compilation Error
(D) Runtime Error
43. Which of the following is not a correct mode to open a file?
(A) ab (B) rw (C) a+ (D) r+
44. The syntax used to rename a file :
(A) os.rename(existing_name, new_name)
(B) fp.name = „new_name.txt‟
(C) os.rename(fp, new_name)
(D) os.set_name(existing_name, new_name)
45. If we open a file in write mode and file does not exists, which of the error will generate ?
(A) File Found Error (B) File Not Exist Error
(C) File Not Found Error (D) None of these
46. How many numbers will be printed by the following code ? def fun(a,b):
for x in range(a,b+1):
if x%3==0:
print(x, end=" ") fun(100,120)
(A) 7 (B) 8 (C) 6 (D) 9
47. What does the following code print? x = 'mohan'
for i in range(len(x)): x[i].upper()
print (x)
(A) mohan (B) MOHAN (C) Error (D) None of these
48. Which is the function to read the remaining lines of the file from a file object infile ?
(A) infile.read(2) (B) infile.read()
(C) infile.readlines() (D) infile.readline()
49. What will be the output of the following? import numpy as np
a = np.array([1,5,4,7,8]) a = a + 1
print(a[1])
(A) 4 (B) 5 (C) 6 (D) 7
50. What is the output of the following code? dict={"Joey":1,"Rachel":2}
dict.update({"Phoebe":2}) print(dict)
(A) {"Joey":1,"Rachel":2,"Phoebe":2} (B) {"Joey":1,"Rachel":2}
(C) {"Joey":1,"Phoebe":2} (D) Error
51. Testing is known as :
(A) A stage of all projects
(B) Finding broken code
(C) Evaluating deliverable to find errors
(D) None of the above
52. A process is expressed in a flowchart by .
(A) Rectangle (B) A circle (C) Parallelogram (D) A diamond
53. What is the output of below program ? def maximum(x, y):
if x > y:
return x elif x == y:
return 'The numbers are equal' else:
return y
print(maximum(2, 3))
(A) 2 (B) 3
(C) The numbers are equal (D) None of the options
54. What will be the output after the following statements? for i in range(1,6):
print(i, end='') if i == 3:
break
(A) 1 2 (B) 1 2 3 (C) 1 2 3 4 (D) 1 2 3 4 5
55. Which function is used to read all the characters?
(A) readall() (B) read()
(C) readcharacters() (D) readchar()
56. What is the output of >>>float(‟12.6‟)
(A) 12.6 (B) ‟12.6‟ (C) 12 (D) syntax error
57. What will be the output of the following ? import numpy as np print(np.maximum([2, 3, 4], [1, 5, 2]))
(A) [1 5 2] (B) [1 5 4] (C) [2 3 4] (D) [2 5 4]
58. Which of the following is false about “from …. import ……” form of import?
(A) The syntax is: from modulename import identifier
(B) This form of import does not import anything
(C) The namespace of imported module becomes part of importing module
(D) The identifiers in module are accessed directly as: identifier
59. A function used for writing data in the binary format :
(A) write (B) output (C) send (D) dump
60.What is the symbol used to represent start and stop of a flowchart ?
(A) oval (B) rectangle (C) arrow (D) diamond
61. What value does the following expression evaluate to ? print(5 + 8 * ((3* 5)-9) /10)
(A) 9.0 (B) 9.8 (C) 10 (D) 10.0
62. Operations to be repeated a certain number of times are done by .
(A) Selection (B) Sequential (C) Simple (D) Loop
63. Which part of the memory does the system store the parameter and local variables of a function call ?
(A) heap (B) stack
(C) Uninitialized data segment (D) None of the above
64. What will be the output of the following ? import numpy as np
a = np.array( [2, 3, 4, 5] ) b = np.arange(4) print(a+b)
(A) [2 3 4 5] (B) [3 4 5 6] (C) [1 2 3 4] (D) [2 4 6 8]
65. What is the output of below program ?
def say(message, times = 1): print(message * times)
say('Hello')
say('World', 5)
(A) Hello WorldWorldWorldWorldWorld
(B) Hello World 5
(C) Hello World,World,World,World,World
(D) Hello HelloHelloHelloHelloHello
66. The way for solving a problem step by step is known as .
(A) Design (B) Planning (C) Algorithm (D) Execution
67. What is the output ?
def calc(x):
r=2*x**2
return r
print(calc(5))
(A) Error (B) 50 (C) 100 (D) 20
68. What will be the output of the following Python code ? def printMax(a, b):
if a > b:
print(a, 'is maximum') elif a == b:
print(a, 'is equal to', b) else:
print(b, 'is maximum') printMax(3, 4)
(A) 3 (B) 4
(C) 4 is maximum (D) None of the mentioned
69. What value does the following expression evaluate to ? x = 5
while x < 10:
print(x, end='')
(A) Closed loop (B) One time loop
(C) Infinite loop (D) Evergreen loop
70. What is the output of the following code ?
x = 50
def func (x) :
x = 2 func (x)
print ('x is now', x)
(A) x is now 50 (B) x is now 2 (C) x is now 100 (D) Error
71. What is the output of the following code ? def disp(*arg):
for i in arg:
print(i) disp(name="Rajat", age="20")
(A) TypeError (B) Rajat 20
(C) Name age (D) None of these
72. Which of the following executes the programming code line by line?
(A) Compiler (B) Interpreter (C) Executer (D) Translator
73. What is the return type of following function ? def func1():
return „mnp‟,22
(A) List (B) dictionary (C) string (D) tuple
74. What is the output of the following code ? def fun(a, b=6):
a=a+b print(a) fun(5, 4)
(A) 11 (B) 9 (C) 5 (D) 4
75. Which of the following is an invalid mode ?
(A) a (B) ar+ (C) r+ (D) w
76. What will be the output of the following Python code? from math import pow
print(math.pow(2,3))
(A) Nothing is printed
(B) 8
(C) Error, method pow doesn‟t exist in math module
(D) Error, the statement should be: print(pow(2, 3))
77. What will be the output of the following expression ? x = 4
print(x<<2)
(A) 4 (B) 16 (C) 6 (D) 2
78. What is the output of the following code ? import numpy as np
y = np.array([[11, 12, 13, 14], [32, 33, 34, 35]])
print(y.ndim)
(A) 1 (B) 2 (C) 3 (D) 0
79. A computer programme that manages and controls a computer's activity :
(A) Interpreter (B) Modem
(C) Compiler (D) Operating system
80. What will be the output of the following expression ? print (7//2)
print (-7//2)
(A) 3 -3 (B) 4 -4 (C) 3 -4 (D) 3 3
81. What will be the output of the following pseudo-code ? Integer a
Set a = 4 do
print a + 2 a = a- 1
while (a not equals 0) end while
(A) 6 6 6 6 (B) 6 5 4 3 (C) 6 7 8 9 (D) 6 8 10 12
82. What is the output of the following code ? a = {1: "A", 2: "B", 3: "C"}
b = {4: "D", 5: "E"}
a.update(b) print(a)
(A) {1: 'A', 2: 'B', 3: 'C'} (B) {1: 'A', 2: 'B', 3: 'C', 4: 'D', 5: 'E'}
(C) Error (D) {4: 'D', 5: 'E'}
83. An algorithm that calls itself directly or indirectly is called as .
(A) Sub Function (B) Recursion
(C) Reverse Polish Notation (D) Traversal Algorithm
84. Which module is to be imported for using randint( ) function ?
(A) random (B) randrange (C) randomrange (D) rand
85. Function defined to achieve some task as per the programmer‟s requirement is called a ____.
(A) user defined function (B) library function
(C) built in functions (D) All of the above.
86. Which of the following is not a keyword ?
(A) eval (B) nonlocal (C) assert (D) finally
87. What will be the output of the following pseudocode, where ĘŚ represent XOR operation ? Integer a, b, c
Set b = 4, a = 3 c = a ^ b
Print c
(A) 4 (B) 3 (C) 5 (D) 7
88. Which statement is correct to import all modules from the package ?
(A) from package import all (B) from package import *
(C) from package include all (D) from package include *
89. Flowchart and algorithms are used for .
(A) Better programming (B) easy testing and debugging
(C) Efficient Coding (D) All
90. Which of the following is not a valid identifier?
(A) student (B) s12 (C) 123 (D) _123
91. What will be the output of the following ? def iq(a,b):
if(a==0): return b
else:
return iq(a-1,a+b) print(iq(3,6))
(A) 9 (B) 10 (C) 11 (D) 12
92. Which symbol is used to write single line comment ?
(A) * (B) # (C) / (D) ?
93. A Python module is a file with the file extension that contains valid Python code.
(A) .pym (B) .pymodule (C) .module (D) .py
94. What will following code segment print ? a = True
b = False c = False
if not a or b:
print(1)
elif not a or not b and c: print (2)
elif not a or b or not b and a: print (3)
else:
print (4)
(A) 1 (B) 3 (C) 2 (D) 4
95. What will be the output after the following statements? x = 2
if x < 5:
print(x) else:
pass
(A) 2 3 4 (B) 1 2 3 4 (C) 2 (D) None of these
96. What will be the output of the following pseudocode ?
Integer a, b Set a = 9, b = 5 a = a mod (a - 3) b = b mod (b – 3)
Print a + b
(A) 4 (B) 5 (C) 9 (D) 8
97. Which of the following symbol is used for input and output operations in a flow chart ?
(A) Rectangle (B) Parallelogram (C) Circle (D) Diamond
98. immediately terminates the current loop iteration.
(A) break (B) pass (C) continue (D) None of these
99. How can we create an empty list in Python ?
(A) list=() (B) list.null (C) null.list (D) list=[ ]
100. Which one of the following is a
mutable data type ?
(A) set (B) tuple (C) String (D) None of these
No comments:
Post a Comment