Subscribe Us

Merit-Based Scholarship And Fee Discount

Advertisement

computer knowledge benifits

o level python set 2 previous mcqs

o level python mcqs previous question O Level Python MCQs Previous Questions | NIELIT O Level Python MCQ Practice
1)which of the following Functions return a list Containing all words of the string?
A))Find()
B) Index()
C) Partition()
D) Split()
(D)Split()


2) in a while loop, how can you prevent it from becoming an infinite loop?'
A)Use the break statement at the end of the loop body
B) Include an else statement wise a termination condition
C)Ensure that the loop condition becomes false at some point.
D) Add a continue statement at'], answer:C
(C) 3 4


3)In which part of the memory does the system stores the parameter and local variables of function call?'
A) Heap'
B) Stack'
C) Data segment
D) Heap
system


4)What is the time complexity of a recurs function with multiple recursive calls?',
A) O(1)
B) O
C) O(log n)
D)It depends on the specific problem and number of recursive calls.'],
(D)


5) What will be the output of the following Python code? Def f(x): range(5): yield I; g=f(8); print(li) ?',
A) [0,1,2,3,4]'
B) [1,2,3,4,5,6,7,8]'
C) [1,2,3,4,5]
D) (D) [0,1,2,3,4,5,6,7],
A


6)Which module in Python can be used for expressions?'
A) Re'
B) Regex
C)Express
D) Pattern.
A


7) 'Which method is used to rename a file?'
A)Fname()
B) Rename()
C)Flush()
D) Flush()
C) .(B) FALSE


8)Which of the following operators is the correct for power(ab)?',
A) a^b'
B) a^^b'
C) a^*b
D) (D) None of the options
D


9) What are the arguments known as passed to a function in a correct post?',
A) Required arguments
B) Keyword arguments
C) Default arguments
D) Variable-length arguments.'],
B


10) What is the term used to describe the process of drawing a flowchart for an algorithm?
A) Algorithmic representation'
B) Flowchart mapping
C)Flowchart design
D)Algorithmic charting.']
C) D


11File name with.py extension which makes package importable is known as____.
A) __main__
B) __import__
C) __ from__
D) __init__.
D


12)What is the purpose of a function in programming?',
A) To store multiple values in a single variable
B) To make decision based on conditions
C) To execute a block of code only once
D)To perform a specific task or operation.
D


13) Which amongst the following function headers is correct?'
A)Def fun(p, q = 2, r = 3)
B) Def fun(p = 2, q = 3, r)
C)Def fun(p = 2, q, r = 3)
D) Def fun(p, q, r = 3, s)
A


14)Which amongst the following function headers is correct?.
A) (A) Def fun(p, q = 2, r = 3)',
B)(B) Def fun(p = 2, q = 3, r)
C) (C) Def fun(p = 2, q, r = 3)
D) (D) Def fun(p, q, r = 3, s)
.A


15) What are the values of the following 2**(3**2) (2**3)**2 2**3**2 .',
A) 512, 64, 512',
B) 512, 64, 512',
C) 512, 64, 512',
D) 64, 512, 64.
.A


16) Which of the following is the correct way the sum of all elements in a NumPy array?.
A)Sum(arr)
B) arr.sum()
C)np.sum(arr)
D) All of the above
D


17) What is the output of print(math.trunc(‘5.2’))?.
A) 5 '
B) 5.0
C) error
D)None of the above
(.C


18What will be the output of the following Python of def func(a, b=5, c=10) Print(‘a is’,a, ‘and b is’, b, ‘and c is’, c) func(3,7) func(25,c = 24) func(c = 50, a = 100)
A) (A) a is 7 and b is 3 and c is 10 a is 25 and b is 5 and c is 24 a is 5 and b is 100 and c is 50
B)(B) a is 3 and b is 7 and c is 10 a is 5 and b is 25 and c is 24 a is 50 and b is 100 and c is 5
C) (C)a is 3 and b is 7 and c is 10 a is 25 and b is 5 and c is 24 a is 100 and b is 5 and c is 50
D) (D) a is 3 and b is 7 and c is 10 a is 25 and b is 5 and c is 24 a is 100 and b is 5 and c is 50 .'],
.B


