Tutorial Video
Mini Tutorial Videos
Video 2 – How to add / append items to a list
Video 3 – How to remove / pop items from a list
Video 4- How to loop through a Python list
Video 5 – How to use if statements with lists
Video 6 – Finding items in a list
Video 7 – How to sort a list in Python
Video 8 – How to shuffle / randomise a list
Video 9 – How to convert a list to a string (and back again)
Full playlist video on YouTube
Can’t access YouTube? Click here for the Google Drive version
Cheat Sheet
Python Lists Cheat Sheet
#Create an empty list l = [] #Create a list with items in it l = ["dog","cat","mouse"] #get the user to add items to a list for i in range(5): l.append(input("What to add?")) #print all items in a list for item in l: print("Your item is -", item) #remove the last item from a list: l.pop() #remove the first item from list l.pop(0) #remove a item and save it to a variable chosen = l.pop() #reverse a lit l.reverse() #sort a list l.sort() #see if an item is in a list if "dog" in l: print("found!") # Find the index of an item l.index("dog") # replace an item at a specific index in a list l[3] = "cat"
Challenge 21
Challenge 21 – Favourite Movies
The user should be asked to enter the names of their 5 favourite movies.
Bronze
- Your program should ask the user to enter 5 movie titles into a list
- Once the user has entered all 5 names, the list contents should outputted back to the user
Silver
- Your program should sort the list into Alphabetical order
Gold
- Your program should ensure that the user’s input is valid, for each movie title entered
22
Challenge 22 – Race Recorder
Write a program that allows the user to enter the names of each person that finishes a running race. The program should then print out the full list of runners in the race, together with their position.
Bronze
- The program should ask the user to enter 5 names
- The program should then print out a list of names, with each runner’s position next to them.
Silver
- The program should be adapted to allow the user to keep entering as many names as they like. The program should stop asking for more names when the user presses enter with an empty name.
- The program should include the option to find a runner’s position in the race, if you enter their name.
Gold
- The program should include menu functions with options for separate screens.
23
Challenge 23 – Shop Takings
Write a program that asks the user to enter the daily takings for a shop, for a week.
Bronze
- The program should ask the user to enter 7 values
- The program should store each of the values in a list
- The program should print out the list at the end of the week
- The program should print out the total takings for the week.
Silver
- The program should display the minimum, maximum and average daily takings for the week.
- The program should format the data in a suitable manner (make it look pretty)
Gold
- The program should check the values entered each time to ensure that the are integers and repeat the question until a valid response is entered.
24
Challenge 24 – Card Picker
Bronze
- Create a program that generates a list of the 52 cards from a standard deck of cards, excluding the jokers.
- Your program should then pick a random card from the deck and output the chosen card to the user.
Silver
- Your program should automatically create the list using loops, rather than the whole list of cards being manually typed out.
Gold
- Each time a card is drawn, your program should remove that card from the list, so that it can’t be drawn again.