Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python Is it possible for a user-defined function to return multiple values? Sel

ID: 3884300 • Letter: P

Question

Python

Is it possible for a user-defined function to return multiple values?

Select one:

a. No, a function can only return one argument.

b. Yes, they are returned as a tuple of values.

Which of the following expressions DOES NOT have a syntax error?

Select one:

a. assert is False

b. 1stNumber+1

c. print("HelloWorld")

d. True && False

With what keyword do you define a new function in python?

For example, let's pretend that I want to make a function called coconuts; what would I fill in the blank below in order to make the following a function definition?

____ coconuts():

print("Coconuts!!")

Select one:

a. function

b. define

c. definition

d. None of the above

e. def

In Python, is a function actually an object?

Select one:

a. No!

b. Yes! Just like everything else.

True or False:

When using keyword arguments, the order of the arguments listed in the function call is arbitrary and does not need to explicitly match the argument order listed in the function definition.

Select one:

a. True

b. False

What is an unnamed function called in Python?

Select one:

a. There is no such thing!

b. a lambda function

c. an anonymous function

d. a delta function

True or false:

To access one of the module functions, you simply need to specify the name of the function.

Select one:

a. True

b. False: you have to specify the name of the module and the name of the function, separated by a dot (also known as a period)

Can you use a keyword as the name of a function?

Select one:

a. No!

b. Yes!

Fill in the blank:

The order that statements run in is called the ______________.

Select one:

a. flux of code

b. flow of code

c. flow of execution

d. flow of consciousness

e. flow of statements

Match the following definition with the correct vocab word:

"The process of replacing something unnecessarily specific with something appropriately general."

Select one:

a. refactoring

b. encapsulation

c. looping

d. generalization

e. interfacing

Explanation / Answer

1. b. Yes, they are returned as a tuple of values.

Explanation: In python, you can return multiple values as a tuple or as a list.

2. c. print("HelloWorld")

Explanation: That is the correct usage of print() function in python.

3. e. def

Explanation: Keyword 'def' marks the start of a function header. Hence, any function should have 'def' keyword at the beginning

4. b. Yes! Just like everything else.

Explanation: Yes, python functions are full objects.

5. a. True

Explanation: Yes, the position of the arguments can be changed.But, keyword arguments should follow positional arguments

6. c. an anonymous function

Explanation: When a function doesn't have a name, it is called as an anonymous function in python.

7. b. False: you have to specify the name of the module and the name of the function, separated by a dot (also known as a period)

Explanation: A very good example is importing the module math and using the function math.pow(a,b)

8. a. No!

Explanation: Keywords are reserved words in python. They cannot be used for variable names, function names etc.

9. c. flow of execution

Explanation: Execution, in general, is running a statement/instruction. Hence, the order in which statements run is called the flow of execution

10. d. generalization