19)How do you close an open file in python?.',
A) close_file(file)'
B) file.close()
C) close(file)'
D) end_file(file).
.B


20)Which string function is used to check characters in a string are letters or digital?.'
A) isalpha()
B) isdigit()
C) isalphadigit()
D) isalnum().
..D


21) The following is displayed by a print function of function calls that result in this output. tom dick harry
A) (A)print(“”tom/ndick/nharry””)
B) (B)print(“”tom/ndick/nharry””)
C) (C)print(‘tom/ndick/nharry’)
D) (D) (D) print(tomdick)')
.A


22)What will be the output? For I in range(3): If i == 1: break else: print(“No Break”)
A) No Break
B) Break
C) No output
D) Syntax Error
A


23)What will be the output of the for fo = open(“foo.txt”, “wb”) print “Name of the file:”, fo.name fo.flush() fo.close() ',
A) Compilation Error
B) No Output
C) Compilation Error
D) No Outputbr>
.No Output


24)What is the output of np.linsapce(0,1, num=5)'
A) [0,1,2,3,4,5]'
B) [0,0.25,0.5,0.75,1]'
C) [0,0.2,0.4,0.6,0.8]',
D) [0,0.2,0.4,0.6,0.8,1]'],
..[0,0.2,0.4,0.6,0.8,1]'],


25)NumPy is often used along with packages like .',
A) Matplotlib
B) Node.js'
C) Java'
D) C++
.(A) Matplotlib'


26)How do you change the file post an offset value from the start?.'
A) fp.seek(offset, 0)',
B) fp.seek(offset, 1)
C) fp.seek(offset, 2)
D) fp.seek(offset, 2)
..(A) fp.seek(offset


27)______method is used to read a specified number of bytes (n) of data from a data file.',
A) read([bytes])',
B) read(n)
C) (C) read([b])
D) readline([n])']
.(B) read(n)


28)Which of the following is the use of id() function',
A) It returns the object that does not have unique'
B) Id returns the identity of the object
C) It allocates identity to an object
D) Id returns the identity of the class'],
..' (B) Id returns the identity of the object'


29)Which algorithm is used to search an element sorted lis
A) Linear
B) Binary'
C) Exponential',
D) Jump'],
..(B) Binary',


30)'Assumping A as 18, which of the following is the displayed by the instruction, print(A<<2)',
A) 18',
B) 72 ',
C) 36 '
D) 54.'],
.(B) 72


31)What is the purpose of the “docstring” in a function?',
A) To provide documentation the function',
B) To specify the data type of the return value'
C) To hide the function from being exected'
D) To define default arguments'],
.(A) To provide documentation the function',


32)'Which command is used to remove dirl?',
A) Os.remove(“dirl”)',
B) Os.delete(“dirl”)',)
C) Os.rmdir(“dirl”)'
D) None of the above']
.(C) Os.rmdir(“dirl”)'


33)'The output of the following code print(chr(97)))) is?.',
A)
B)
C) Error '
D) 97.'],
.(A) a',


34)What is the output of C program with int main() { Int a = 0, printi(“AJAY”); return 1; printi(“VIJAY”); return 1; }
A)A. AJAY VIJAY',
B) B. VIJAY '
C)B. VIJAY'
D) ' AJAY VIJAY'],
.B. VIJAY


35)'Which of the following plug-in can’t be embedded by element?', A) (A) Map',,
B) (B) Flash players',
C)(C) Readers'
D) (D) Java applets'],
.(A) Map',


36)'What will be the output of the following int main() { int a =5, while(a=123) { printf(“RABBIT/n”): } Printf(“GREEN”): Return 0; } ',
A) (A) RABBIT is printed unlimited number of
B) (B) RABBIT GREEN '
C) (C) Compiler error''
D) (D) GREEN'],
.(D) GREEN'],


