Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

1. .

Find the invalid identifier from the following

a. name b. break c. section d. mark12

2. Which of the following is a function/method of the pickle module ?

a. reader ( ) b. writer ( ) c. load ( ) d. read ( )

3 For a given declaration in Python as s = “WELCOME” Which of the following will be the correct output of

print (s[1: :2]) ?

a. WEL b. COME c. WLOE d. ECM


4 Which of the following statement is not correct ?

a. We can write content into a text file opened using ‘w’ mode
b. We can write content into a text file opened using ‘w+’ mode
c. We can write content into a text file opened using ‘r’ mode
d. We can write content into a text file opened using ‘r+’ mode
5. Which of the following option is the correct Python statement to read and display the first 10 characters of a text
file “Notes.txt” ?
a. F = open ( ‘Notes.txt’ ); print(F.load(10))
b. F = open ( ‘Notes.txt’ ); print(F.dump(10))
c. F = open ( ‘Notes.txt’ ); print(F.read(10))
d. F = open ( ‘Notes.txt’ ); print(F.write(10))
6 Which of the following is not a correct python statement to open a text file “Notes.txt” to write content into it ?
a. F = open ( ‘ Notes.txt ’, ‘w’)
b. F = open ( ‘ Notes.txt ’, ‘a’)
c. F = open ( ‘ Notes.txt ’, ‘A’)
d. F = open ( ‘ Notes.txt ’, ‘w+’)
7 A text file opened using the following statement: MyFile = open ( ‘Notes.txt’ ) Which of the following is the correct
Python statement to close it ?
a. MyFile = close ( ‘Notes.txt’ )
b. MyFile = close ( ‘Notes.txt’ )
c. Close.MyFile ( )
d. MyFile.close ( )
8 Which of the following option is the correct usage for the tell ( ) of a file object?
a. It places the file pointer at a desired offset in a file
b. It returns the entire content of a file
c. It returns the byte position of the file pointer as an integer
d. It tells the details about the file
9 Which of the following is an incorrect Logical operator in Python ?
a. not
b. in
c. or
d. and
10 Given the Python declaration S1 = “Hello”. Which of the following statements will give an error ?
a. print ( S1 [4] )
b. S2=S1
c. S1=S1[ 4 ]
d. S1 [ 4 ] =’’Y”
11 Which of the following statement is incorrect in the context of pickled binary files ?
a. csv module is used for reading and writing object in binary files.
b. pickle module is used for reading and writing objects in binary files.
c. load ( ) of the pickle module is used to read objects.
d. dump ( ) of the pickle module is used to write objects.
12 Which is the significance of the seek ( ) method ?
a. It seeks the absolute path of the file.
b. It tells the current byte position of the file pointer within the file.
c. It places the file pointer at a desired offset within the file.
d. It seeks the entire content of the file.
13 If the following statement is used to read the contents of text file object F: X = F.readlines ( ) Which of the following
is the correct data type of X ?
a. string
b. list
c. tuple
d. dictionary
14 Which of the following is not correct in context of Positional and Default parameters in Python functions ?
a. Default parameter must occur to the right of Positional Parameters.
b. Positional parameters must occur to the right of default parameters.
c. Positional parameters must occur to the left of Default parameters.
d. All parameters to the right of a Default parameter must also have Default values.
15 For a function header as follows: Def Calc( X, Y = 20 ) : Which of the following function calls will give an Error :
a. Calc( 15 , 25 )
b. Calc( X =15 , Y = 25)
c. Calc( Y = 25 )
d. Calc ( X = 25 )
16 Which of the following is not correct in context of scope of variable ?
a. global keyword is used to change value of a global variable in a local scope
b. local keyword is used to change value of a local variable in a global scope
c. global variable can be accessed without using the global keyword in a local scope
d. local variables cannot be used outside its scope
17 Which of the following is the correct output for the execution of the following Python statement ?
print ( 5 + 3 ** 2 /2 )
a. 32 b. 8.0 c . 9.5 d. 32.0

