Embercode
✕
Functions and ScopeQuick quiz

Pure functions in Python

7 questions. Covers Pure functions in Python.

Questions 1 to 5 of 7

  1. 1. Is within_limit pure? Answer true or false, with the reason. ``python LIMIT = 10 def within_limit(n): return n <= LIMIT ``
  2. 2. Is this function pure? Answer true or false, with the reason. The function adds up a list of prices, prints the total with print, and then returns the total.
  3. 3. What does this program print? ``python def sorted_copy(xs): copy = list(xs) copy.sort() return copy a = [3, 1, 2] b = sorted_copy(a) print(a, b) ``
  4. 4. What does this program print? (one line per output) ``python TAX_RATE = 0.18 def price_with_tax(price): return price * (1 + TAX_RATE) print(price_with_tax(50.0)) TAX_RATE = 0.05 print(price_with_tax(50.0)) ``
  5. 5. Which change makes within_limit pure?

5 question(s) left on this page.