You're on assignment part 3/3 for this lesson.
Pure functions have a lot of benefits. Whenever possible, good developers try to use pure functions instead of impure functions. Remember, pure functions:
These properties result in pure functions being easier to test, debug, and think about.
Refer to the following examples and answer the questions.
def multiply_by2(nums):
products = []
for num in nums:
products.append(num*2)
return products
balance = 1000
cars = []
def buy_car(new_car):
global balance
cars.append(new_car)
balance -= 69
import random
def roll_die(num_sides):
return random.randint(1, num_sides)