Functions
Built in functions
Arguments vs no argument
Return values
100

This keyword begins every user-defined function in Python

def

100

This built-in function returns the absolute value of a number

abs()

100

Is the following function defined with arguments or without? 

def area_rectangle():

Without arguments (no parameters listed)

100

What Python keyword is used to send a value back from a function to the caller?

return 

200

Name the three steps required to call a function

name, add parentheses (), include any required parameters inside parentheses separated by commas

200

Which built-in function would you use to get the sum of numbers in a list?

sum()

200

 If a function has two parameters, what must you do when you call it?

Call it with exactly two arguments (neither less nor more)

200

Given this function, what will calling 

rect_area = area_rectangle(3, 4) store in rect_area? 

def area_rectangle(l, w): 

area = l * w

 return area

12

300

True or False: A function’s code runs automatically when Python reads the program

False — functions run only when they are called

300

  returns either True or False based on the parameter passed.

bool()

300

The values you pass into a function when calling it are called _______

arguments

300

Why might we prefer a function that returns a value to one that only prints the result? Give one clear reason

A function that returns a value allows you to reuse the result in other parts of your program

400

Write the short one-line purpose of a user-defined function in your own words

A user-defined function packages code to perform a specific task so we can reuse it

400

The built-in function ____ sorts list elements in place

sort()

400

 Given this definition, how many parameters are there and what are their names? 

def area_rectangle(l, w): 

return l * w

Two parameters:

 l and w

400

Read this function and say what value it returns when called as double_number(10). 

def double_number(n):

 return n * 2

returns 20 

500

Given the function definition below, what is the name of the function and does it take any parameters? def greet(): print("Welcome!")

Name: greet; Parameters: none (no arguments)

500

Which built-in function returns the result of raising a number to a power (base and exponent)?

pow()

500

Explain one advantage of passing values as arguments into a function instead of asking for input inside the function.

It makes the function reusable for many inputs and separates input gathering from logic so the function can be tested more easily.

500

Write a short function definition named add_three that accepts one parameter x and returns x plus 3 

write the code

def add_three(x):

    return x + 3


M
e
n
u