logo CodeStepByStep logo

functional_concepts

Language/Type: Python functional programming

Answer the following questions about functional programming. The third question refers to the following function double_all:

# Doubles the values of all elements in a list.
def double_all(a):
    for i in range(len(a)):
        a[i] = 2 * a[i]

The xth questionrefers to the following lambda code:

a = 1
b = 2
lambda b, c: c + b - a
Why do functional programmers want to avoid side effects?
(order shuffled)
Which of the following would be considered a side effect? (Check all that apply.)
(order shuffled)
What side effect does the double_all function have?
(order shuffled)
What is the difference between a free variable and a bound variable?
(order shuffled)
What are the free variables in the lambda function in the code? (Check all that apply.)
What are the bound variables in the lambda function in the code? (Check all that apply.)

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.