1 - Knowing that a function named fun() resides in a module named mod , choose the correct way to import it:
a) from mod import fun
b) import fun from mod
c) from fun import mod
d) import fun
Solution: a) from mod import fun
2 - What is the expected output of the following code?
from random import randint
for i in range(2):
print (randint(1,2), end='')
a) 12, or 21
b) there are millions of possible combinations, and the exact output cannot be predicted
c) 12
d) 11, 12, 21, or 22
Solution: d) 11, 12, 21, or 22
3 - During the first import of a module, Python deploys the pyc files in the directory called:
a) mymodules
b) __init__
c) hashbang
d) __pycache__
Solution: d) __pycache__
4 - A list of package’s dependencies can be obtained from pip using its command named:
a) deps
b) show
c) dir
d) list
Solution: b) show
5 - What is the expected value of the result variable after the following code is executed?
import math
result = math.e != math.pow(2, 4)
print(int(result))
a) 0
b) 1
c) False
d) True
Solution: b) 1
The pip list command presents a list of:
a) available pip commands
b) outdated local package
c) locally installed package
d) all packages available at PyPI
Solution: c) locally installed package
7 - How to use pipto remove an installed package?
a) pip --uninstall package
b) pip remove package
c) pip install --uninstall package
d) pip uninstall package
Solution: d) pip uninstall package
8 - The following statement
from a.b import c
causes the import of:
a) entity a from module b from package c
b) entity c from module a from package b
c) entity b from module a from package c
d) entity c from module b from package a
Solution: d) entity c from module b from package a
9 - The pyc file contains:
a) a Python interpreter
b) compiled Python code
c) Python source code
d) a Python compiler
Solution: b) compiled Python code
10 - A predefined Python variable that stores the current module name is called:
a) __name__
b) __mod__
c) __modname__
d) _module__
Solution: a) __name__
11 - What is true about the pip search command? (Select three answers)
a) all its searches are limited to locally installed packages
b) it needs working internet connection to work
c) it searches through all PyPI packages
d) it searches through package names only
Solution: a, b, c
12 - When a module is imported, its contents:
a) are executed once (implicitly)
b) are ignored
c) are executed as many times as they are imported
d) may be executed (explicitly)
Solution: a
13 - Choose the true statements. (Select two answers)
a) The version function from the platform module returns a string with your Python version
b) The processor function from the platform module returns an integer with the number of processes currently running in your OS
c) The version function from the platform module returns a string with your OS version
d) The system function from the platform module returns a string with your OS name
Solution: c
14 - What is true about the pip install command? (Select two answers)
a) it allows the user to install a specific version of the package
b) it installs a package system-wide only when the --system option is specified
c) it installs a package per user only when the --user option is specified
d) it always installs the newest package version and it cannot be changed
Solution: a, c
15 - Knowing that a function named fun() resides in a module named mod , and it has been imported using the following line:
import mod
Choose the way it can be invoked in your code:
a) mod->fun()
b) mod::fun()
c) mod.fun()
d) fun()
Solution: c
16 - The digraph written as #! is used to:
a) tell a Unix or Unix-like OS how to execute the contents of a Python file
b) tell an MS Windows OS how to execute the contents of a Python file
c) create a docstring
d) make a particular module entity a private one
Solution: a
17 - A function which returns a list of all entities available in a module is called:
a) entities()
b) content()
c) dir()
d) listmodule()
Solution: c
18 - What is true about updating already installed Python packages?
a) it can be done only by uninstalling and installing the package once again
b) it’s an automatic process which doesn’t require any user attention
c) it can be done by reinstalling the package using the reinstall command
d) it’s performed by the install command accompanied by the -U option
Solution: d