1. Which of the following is not a feature of python?
a) Interactive
b) Interpreted
c) Statically typed
d) Object oriented
Answer: C
2. Which of the following is not a list attribute?
a) append()
b) insert()
c) delete()
d) copy()
Answer: C
3. Which of the following is not a valid variable definition in python?
a) x1y2
b) abc-123
c) _abc
d) __abc
Answer: B
4. Which of the following is used to retrieve the object or variable type?
a) dir()
b) type()
c) help()
d) dtype()
Answer: B
5. Which of the following is not a keyword in python3?
a) True
b) in
c) print
d) def
Answer: C
6. Which of the following is not a number type in python3?
a) int
b) float
c) long
d) complex
Answer: C
7. Which of the following is not an exception type?
a) ValueError
b) KeyError
c) ZeroDivisionError
d) IndexOutOfRangeError
Answer: D
8. Which of the following is invalid list comprehension syntax for a list of number numbers
a) [i**2 for i in numbers]
b) [i for i in numbers if i%2==0]
c) [i for i in numbers id i%2==0 else i**2]
d) [i if i%2==0 else i**2 for i in numbers]
Answer: C
9. Which of the following is the correct syntax to apply a decorator?
a) @decorator
b) #decorator
c) _decorator
d) decorator
Answer: A
10. Which keyword is used to define a function in Python?
a) def
b) lambda
c) Both a and b
d) None
Answer: C
11. Which of the following commands can be used to read the entire contents of a file as a string using
the file object <tmpfile>?
a) tmpfile.read(n)
b) B. tmpfile.read()
c) C. tmpfile.readline()
d) D. tmpfile.readlines()
Answer: B
12. What does the <readlines()> method returns?
A. str
B. a list of lines
C. list of single characters
D. list of integers
Answer: B
13. How many times will the loop run?
>>> i=2
>>> while(i>0):
>>> i=i-1
A. 2
B. 3
C. 1
D. 0
Answer: A
14. What will be the output of the following Python code?
>>>t=(1,2,4,3)
>>>t[1:3]
a) (1, 2)
b) (1, 2, 4)
c) (2, 4)
d) (2, 4, 3)
Answer: C
15. What will be the output after the following statements?
x = ['Today', 'Tomorrow', 'Yesterday']
y = x[1]
print(y)
a. x1
b. Today
c. Tomorrow
d. Yesterday
Answer: C