CPSC120
Fundamentals of Computer Science

In-class Activity 23

  1. Create a Python function that takes two 2D points and returns the point mid-way between the two points.

  2. Create a Python function that takes a list of integers and returns the mode of the input list as a list of integers.

  3. What would the following snippet of Python code print if run?

    spam = [2, 1, 0]
    for i in range(len(spam))
        print(spam[spam[i]])
  4. What would the following snippet of Python code print if run?

    spam = [1, 2, 3]
    for i in range(len(spam))
        spam = spam + [spam[i] + spam[i]]
    print(spam)
  5. What would the following snippet of Python code print if run?

    spam = [1, 2, 3]
    for i in range(len(spam))
        spam.append(spam[i] + spam[len(spam) - i - 1])
    print(spam)