1 ic04 CS8 F17
Name:
(as it would appear on official course roster)
Optional: name you wish to be called
if different from name above.
Optional: name of "homework buddy"
(leaving this blank signifies "I worked alone"

# ic04: Review for midterm-2 (pytest, loops and lists)

true Mon 11/13 12:30PM Mon 11/13 02:50PM

You may collaborate on this homework with AT MOST one person, an optional "homework buddy".

MAY ONLY BE TURNED IN IN THE LECTURE/LAB LISTED ABOVE AS THE DUE DATE.
There is NO MAKEUP for missed assignments, and you may not submit work in advance, or on behalf of another person.
In place of that, we drop the four lowest scores (if you have zeros, those are the four lowest scores.)

Disregard the instruction above about “homework buddies” for this in-class assignment. For this assignment:

• Collaborating with your neighbor is allowed and encouraged
• Asking for help from the professor is allowed and encouraged

Those conditions will NOT be true on the final exam. This is just for practice.

1. (20 pts) Write the definition of a Python function maskedPassword that takes one parameter pw and returns a string consisting of the first three characters contained in the variable pw followed by ‘x’s instead of the remaining characters in pw. The length of the returned value should be the same as the length of the parameter passed in. If the length of pw is less than 3 return pw without any modification (YOU MAY ASSUME pw is of type str)

2. Write three test cases (in the style of the pytest module) that for the function maskedPassword as defined above.

1. (5 pts) Write your one test case here:
2. (5 pts) Write a second test case here:
3. (5 pts) Write a third test case here:
3. (20 pts) Write the definition of a Python function isValidPassword that takes a parameter pw and returns True if the variable pw is of type str and is a valid password, according to the following rules: it must consist of at least 8 characters, include one of the special characters * or # and terminate with a numeric digit (0-9).

4. Write three test cases (in the style of the pytest module) that for the function isValidPassword as defined above.

1. (5 pts) Write one test case here:
2. (5 pts) Write a second test case here:
3. (5 pts) Write a third test case here:
5. (30 pts) Write the definition of a Python function minOfTwoLists that takes two lists as parameters: alist and blist. The functions returns a new list where each element in the new list is the minimum of the corresponding elements in alist and blist. The function should raise a ValueError exception with an appropriate message, if either alist or blist is not a list or if either of them contains anything other than numbers (either int or float) or if the two lists are not of the same length.