Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A file containing Python code that is passed as input to the interpreter is called a _______? a larch b package c module d script

A file containing Python code that is passed as input to the interpreter is called a _______?

a

larch

b

package

c

module

d

script

Question 2 (1 point)

When importing a module, the interpreter first checks to see if that module has already been imported. A dictionary of the loaded modules is stored in_______.

a

sys.libs

b

sys.larch

c

sys.modules

d

sys.packages

Question 3 (1 point)

Consider the following code example: ## module M1.py a = 'First Message' def printer(): print('Hello from M1:', a) >>> import M1 >>> M1pr = M1.printer >>> M1pr() Hello from M1: First Message >>> # Change printer and message ... >>> reload(M1) The console output that follows the reload statement will be _______________

a

No output

b

First Message

c

d

The program will throw an error.

Question 4 (1 point)

Which of the following is not in sys.path?

a

The directory of the executing script.

b

A list of directories specified by the environmental variable PYTHONPATH.

c

The directory where Python is installed (typically C:\Python27 or similar on Windows).

d

The directory where a larch is.

Question 5 (1 point)

A _________ is a file containing Python code that can be imported by a script.

a

larch

b

package

c

module

d

script

Question 6 (1 point)

Consider the following directory structure. A statement to import the cow module would be __________.

ASCIIArt\Top-level package

__init__.py

canvas.py

figures\Subpackage for figures art

__init__.py

man.py

cow.py

...

buildings\Subpackage for buildings art

__init__.py

barn.py

house.py

...

a

import figures

b

import ASCIIArt.figures.cow

c

import ASCIIArt.cow

d

import ASCII.figures.cow

Question 7 (1 point)

The following code uses functions defined in my_funcs.py. Complete the import statement at the top of the program. ____________________ a = 3 print(a! = , factorial(a)) print(log(a) = ,log(a))

a

import factorial, squared

b

import factorial, log

c

from my_funcs import factorial, log

d

from my_func import factorial log

Question 8 (1 point)

Consider the code snippet named shapes.py. A statement to call the draw_square function from the shapes module, passing an argument of 3 would be _______________.

cr = '#'

import shapes

def draw_square(size):

for h in range(size):

for w in range(size):

print(cr, end='')

print()

def draw_rect(height, width):

for h in range(height):

for w in range(width):

print(cr, end='')

print()

a

draw_rect(3)

b

draw_square(3.0)

c

shapes.draw_square(3)

d

The program throws an error

Question 9 (1 point)

A Python file containing code that can be imported and used by other scripts is a(n) _______.

a

larch

b

exception

c

module

d

package

Question 10 (1 point)

Consider the following directory structure. A statement to import the figures subpackage would be _____________.

ASCIIArt\Top-level package

__init__.py

canvas.py

figures\Subpackage for figures art

__init__.py

man.py

cow.py

...

buildings\Subpackage for buildings art

__init__.py

barn.py

house.py

...

a

import figures

b

import ASCIIArt.figures

c

import ASCIIArt

d

import ASCII.figures

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Master The Art Of Data Storytelling With Visualizations

Authors: Alexander N Donovan

1st Edition

B0CNMD9QRD, 979-8867864248

More Books

Students also viewed these Databases questions