Revision 2 QP
Revision 2 QP
3 For a given declaration in Python as s = “WELCOME” Which of the following will be the correct output of
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
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
31
32
33
34
35