1 |
ic02 |
CS8 M17 |
Name: | ||||
---|---|---|---|---|
(as it would appear on official course roster) | ||||
Umail address: | @umail.ucsb.edu | |||
Optional: name you wish to be called if different from name above. | ||||
Optional: name of "homework buddy" (leaving this blank signifies "I worked alone" |
ic02: Review for Final Exam
ready? | assigned | due | points |
---|---|---|---|
true | Wed 09/06 09:30AM | Wed 09/06 10:50AM |
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.
(12 pts) Please fill in the information at the top of this homework sheet, as usual. WRITE DARK, and remember, if you MUST submit it on multiple sheets, JUST write your name at the top of both sheets and turn in both sheets UNCONNECTED. No staples, paper clips, fold/tear etc or anything that would jam up the scanner.
-
(20 pts) Write the definition of a Python function
maskedPassword
that takes one parameterpw
and return a string consisting of the first three characters contained in the variablepassword
followed by ‘x’s instead of the remaining characters inpassword
. The length of the returned value should be the same as the length of the parameter passed in. (YOU MAY ASSUMEpw
is of typestr
) -
Write three test cases (in the style of the
pytest
module) that for the functionmaskedPassword
as defined above.- (8 pts) Write your one test case here:
- (8 pts) Write a second test case here:
- (8 pts) Write a third test case here:
-
(20 pts) Write the definition of a Python function
isValidPassword
that takes a parameterpw
and returns True if the variablepassword
is of typestr
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
). -
Write three test cases (in the style of the
pytest
module) that for the functionmaskedPasswordisValidPassword
as defined above.- (8 pts) Write one test case here:
- (8 pts) Write a second test case here:
- (8 pts) Write a third test case here: