Last Updated on October 18, 2019 by Admin
PCAP – Programming Essentials in Python Quizzes Module 4 Test Answers
-
Knowing that a function named fun() resides in a module named mod, choose the proper way to import it:
- import fun from mod
- import fun
- from mod import fun
- from fun import mod
-
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:
- mod.fun()
- mod::fun()
- fun()
- mod‑>fun()
-
A function returning a list of all entities available in a module is called:
- content()
- dir()
- entities()
- listmodule()
-
The pyc file contains:
- compiled Python code
- a Python interpreter
- a Python compiler
- Python source code
-
When a module is imported, its contents:
- are executed once (implicitly)
- are executed as many times as they are imported
- are ignored
- may be executed (explicitly)
-
A predefined Python variable, storing the current module name, is called:
- __modname__
- __name__
- __mod__
- __module__
-
The following statement:
from a.b import c
causes the import of:
- entity c from module b from package a
- entity a from module b from package c
- entity c from module a from package b
- entity b from module a from package c
-
Entering the try: block implies that:
- the block will be omitted
- all of the instructions from this block will be executed
- some of the instructions from this block may not be executed
- none of the instructions from this block will be executed
-
The unnamed except: block:
- must be the last one
- cannot be used if any named block has been used
- can be placed anywhere
- must be the first one
-
The top‑most Python exception is named:
- BaseException
- Exception
- TopException
- PythonException
-
The following statement:
assert var == 0
- will stop the program when var != 0
- is erroneous
- has no effect
- will stop the program when var == 0
-
ASCII is:
- a predefined Python variable name
- a standard Python module name
- a character name
- short for American Standard Code for Information Interchange
-
UTF‑8 is:
- a synonym for “byte”
- a form of encoding Unicode code points
- the 9th version of the UTF standard
- a Python version name
-
UNICODE is a standard:
- honored by the whole universe
- for coding floating-point numbers
- used by coders from universities
- like ASCII, but much more expansive
-
The following code
x = ‘\”
print(len(x))
prints:
- 1
- 0
- 3
- 2
-
The following code:
print(ord(‘c’) – ord(‘a’))
prints:
- 3
- 2
- 0
- 1
-
The following code
print(chr(ord(‘z’) – 2))
prints:
- x
- a
- z
- y
-
The following code
print(3 * ‘abc’ + ‘xyz’)
prints:
- abcabcabcxyz
- abcabcxyzxyz
- xyzxyzxyzxyz
- abcxyzxyzxyz
-
The following code
print(‘Mike’ > “Mikey”)
prints:
- 0
- False
- 1
- True
-
The following code:
print(float(“1,3”))
- prints 1,3
- prints 1.3
- raises a ValueError exception
- prints 13