37)'What action does the following statements performs? Serial printIn(“for (int i=0; i<6; i +=2)”): { For (int i=0; i<6; i +=2) { Serial.printIn(i); } } ',
A) A. 0,2,4,
B) B. 0,1,2',
C) (c)0,1,2', '
D) D.0,1'],
.A. 0,2,4',


38)'Predict the output of the following code if use sensor? Int op = 7; Int isBarrier = HIGH; Void setup() { pinMode(op, INPUT); Serial.begin(9600); } Void loop() { isBarrier = digitalRead(op); if (isBarrier == LOW { Serial.print(“1+”); } Else { Serial.print(“clear+”); } Delay(100); }
A) clear + clear +1 + 1
B) Clear + clear + clear + clear',
C) Clear + clear + clear + clear
D) clear + clear +1 + 1'],
.Clear + clear + clear + clear'


39)'Which command is used to remove dir1?',
A) os.remove(“dir1”)_'
B) os.delete(“dir1”)
C) os.rmdir(“dir1”),'
D) None of the above '],
.(C) os.rmdir(“dir1”),

40)'Which method is used to rename a file?',
A) fname()'
B) rename()',
C) flush()
D) filename()'],
.(B) rename()


41)'What will be the output of the following Python code? def f(x): range(5): yield I; g=f(8); print(li);',
A) [0,1,2,3,4]
B) [1,2,3,4,5,6,7,8] ',,
C) [1,2,3,4,5]'
D) [0,1,2,3,4,5,6,7]'],
.(A) [0,1,2,3,4]


42)'What is the output of print(math.trunc(‘5.2’))?',
A) 5'
B) 5.0',
C) error
D) error'], '],
.(C) error'],


43)'Which of the following is the correct way of the sum of all elements in a NumPy array?',
A) sum(arr)'
B) arr.sum(),
C) np.sum(arr)
D) All of the above '],
.(D) All of the above '],


44)'What will be the output of this program ? For i in range(3): If i == 1: break else: print(“No break”)
A) No Break''
B) Break ',,
C) No output
D) Syntax Error.],
.(A) No Break'


45)''Which string function is used to check the characters in a string are letters or digital?',
A) isalpha()
B) isdigit()',
C) isalphadigit()
D) isalnum()'],
.(D) isalnum()'],


46)Which of the following is the use of id() function?',
A) It returns the object that does not have unique'
B) Id returns the identity of the object',,
C) It allocates identity to an object
D) Id returns the identity of the class'],
.(B) Id returns the identity of the object'


40)What action does the following statements performs? Serial.printIn( “for (int i=0; i<6; i +=2)”); { for (int i=0; i<6 ; i +=2) { Serial.printIn(i); } }
A) 0,2,4 '
B) 0,1,2',,
C) isalphadigit(
D) isalnum()'],
.(D) isalnum()'],


48)''Which string function is used to check the characters in a string are letters or digital?',
A) 0,2,4
B) 0,1,2',
C) isalphadigit()
D) isalnum()'], '],
.(D) isalnum()'],

49)'Which string function is used to check the characters in a string are letters or digital?',
A) isalpha()'
B) isdigit(),
C) 0,1,2
D) 0,1 '],
.(A) isalpha()


50)'What happens if a user clicks “Cancel” in a prompt() dialogue?',
A) Returns an empty string'
B) Returns null '
C) Returns undefined
D) Throws an error '],
.(B) Returns null


51)Choose a right C Statement.',
A) Loops or Repetition block executes a group of statements repeatedly',
B) Loop is usually executed as long as a condition is met,
C)Loops usually take advantage of Loop Counter ')
D) All of the above'],
.(A) Loops or Repetition block executes a group of statements repeatedly'


53)'Which of the following is used to concatenation two strings in ‘C’ language?',
A) Concat()',
B) Strcat(),
C) Merge() '
D) Join()'],

.(B) Strcat()'


