Skip to main content

Lab 6 — Practice with `for` loops and lists

Date: October 20, 2026

Skills: 4​

For all of these problems, first implement them with a for loop (so, use #level intermediate). Afterwards, implement them a second time with map or filter (without changing any variables). For some, it should be possible with just a single call to map or filter -- but for others you may need to also use other functions (like len).

  1. Design a function absolute_values that takes a list of numbers and returns a new list where each number has been converted to its absolute value (use abs).
  2. Design a function exactly_three_chars that takes a list of strings and returns a new list containing only the strings that have exactly 3 characters.
  3. Design a function all_even that takes a list of numbers and returns True if every number in the list is even, False otherwise.
  4. Design a function count_in_range that takes a list of numbers, a minimum value, and a maximum value, and returns how many numbers in the list are between the min and max (inclusive).