Python Programming :
UNIT : 3 - Classes
1.The following Python code will result in an error if the input value is entered as -5.
assert False, 'Spanish'
a) True
b) False
Answer: A
2.What will be the output of the following Python code?
x=10
y=8
assert x>y, 'X too small'
a) Assertion Error
b) 10 8
c) No output
d) 108
Answer : C
3. What will be the output of the following Python code?
def f(x):
yield x+1
print("test")
yield x+2
g=f(9)
a) Error
b) test
c)test
10
12
d) No output
Answer : D
4. What will be the output of the following Python code?
def f(x):
for i in range(5):
yield i
g=f(8)
print(list(g))
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]
Answer : A
5. Which of the following is not an exception handling keyword in Python?
a) try
b) except
c) accept
d) finally
Answer : C
Unit 4 - Files
1.To open a file c:\scores.txt for writing, we use ____________
a) outfile = open(“c:\scores.txt”, “w”)
b) outfile = open(“c:\\scores.txt”, “w”)
c) outfile = open(file = “c:\scores.txt”, “w”)
d) outfile = open(file = “c:\\scores.txt”, “w”)
Answer : B
2. To read two characters from a file object infile, we use ____________
a) infile.read(2)
b) infile.read()
c) infile.readline()
d) infile.readlines()
Answer : A
3. To read the entire remaining contents of the file as a string from a file object infile, we use
____________
a) infile.read(2)
b) infile.read()
c) infile.readline()
d) infile.readlines()
Answer : B
4. The readlines() method returns ____________
a) str
b) a list of lines
c) a list of single characters
d) a list of integers
Answer : B
5. To read the next line of the file from a file object infile, we use ____________
a) infile.read(2)
b) infile.read()
c) infile.readline()
d) infile.readlines()
Answer : C
UNIT 5 - XML and Serialization.
1.XML Is Designed To Store Data And _____
Design
Verify
Both A & B
Transport
Answer : D
2. WSDL stands for ___
A. Web Services Description Language
B. Wide Services Description Language
C. Web Services Details Language
D. Web Science Description Language
Answer : D
3.Which Allows Hyperlinks To Point To Specific Parts (fragments) Of XML Documents?
XPath
Xpointer
XSLT
XLink
Answer : B
4. To sterilize an object hierarchy, the _____________ function must be called. To desterilize a
data stream, the ______________ function must be called.
a) dumps(), undumps()
b) loads(), unloads()
c) loads(), dumps()
d) dumps(), loads()
Answer : D
5. What will be the output of the following Python code?
pickle.HIGHEST_PROTOCOL
a) 4
b) 5
c) 3
d) 6
Answer : A