54)''How to run two variables x and y in for loop simultaneously?',
A) for(x=0; x B) for(x=0; x C) for(y=0; y D) for(x=0;x
. B. for(x=0,y=0;x

55)''How many errors are in the code: Int i=10; void setup() { pinMode(I,OUTPUT): digitalwrite(HIGH); } Void loop() { //Do Nothing. }
A) 1,
B) 2
C)3 '
D) 4],
.(B) 3'


56)'How to run two variables x and y in for loop simultaneously?',
A) for(x=0; x B) for(x=0,y=0;x C) Both for(x=0;x D) D. for(x=0;x
.(B)for(x=0,y=0;x

57)' What will be the output of the following code? { Int x = 5*6/2 +8; Printf(“%d”,x); return 0; } ',
A)20,
B) 22',
C) 23
D) 12'],
.'C. 23


58)'Which of the following functions return a value?',
A) Setup-ADC()',',
B) read-adc()'
C) set¬_adc_ports () '
D) set¬_adc_channel()'],
.(B) Strcat()'


59)'What would the following code output? #define X 10; void setup(){ X=0; Serial.begin(9600); Serial.print(X); } void loop(){ //Do nothing… ',
A) Error,
B) 0xa'
C) 0xAB
D) 0'], ],
.(A) Error','


60)'In the C language, the constant is defined_____',
A) Before main',
B) After main'
C) Anywhere, but starting on a new line. ''
D) None of these'],
.(C) Anywhere, but starting on a new line.


61)'What is the purpose of a constant in’C’ language?',
A) To store input from the user ',
B) To store changing values'
C) To store intermediate calculations results'
D) To store fixed values that cannot be changed'],
.(D) To store fixed values that cannot be changed'],

62)' Choose the correct option for indexing of the given code: Int main () { Int xyz(8); Return 0; } ',
A)0,7
B)B. 0,8',,
C) C. -1,7 '
D)D. -1,7'],
(A).,7


63)'Using NumPy, a developer can perform which of the following operations?',
A)Mathematical and logical operations on arrays'
B)Fourier transforms and routns for shape manipulation
C)Operations related to linear algebra
D) All of the above '],
.(D) All of the above '],


64)'Which of the following is the output displayed by the Python instruction, print(‘Python’.endswith(‘n’))?',
A) Python'
B) False'
C) True'
D) n'],
.(C) True


65)'In context of Python variables, analyze the correctness of following statements: (S1) A variable name can only contain alpha-numeric characeters and underscores, (S2) A variable name cannot be any of the Python keywords',
A) both (S1) and (S2) are true ,
B) (S1) is false whereas(S2) is true',
C) (S1) is true whereas (S2) is false '
D) Both (S1) and (S2) are false '],
.(A) both (S1) and (S2) are true ''


66)'Finding and solving errors of the source code is _______.',
A) Decoding',
B) Desk checking',,
C) Debugging '
D) Testing'],
.(C) Debugging


67)Which of the following option is the correct statement to read and display the first 10 characters of a text file “doc.txt”',
A) F=open (‘doc.txt’): print(F.load(10))',
B) F=open (‘doc.txt’): print(F.dump(10))',
C)F=open (‘doc.txt’): print(F.read(10))
D) F=open (‘doc.txt’): print(F.write(10))'],
(C).F=open (‘doc.txt’): print(F.read(10)) '


68)''Which NumPy function is used to calculate the standard deviation of an array?',
A) np.std()'',
B) np.var(),
C) np.mean() '
D) np.median()'],
.(A) np.std()'


69)Which scope in the LEGB rule has the highest priority when resolving a variable name??',
A) Local',
B) Enclosing',,
C) Global ''
D) Built-in'],
.(D) Built-in'], '

70)'Purpose of the break statement in Python is_____.',
A) '(A) To skip the current iteration and move to the next one in a loop,
B) (B) To exit the current loop and continue with the next statement after the loop'
C) (C) To terminate the entire program ''
D) (D) To print a message to the console'],
(B) To exit the current loop and continue with the next statement after the loop',


71)'What is the output of the following code? Import numpy as np A = np.array([[1,2], [3,4]]) Print(a.ndim) ',
A) A. 0 '',
B)B. 1',
C) 'C. 2'
D) D. 3']
. C. 3'],

72)'What will be the output of the following Python code? def f(p, q, r): global S p = 10 q = 20 r = 30 s = 40 print(p, q, r, s) p, q, r, s = 1, 2, 3, 4 f(5, 10, 15) ',(D) Join()
A)(A) 1 2 3 4',,
B)(B) 5 10 15 4'
C) (B) 5 10 15 4
D)(A) 1 2 3 4'],
(B) 5 10 15 4',

73)'Which of the following is not a benefit of using NumPy arrays over Python lists?',
A(A) NumPy arrays support mathematical operations on entire arrays.',
B)(B) NumPy arrays are more memory-efficient'
C) (C) NumPy arrays provide a convenient way to perform element – wise operations. '
D) (D) NumPy arrays can store elements of multiple data types'],
.(D) NumPy arrays can store elements of multiple data types'],

74)'Which function is used to add an element (5) in the list1?',
A) (A) list1.sum(5)',
B)(B) list1.add(5)'
C) (C) list1.append(5)'
D) (D) list1.addelement5)'],
.(C) list1.append(5)
75)What is the output of the following code snippet: Int a = 10; Int b = 20; Serial.println(a < b ? a : b):
A) (A) 10
B)(A) 10
C)(C) Error
D) (D) 0 ],
.(A) 10 '

76)'What will be the output of the following Python code? min = (lambda x, y,x if x < y,else y) min(101 *99, 102*98
A)(A) 9997
B)(B) 9999'
C) (C) 9996
D) (D) 9998'],
.(C) 9996

77)'What are keyword arguments in functions?'
A) '(A) Arguments that are used as default values',
B(B) Arguments that are passed by reference ',
C) Arguments that are not allowed in function parameters'
D) (D) Arguments that are passed by using keywords instead of position'],
(D) Arguments that are passed by using keywords instead of position'],

78)'Suppose a user wants to print the second value of an array, which has 5 elements. What will be the syntax of the second value of the array?'
A)(A) array[1]',,
B)(B) array[0]
C) (C) array[-1]'
D) (D) array[2]'],
.(A) array[1]',

79)'What will be the output of the following Python code?' a = (1 “A”,2 “B”,3 “C”) b = (4 “D”,5 “E”) print(a)
A) '(A) (1, ‘A’, 2 ‘B’, 3 ‘C’)',,
B)(B) (1, ‘A’, 2 ‘B’, 3 ‘C’)'
C) (C) (1, ‘A’, 2 ‘B’, 3 ‘C’)',
D) (D) (1, ‘A’, 2 ‘B’, 3 ‘C’)'],
(D) (1, ‘A’, 2 ‘B’, 3 ‘C’)'],

80)'What is the output of the following code? print(bool(0), bool(2.15), bool(2.0+Ij))'
A) (A) True True False True',
B)(B) True False False True '
C) (C) False True False True'
D) (D) False True True True '],
.(D) False True True True '],

81)'What is the purpose of the strip() function in Python?'
A) (A) Removes leading and trailing spaces from a string
B)(B) Converts a string to uppercase ',
C) Searches for a substring in a string
D) (D) Splits a string into a list '],
(A) Removes leading and trailing spaces from a string

82)'What type of data structures are used for data manipulation in Pandas?'
A) '(A) List and DataFrames',
B)(B) Set and Dataframes ''
C) (C) Series and DataFrames,
D) (D) Set and series'], ,
'(A) List and DataFrames'

83)'Which of the following methods is used to sort a list in place in ascending order?'
A) '(A) Sort()'
B)(B) Sorted()
C) (C) Arrange()'
D) (D) Order()'],
.(A) Sort()

84)'Which of the following slicing operations will reverse the string s = “abcdef”?'
A)(A) S[::-1]',
B)(B) S[-1:0]
C)(C) S[0:-1:-1],
D) (D) S[-1:]'],
.(A) S[::-1]'

