In this lab, you will be tasked with writing several functions that require you to use lists and while/for loops.
You should create one file named lab5.py
and put all of the functions you complete, along with the test-cases, in the same file.
Submit just this file to D2L when you are finished.
Write a functions named up_low .
This function will take one parameter, which you can assume is a list of strings.
This function should loop through all elements.
If any element begins with an upper-case letter, it should replace the element with and _all_ upper-case version of the string.
Otherwise, it should convert the string to be all lower-case.
See the tests below for examples:
|
Write a function named longest .
This function will accept two parameters, each of which will be lists on strings (not necessarily of the same length).
This function should determine if the first or the second argument has a greater number of total characters in all of the elements.
For each list, go through each element and sum the lengths of all the strings.
Whichever sum is greater is the "longer" list.
Return 1 if the first is longer, 2 if the second is longer, and 3 for a tie.
For example, these tests:
|
Create a function named check_ok_applicants .
This function will look through a list of applicanta to University of Nowherere (made up by me!) and determine which applicants may be accepted.
The criteria for being accepted is that an applicant must be 27 years old or greater, less than 50, and have a BS, MS, or PhD.
The function will take three lists as parameters.
The first will be a list of the applicants names, the second a list of their ages, and the third a list of education level.
These three lists will be of the same length, and the elements at the same intexes correspond to the same applicant.
The function should return a new list with the names of the acceptable applicants.
This test case:
|
Create a function named remove_triples .
This function will have one list parameter.
This function will iterate through the elements of the list and determine if there are any elements that appear three times in-a-row.
When it finds this, it will remove two of the three elements, so that only one will remain.
It should return the number of times it had to do this removal.
This test case:
|
You must turn in at least 3 of the problems on D2L to get credit for this.