Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.A file that contains reusable code is called a a. function b. namespace c. module d. hierarchy chart -------- 2.A global variable a. is defined

1.A file that contains reusable code is called a

a. function

b. namespace

c. module

d. hierarchy chart

--------

2.A global variable

a. is defined inside the main() function

b. cannot be modified inside a function

c. cannot be accessed from within a function

d. is defined outside of all functions

-----------

3.a local variable is defined

a. inside a function

b. inside the main() function

c. inside an if statement

d. outside of all functions

-----------------------

4.a return statement

a. can be used to return a local variable to the calling function

b. can only be used once in each function

c. can be used to allow the function to modify the value of a global variable

d. must be coded within every function

--------

5.Assuming the random module has been imported into its default namespace, which of the following could possibly result in a value of 0.94?

a. number = random.random()

b. number = random.randfloat()

c. number = random.randint (0,1)

d. number = random.randint(0, 1) / 100

---------

6.Assuming the random module has been imported into its default namespce, which of the following could be used to generate a random even integer from 2 through 200?

a. number = random.randrange(2, 200, 2)

b. number = random.randrange (2,202,2)

c.. number = random (1, 100) * 2

d. number = random.randint (2,200,2)

______________

7.Before you can use a standard module like the random module, you need to

a. import the module into its default namespace

b. import the module into a custom namespace.

c. import the module into the global namespace

d. import the module

-------------

8.

def get_username(first, last): s = first + "." + last return s.lower() def main(): first_name = input("Enter your first name: ") last_name = input("Enter your last name: ") username = get_username(first_name, last_name) print("Your username is: " + username) if __name__ == "__main__": main()

what arguements are defined by the get_username() function?

a. first, last

b. username

c. first_name, last_name

d. s, first, last

--------------

9.

def get_username(first, last): s = first + "." + last return s.lower() def main(): first_name = input("Enter your first name: ") last_name = input("Enter your last name: ") username = get_username(first_name, last_name) print("Your username is: " + username) if __name__ == "__main__": main()

if the user enters 'Lopez' for the first promt in main() and 'Maria' for the second prompt, what will display?

a.Lopez.Maria

b. lopez.maria

c. Maria.Lopez

d. maria.lopez

__________

10.

def get_volume(width, height, length=2): volume = width * height * length return volume def main(): l = 3 w = 4 h = 5 v = get_volume(l, w, h) print(v) if __name__ == "__main__": main()

what value is passed to the height argument by the call to the get_volume() function?

a. 2

b. 3

c. 4

d. 5

---------------

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

Step: 3

blur-text-image

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

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions

Question

Does your strategic intent play to your strengths?

Answered: 1 week ago