Part 1
Using a loop, and the following list:
ages = [5, 15, 64, 27, 84, 26]
- Find the sum total of the values in this list
- Find the average (mean) value of the items in the list
Part 2
Using a single list comprehension, and the following list:
words = ["The", "quick", "brown", "fox", "jumped", "over", "the", "lazy", "dog"]
- Build a new list, with the first letter from each word
- Convert each letter to lower case
Expected output: ["t", "q", "b", "f", "j", "o", "t", "l", "d"]
Hint: Strings in Python work as if they were a tuple full of characters. How would you get the first element from a tuple or list?
Part 3
Implement a basic linear search algorithm using Python's for
and if
keywords.
Given the following data structure:
pupils = ["Alison", "James", "Stephen", "Mandy", "Henry"]
Search through the list and check if the name "Jack" is included. Print out an appropriate message.