Quiz - 4¶
Develop the function extreme_values
which takes the parameter numbers
, representing a list of 10 random numbers between 0-100.
The function should return a tuple (a, b)
, where a and b are the maximum and minimum values respectively of the numbers
list. Solve the problem without using
the functions max
nor min
.
Example:
extreme_values([15, 48, 0, 27, 13, 62, 32, 57, 85, 18])
-> (85, 0)
Develop the function even_and_odd
which takes the parameter numbers
. numbers
represents a list of 20 random numbers between 1-100.
The function should return a tuple of lists of the form ([even], [odd])
, where even and odd are lists of even and odd numbers that are
in numbers
, respectively.
Develop the function collate_lists
which takes two parameters, l1
and l2
, representing lists of 10 random numbers between 1-100.
The function should generate a third list composed of the elements of l1
and l2
interleaved. This third list will be returned.
Example:
collate_lists([1, 3, 5, .....], [2, 4, 6, ....])
-> [1, 2, 3, 4, 5, 6, ....]
The function search_for_words
will be passed the following text
as argument:
“The Python Software Foundation and the global Python community welcome and encourage participation by everyone. Our community is based on
mutual respect, tolerance, and encouragement, and we are working to help each other live up to these principles. We want our community to be more diverse: whoever you are, and
whatever your background, we welcome you.”
It should generate a list of words from this text using split()
. Then it should create a list of words that start or end with any
of the letters in the string "python"
. This list is the one that will be returned. Note: Don’t forget to first remove special characters
and be careful with capitalization.
Now you will develop the function search_for_words_2
, which will be passed the previous text as a parameter. Again you will separate the
text into words, just like you did in Exercise 4. This time, you should calculate the number of words within text
that have any
of the letters in the string "python"
, and also have a length greater than 4 characters.