Lists Hacks Python
This is a CSP Hacks notebook based on the lists lesson
Python Lists Homework
- After going through the lists lesson work on these hacks in your own repository
Hack 1 – Add Up Numbers
Make a list of numbers. Write code to:
- Find the total sum.
- Find the average.
# Hack 1 – Add Up Numbers
numbers = [4, 7, 1, 9, 6, 7, 10]
# Write your code here:
Hack 2 – Count Repeats
Make a list with repeated items. Write code to count how many times each item appears.
# Hack 2 – Count Repeats
items = ["cat", "dog", "cat", "bird", "bird", "bird"]
# Write your code here:
Hack 3 – Keep Only Evens
Make a list of numbers. Write code to create a new list with only even numbers.
# Hack 3 – Keep Only Evens
numbers = [3, 8, 5, 12, 7, 9, 13, 31, 66, 18]
# Write your code here: