Font size
WorksheetsPython Test
Total questions: 80
Worksheet time: 40mins
In which of the following, data is stored permanently ?
Variable
File
Both of the above
None of the above
NumPy stands for :
Numbering Python
Number In Python
Numerical Python
None of the above
Which function returns the current position of file pointer?
get()
tell()
seek()
cur()
What does readlines() method return?
Dictionary
String
Tuple
List
Which of the following will read entire content of file (file object ‘f’) ?
f.reads( )
f.read( )
f.read(all)
f.read( * )
In which software development phase quality of software is documented?
Testing
Delivery
Idea
Development
Python is written in __________.
Java
C
PHP
All of the above
Recursive function is __________.
A function that calls itself
A function that calls other functions
Both (A) and (B)
None of the above
The connector symbol for flowchart is __________.
Circle
Parallelogram
Diamond
All the above
To use a module in another module, you must import it using an ________ statement.
import
include
both (A) and (B)
none of the above
f.read(5) will read __________ from a file (file object ‘f’).
5 characters
5 words
5 lines
None of the above
The brain of a computer system is __________.
RAM
CPU
ROM
Control Unit
Which of the following declarations is incorrect?
1x = 2
x = 3
__xyz__ = 5
None of these
In python language, which of the following operators is the correct option for raising k to the power l ?
k ^ l
k**l
k ^ ^ l
k ^ *l
Which symbol is used as a flowline to connect two blocks in a flow chart ?
arrow
circle
box
parallelogram
A _______ statement is used when a statement is required syntactically but you do not want any code to execute.
break
pass
continue
none of these
What will be the output of the following ? print(sum(1,2,3))
Error
6
1
3
For performing the addition of two numbers, which of the following symbol in a flow chart are used ?
Control flow
Terminal
Processing
Decision
Which of the following is not an advantage of using modules ?
Provides a means of reuse of program code
Provides a means of dividing up tasks
Provides a means of reducing the size of the program
Provides a means of testing individual parts of the program
Which mode creates a new file if the file does not exist?
write mode
read mode
append mode
Both (A) and (C)
Kite/diamond symbol in flow chart is used for __________.
Execution
Decision
Statement
All of the above
What will be the output of the following Python code ? len([“hello”,2, 4, 6])
Error
6
4
3
A _____________ stores information in the form of a stream of ASCII or unicode characters i.e. human readable.
Text file
Binary file
Both (A) and (B)
None of these
Which function is used to add an element (5) in the list1 ?
list1.sum(5)
list1.append(5)
list1.addelement(5)
Which of the following functions is used to move the file pointer to a specific position in a file?
getpos( )
move( )
position( )
seek( )
What is the use of the zeros() function in Numpy array in python ?
To make a Matrix with all element 0
To make a Matrix with all diagonal element 0
To make a Matrix with first row 0
None of the above
Flow charts and Algorithms are used for __________.
Better Programming
Optimized Coding
Systematic testing
All the above
What is the main purpose of using pseudocode in programming?
Planning and organizing tasks
Expressing algorithms in a language-independent manner
Data analysis and visualization
Debugging and testing software
The contents inside the 'for loop' are separated by:
colon
comma
semicolon
hyphen
What will be the output of the following Python code ?
tuple1=(5,1,7,6,2)
tuple1.pop(2)
print(tuple1)
(5,1,6,2)
(5,1,7,6)
(5,1,7,6,2)
Error
What is the output of the following code snippet? print([i.lower() for i in 'HELLO'])
hello
['h', 'e', 'l', 'l', 'o']
hel
HELLO
What will be the output of the following Python code? example = “helle” example.rfind(“e”)
1
2
4
5
Choose the correct option with respect to Python.
Both tuples and lists are immutable
Tuples are immutable while lists are mutable
Both tuples and lists are mutable
Tuples are mutable while lists are immutable
Which of the following is not a control structure ?
Loop
Process
Decision
None of these
What type of data is : arr = [(1, 1), (2, 2), (3, 3)] ?
List of tuples
Tuples of lists
Array of tuples
Invalid type
What will be the output of the following Python code ? example = “hello” example.rfind(“e”)
1
2
4
5
The connector symbol for flowchart is ________.
Circle
Parallelogram
Diamond
All the above
What is ‘f’ in the following statement ? f=open("Data.txt", "r")
File Name
File Handle
Mode of file
File Handling
What is the output of following code? import numpy as np
a = np.array([[1,2,3],[4,5,6]])
print(a.shape)
(2, 3)
(3, 2)
(1, 1)
None of these
What is the value of the following Python code ? >>>print(36 / 4)
9
4
9.0
4.0
What will be the output of following ?
Y=[2,5J,6] Y.sort()
[2,6,5J]
[5J,2,6]
Error
[6,5J,2]
Which of the following symbols is used to represent output in a flow chart?
Square
Circle
Parallelogram
Triangle
What is the output of the following code ?
def s(n1):
print(n1)
n1 = n1 +2
n2=4
s(n2)
print(n2)
6 4
4 6
4 4
6 6
Which statement is correct to import all modules from the package ?
from package import all
from package import *
from package include all
from package include *
What is the output of following code? >>>print(5*(2//3))
3
3.3
0
error
In which format does a Binary file contain information?
Quick response code
Same format in which the data is held in memory
ASCII format
Unicode
Which function is used to write data in binary mode?
write
writelines
dump
pickle
The sequence logic will not be used while __________.
Subtracting two numbers
Comparing two data values
Providing output to the user
Adding two numbers
Which of the following words is not a keyword of Python language?
val
raise
try
with
Which of the following error is returned when we try to open a file in write mode which does not exist?
File Found Error
File Not Exist Error
File Not Found Error
What will be output for the following code? import numpy as np a = np.array([[1,2,3],[0,1,4]]) print (a.size)
1
5
6
4
What will be the output of the following Python code ?
def display(b, n):
while n>0:
print(b, end=””)
n=n-1
display(‘z’, 3)
zzz
zz
Infinite loop
An exception is thrown
Which of the following functions is a built-in function in python ?
factorial()
print()
seed()
sqrt()
What is correct to import all modules from the package?
from package import all
from package import *
from package include all
from package include *
What will be the output of following statement? >>>"m"+"nl"
'm+nl'
'mnl'
'm nl'
'm'
What is the output of the following code ? 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
print (c[2])
10
21
12
28
Which statement will return one line from a file (file object is ‘f’) ?
f.readlines( )
f.readline( )
f.read( )
f.line( )
Which statement will move file pointer 10 bytes backward from current position ?
f.seek(-10, 0)
f.seek(10, 0)
f.seek(-10, 1)
none of the above
What is the output of the following ? x=123 for i in x: print(i)
1 2 3
123
Error
None of these
What is the output of the following code? import numpy as np a = np.array([1,2,3]) print(a.ndim)
1
2
3
0
What is the output of the following ? print(max([1, 2, 3, 4], [4, 5, 6], [7]))
[4, 5, 6]
[7]
[1, 2, 3, 4]
7
What will be the output of the following Python code? from math import * floor(11.7)
12
11
11.0
None of these
What will be the output of the following expression? x = 14 print(x>>2)
14
1
3
2
What will be the output of the following code snippet ?
numbers = (4, 7, 19, 2, 89, 45, 72, 22)
sorted_numbers = sorted(numbers)
odd_numbers = [x for x in sorted_numbers if x % 2 != 0]
print(odd_numbers)
[7, 19, 45, 89]
[2, 4, 22, 72]
[4, 7, 19, 2, 89, 45, 72, 22]
[2, 4, 7, 19, 22, 45, 72, 89]
What will be the output of the following Python code?
>>>list1 = [1, 3]
>>>list2 = list1
>>>list1[0] = 4
>>>print(list2)
[1, 4]
[1, 3, 4]
[4, 3]
[1, 3]
Which of the following is a valid arithmetic operator in Python ?
//
?
<
and
In which format Binary file contains information?
Quick response code
Same format in which the data is held in memory
ASCII format
Unicode format
What is the purpose of the 'break' statement in Python?
To exit the current loop
To skip the current iteration and move to the next one
To define a new function
None of the above
What is the output of the following code snippet in Python?
x = 5 y = 2 print(x // y)
2.5
2
3
2.0
Which of the following is true about Python dictionaries?
They are ordered collections
They can contain duplicate keys
They are mutable
None of the above
What is the purpose of using comments in programming?
To make the code more readable for humans
To execute a specific block of code
To declare variables
To stop the execution of the program
What does the 'len()' function do in Python?
Returns the total number of elements in a list
Converts a string to lowercase
Performs a mathematical operation
Checks for the presence of a substring in a string
What is the purpose of using a 'while loop' in programming?
To repeat a block of code until a condition is met
To execute a block of code a specific number of times
To define a function in Python
To handle exceptions in the code
Which of the following is not a valid data type in Python?
Integer
String
Character
Boolean
What will be the output of the following code snippet?
for i in range(5):
print(i)
else:
print('Loop completed')
0 1 2 3 4 Loop completed
0 1 2 3 4
Loop completed
Error
What is the output of the following Python code snippet?
print('hello'[::-1])
olleh
hello
loleh
None of the above
What is the purpose of the 'pass' statement in Python?
To skip the current iteration in a loop
To indicate that no action is to be taken
To raise an exception
To exit the program
Which method is used to remove the last element from a list in Python?
list.remove()
list.delete()
list.pop()
list.clear()
What is the output of the following code snippet? example = 'hello' example.upper()
'HELLO'
'hello'
'hELLO'
'HELlo'
What is the purpose of using pseudocode in programming?
Planning and organizing tasks
Expressing algorithms in a language-independent manner
Data analysis and visualization
Debugging and testing software
