Python Test

Python Test


It is possible to use encoding other than ASCII in Python source files. The best way to do it is to put one more special comment line right after the #! line to define the source file encoding. Which of the following is the correct statement to define encoding?

a. coding: iso-8859-15
b. # -*- iso-8859-15 -*-
c. # -*- coding: iso-8859-15 -*-
d. None of these

Which of the following is the correct prototype of the string.find() function?

a. string.find(s, sub ,start ,end)
b. string.find(s, sub ,start [,end])
c. string.find(s, sub [,start [,end]])
d. string.find(s, sub [,start] ,end)

Which of the following modules lets you check whether two files are identical, and whether two directories contain some identical files?

a. dircomp
b. filecompare
c. filecmp
d. structcomp

How can a null object be declared in Python?

a. none
b. None
c. null
d. Null

The core text processing tasks in working with email are parsing, modifying, and creating the actual messages. Which of the following modules deal with parsing and processing email messages?

a. MimeWriter
b. mimify
c. Both MimeWriter and mimify
d. Neither MimeWriter nor mimify

Which function could be used to list every file and folder in the current directory?

a. os.dirnames(‘.’)
b. os.listdir(‘.’)
c. os.listdir(‘/’)

Which user input method will act like a file-object on which read and readline functions can be called?

a. sys.stdin
b. raw_input()
c. input()
d. sys.argv

Which of the following is the correct prototype for the ‘open’ function of the file class in python 2.2+?

a. open(fname [,mode [,buffering]])
b. open(fname [,buffering [,mode]])
c. open(fname [,mode])
d. open(fname,mode,buffering)
e. open(fname,buffering,mode)
f. None of these

Prev1 of 11

Share This Post