ITP Chapter 5
modules-1-3: In Python a module is: A. A file containing Python definitions and statements intended for use in other Python programs. B. A separate block of code within a program. C. One line of code in a program. D. A file that contains documentation about functions in Python.
A
modules-1-4: To find out information on the standard modules available with Python you should: A. Go to the Python Documentation site. B. Look at the import statements of the program you are working with or writing. C. Ask the professor D. Look in this textbook.
A
modules-3-2: Which statement allows you to use the math module in your program? A. import math B. include math C. use math D. You don't need a statement. You can always use the math module
A
modules-4-3: Which of the following is the correct way to reference the value pi within the math module. Assume you have already imported the math module. A. math.pi B. math(pi) C. pi.math D. math->pi
A
modules-4-5: The correct code to generate a random number between 1 and 100 (inclusive) is: A. prob = random.randrange(1, 101) B. prob = random.randrange(1, 100) C. prob = random.randrange(0, 101) D. prob = random.randrange(0, 100)
A
modules-1-5: True / False: All standard Python modules will work in activecode. A. True B. False
B
modules-4-4: Which module would you most likely use if you were writing a function to simulate rolling dice? A. the math module B. the random module C. the turtle module D. the game module
B
modules-4-6: One reason that lotteries don't use computers to generate random numbers is: A. There is no computer on the stage for the drawing. B. Because computers don't really generate random numbers, they generate pseudo-random numbers. C. They would just generate the same numbers over and over again. D. The computer can't tell what values were already selected, so it might generate all 5's instead of 5 unique numbers.
B
modules-5-1: A module is another name for: A. the code inside a function B. a file containing Python code C. the comments before a function D. a small block of Python code
B
modules-5-2: Create a module by: A. writing a new function or class B. placing an import statement at the top of a file C. placing code in a Python file in the same directory as your other source code D. creating a comment block at the beginning of a file
C
modules-5-3: What determines the name of our import? A. the first variable name in the module B. a comment early in the module C. it's called whatever we name it in the "import" statement D. the filename of the module
D