1. Is Python case sensitive when dealing with identifiers?
a) no
b) yes
c) machine dependent
d) none of the mentioned
2. Python supports the creation of anonymous functions at runtime,
using a construct called __________
a) pi
b) anonymous
c) lambda
d) none of the mentioned
3. What does pip stand for python?
a) Pip Installs Python
b) Pip Installs Packages
c) Preferred Installer Program
d) All of the mentioned
4. Which of the following is the truncation division operator in
Python?
a) |
b) //
c) /
d) %
5. What will be the output of the following Python code?
l=[1, 0, 2, 0, 'hello', '', []]
list(filter(bool, l))
a) [1, 0, 2, ‘hello’, ”, []]
b) Error
c) [1, 2, ‘hello’]
d) [1, 0, 2, 0, ‘hello’, ”, []]
6. Which of the following is not a core data type in Python
programming?
a) Tuples
b) Lists
c) Class
d) Dictionary
7. What is the order of namespaces in which Python looks for an
identifier?
a) Python first searches the built-in namespace, then the global
namespace and finally the local namespace
b) Python first searches the built-in namespace, then the local
namespace and finally the global namespace
c) Python first searches the local namespace, then the global
namespace and finally the built-in namespace
d) Python first searches the global namespace, then the local
namespace and finally the built-in namespace
8. To add a new element to a list we use which Python command?
a) [Link](5)
b) [Link](5)
c) [Link](5)
d) [Link](5)
9. Which one of the following is the use of function in python?
a) Functions don’t provide better modularity for your application
b) you can’t also create your own functions
c) Functions are reusable pieces of programs
d) All of the mentioned
10. What will be the output of the following Python code?
x = 'abcd'
for i in range(len(x)):
print(i)
a) error
b) 1 2 3 4
c) a b c d
d) 0 1 2 3
11. Which of the following is a feature of Python DocString?
a) In Python all functions should have a docstring
b) Docstrings can be accessed by the __doc__ attribute on objects
c) It provides a convenient way of associating documentation with
Python modules, functions, classes, and methods
d) All of the mentioned
12. What will be the output of the following Python code?
def foo():
try:
return 1
finally:
return 2
k = foo()
print(k)
a) error, there is more than one return statement in a single try-finally
block
b) 3
c) 2
d) 1
13. Which of the following is a Python tuple?
a) {1, 2, 3}
b) {}
c) [1, 2, 3]
d) (1, 2, 3)
14. What are the two main types of functions in Python?
a) System function
b) Custom function
c) Built-in function & User defined function
d) User function
15. What will be the output of the following Python code?
print('*', "abcde".center(6), '*', sep='')
a) * abcde *
b) *abcde *
c) * abcde*
d) * abcde *
16. What arithmetic operators cannot be used with strings in Python?
a) *
b) –
c) +
d) All of the mentioned
17. Which one of the following is not a keyword in Python language?
a) pass
b) eval
c) assert
d) nonlocal
18. Which of the following statements create a dictionary?
a) d = {}
b) d = {“john”:40, “peter”:45}
c) d = {40:”john”, 45:”peter”}
d) All of the mentioned
19. Suppose d = {“john”:40, “peter”:45}, to delete the entry for “john”
what command do we use?
a) [Link](“john”:40)
b) [Link](“john”)
c) del d[“john”]
d) del d(“john”:40)
20. Set makes use of __________
Dictionary makes use of ____________
a) keys, keys
b) key values, keys
c) keys, key values
d) key values, key values