CPSC120A
Fundamentals of Computer Science I

Lab 34

Review for Final Exam

Use the command line to create a new directory called lab34 in your labs directory. Make sure all of the .py files that you create for this activity are in that directory.

Programming Excercises
  1. Write a function that takes a two-dimensional list of ints and returns True if all of the columns sum to the same value and False otherwise. For example:

    >>> magic_cols([[4, 9, 2], [3, 5 ,7], [8, 1, 6]])
    True
    >>> magic_cols([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
    False
  2. Write a function that takes a list of ints and returns a new list that contains all of the ints in the input list, but no duplicates. For example:

    >>> remove_dups([1, 2, 3, 4, 5])
    [1, 2, 3, 4, 5]
    >>> remove_dups([1, 2, 3, 2, 1])
    [1, 2, 3]
  3. Write a Python function that returns a dictionary that represents a Vigenère Square. This dictionary can be used to assist in encoding a Vigenère cipher. You should generate this dictionary dynamically, as opposed to hard-coding the values. For example:

    >>> square = generate_vigenere()
    >>> for key in square:
    ...     print(key, "->", square[key])
    
    'a' -> ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
    'c' -> ['c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b']
    'b' -> ['b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a']
    'e' -> ['e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd']
    'd' -> ['d', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c']
      .
      .
      .