18 Which of the following is not a function/method of the random module in Python.


a. randfloat ( )
b. randint ( )
c. random ( )
d. randrange ( )
19 Which of the following is not a valid Python string operation?
a. ‘ Welcome’ + ‘10’
b. ‘Welcome’ * 10
c. ‘Welcome’ * 10.0
d. “10” + ‘Welcome’
20 What will be the output for the following Python statements? T = ( 10, 20, [30, 40, 50], 60, 70) T[2][1] = 100 print (T)
a. ( 10, 20, 100, 60, 70 )
b. ( 10, 20, [30, 100, 50], 60, 70)
c. (10, 20, [100, 40, 50], 60, 70)
d. Error
21 What will be the output for the following Python statements? L = [10, 20, 30, 40, 50 ] L = L + 5 Print ( L )
a. [10, 20, 30, 40, 50, 5]
b. [15, 25, 35, 45, 55]
c. [5, 10, 20, 30, 40, 50]
d. Error
22 What will be the output for the following Python statements ?
D = {“AMIT” : 90, “RESHMA” : 96, “SUKHBIR” : 92, “JOHN” : 95 }
Print ( “ JOHN” in D, 90 in D, sep = “#”)
a. True#False
b. True#True
c. False#True
d. False#False
23 Nitish has declared a tuple T in python as following : T = ( 10, 20, 30 ) Now, he wants to insert an element 40 after
these three elements of T so that the tuple may contain ( 10, 20, 30, 40) Which of the following statements shall
Nitish write to accomplish the above task ?
a. T = T + 40
b. T = T + (40)
c. T = T + (40, )
d. Nitish cannot insert 40 into the tuple since Tuples are immutable
24 Suppose the content of a text file Notes.txt is:
“The way to get started is to quit talking and begin doing”
What will be the output of the following Python code ?
F = open ( “Notes.txt” ) F.seek (29)
S = F.read()
Print ( S )
a. The way to get started is to
b. quit talking and begin doing
c. The way to get started is to quit talking and begin doing
d. Gniod nigeb dna gniklat tiuq ot si detrats teg ot yaw ehT
25 Identify the output of the following Python statements
S = “GOOD MORNING”
Print( S.capitalize ( ), S.title( ), end=”!”)
a. GOOD MORNING ! Good morning
b. Good Morning ! Good morning
c. Good morning ! Good Morning!
d. Good morning Good Morning
26 Identify the output of the following Python statements?
L = [ ] for i in range (4) :
L.append(2*i+1)
Print (L[ : : -1])
a. [7, 5, 3, 1 ] b. [9, 7, 5, 3 ] c. [4, 3, 2, 1 ] d. [1, 2, 3, 4]
27 Identify the output of the following Python statements :
D = { } T = ( “ZEESHAN” , “NISHANT” , “GURMEET” , “LISA” )
for i in range ( 1 , 5) :
D [ i ] = T [ i - 1]
Print ( D )
a. { “ZEESHAN” , “NISHANT” , “GURMEET” , “LISA” }
b. “ZEESHAN” , “NISHANT” , “GURMEET” , “LISA”
c. {[ 1 , “ ZEESHAN” ] , [ 2 , “ NISHANT ”] , [ 3 : “ GURMEET ”] , [ 4 , “ LISA” ]}
d. { 1 : “ ZEESHAN “ , 2 : “ NISHANT “ , 3 : “ GURMEET “ , 4 : “ LISA “}
28

29 Which of the following Python modules is imported to store and retrieve objects using the process of serialization
and deserialization ?
a. csv b. binary c. math d. pickle

30 What will be the output of the following Python code ?

31

32

a. PYTHON 3.9 b. PYTHON 3.9 * 3.9 c. PYTHON 3.9 * 39 d. Error


32

33

34

35

You might also like