100% found this document useful (1 vote)
4K views

Module 4 Test Answers Py Ese

This document contains 20 multiple choice questions about Python modules, functions, exceptions, strings, characters, and data types. It tests knowledge of importing and invoking functions from modules, the dir() function, the structure of try/except blocks, ASCII, Unicode, and operations like concatenation and comparison that can be performed on strings and characters.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
4K views

Module 4 Test Answers Py Ese

This document contains 20 multiple choice questions about Python modules, functions, exceptions, strings, characters, and data types. It tests knowledge of importing and invoking functions from modules, the dir() function, the structure of try/except blocks, ASCII, Unicode, and operations like concatenation and comparison that can be performed on strings and characters.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Module 4 Test Answers

1. 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
2. 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()
3. A function returning a list of all entities available
in a module is called:
 content()
 dir()
 entities()
 listmodule()
4. The pyc file contains:
 compiled Python code
 a Python interpreter
 a Python compiler
 Python source code
5. 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)
6. A predefined Python variable, storing the current
module name, is called:
 __modname__
 __name__
 __mod__
 __module__
7. 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
8. 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
9. 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
10. The top-most Python exception is named:
 BaseException
 Exception
 TopException
 PythonException
11. 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
12. ASCII is:
 a predefined Python variable name
 a standard Python module name
 a character name
 short for American Standard Code for Information Interchange
13. 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
14. 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
15. The following code
x = ‘\”
print(len(x))
prints:
 1
 0
 3
 2
16. The following code:
print(ord(‘c’) – ord(‘a’))
prints:
 3
 2
 0
 1
17. The following code
print(chr(ord(‘z’) – 2))
prints:
 x
 a
 z
 y
18. The following code
print(3 * ‘abc’ + ‘xyz’)
prints:
 abcabcabcxyz
 abcabcxyzxyz
 xyzxyzxyzxyz
 abcxyzxyzxyz
19. The following code
print(‘Mike’ > “Mikey”)
prints:
 0
 False
 1
 True
20. The following code:
print(float(“1,3”))
 prints 1,3
 prints 1.3
 raises a ValueError exception
 prints 13

You might also like