85)'What will be the output of the following Python code? def maximum(x, y) d x > y return x elif x == y return The numbers are equal else; 'return y print/maximum((2,3)
A)'(A) 2
B)(B) The numbers are
C)'3,'
D) (D) None of the above ,
.(D) None of the above ,

86)A module, ABC is imported in current namespace as: import ABC. Which of the following is correct approach to call the function f1() of module, ABC into current namespace?'
A) (A) F1(),
B)(B) ABC.f1()'
C) (C) ABC:f1()
D) (D) F1().ABC'],
.(B) ABC.f1()

87)'Let us suppose you have written a python program where you important numpy as up and written an instruction print(up.power(up.array[10,100,1000]), 2)), which of the following is the output of this program?'
A) (A) [10,100,1000]'
B)((B) [100,10000,1000000] '
C) (C) [1,10,100],
D) [10,100,1000 2]'],
.(B) [100,10000,1000000] '

88)'The following python program can work with______ parameter. def f(x): def [1(*args, **kwargs) print(“Python”) return x(*args, **kwargs) return []
A) (A) any number of
B)(B) 0', '
C) (C) 1,
D) (D) 2'],
.(C) 1,

89)'What is the output of the following code snippet? My_string? “hello, world!”; print(my_string[-6;-1])'
A) (A) World'
B) (B) world ''
C) (C) Worl,
D) (D) Error'],
.(D) Error'],

90)'Which of the following is NOT a valid function parameter type in Python?'
A) (A) Integer',
B)(B) Boolean''
C) (C) Float
D) (D) List '],
.(D) List '],

91)To update the datatype from default to integer using NumPy, apply______.'
A) (A) dtype=np.int64',
B)(B) dtype=np.num64' '
C)(C) dtype=np.float64
D) dtype=np.real64'],
.(A) dtype=np.int64'

92)A shape that can represent two different conditions in a flowchart is ________.'
A) (A) Rectangle',
B)(B) Diamond ''
C)(C) Circle,
D) (D) Parallelogram'],
.(B) Diamond '

93)What will be output for the following code? Import numpy as np a = np array([[1,2,3];[0,1,4]]) b = np zeros((2,3], dtype=np int16 c = np ones((2,3), dtype=np int16 d = a + b + c print (d[1,2] )
A) (A) 5',
B)((B) 7 '
C)(C) 3
D) (D) 4'],
.(A) 5

94.Names that live in a module are called its:'
A) (A) Objects',
B)(B) Attribute''
C)(C) Properties,
D) (D) None of the above '],
.(B) Attribute'

95)What will be the output of the following Python code? Import sys sys stdout.write(‘ Hello\n’) sys stdout.write(‘Python\n’)
A) Compilation Error',
B)(B)B) Runtime' '
C)(C) Python,
D) D) Hello Python'],
. D) Hello Python'],

96) In a package namedpack, first.py and second.py are two_______.'
A) (A) Packages',,
B)(B) Functions ' '
C)Modules
D)Directions'],
(C) Modules,

97)Let us consider a string object X as “Python is a programming language”. Which of the following will display the output as “Python Is A Programming Language”.'
A)(A) Print(x.ucase()),
B)(B) Print.(x.uppercase())'
C)(C) Print(x.upper())
D) Print(x.title())'],
.Print(x.title())'],

98)Which amongst the following is not a logical operator in Python?'
A) 'and'
B) Comment ' '
C) A line that is indented less than the previous line ,
D) A comment'],
.(C) A line that is indented less than the previous line ,'

99)'What will be the output of the following Python code? Elements=[0,1,2] Def incr(x) Return x+1 Print(list(map(elements incr)))
A) '(A) Error'
B)(B) [1,2,3] '
C)(C) [0,1,2],
D)D) None of the
(A) Comment '
. (B) [1,2,3]'

100)Which of the following operations can be performed on both lists and tuples?'
A) (A) Appending elements',
B)(B) Removing elements '
C)(C) Modifying elements,'
D) (D) Slicing'],
(C) Modifying elements,

Post a Comment

0 Comments