These questions assess a students understanding of the list comprehension concept map.

  1. Which of the following statements about list comprehensions is correct?
  1. Given the following:
def square(z):
    return z * z

def is_number(z):
    from numbers import Number
    return isinstance(z, Number)

items = [1, '4', 9, 16.1, [1, 2, 3]]

Write a list comprehension that squares only the numeric elements of items.