Module 3 of 6, Python Foundations
Lists, Tuples and Strings
Keep ordered values in lists and tuples, and slice, search and reshape text.
module checksSign in to track
- Lessons complete-, not done
- Lesson quizzes taken-, not done
- Module Labs passed-, not done
- Module exam passed at 80%-, not done
- lessons
- 4
- quiz questions
- 48
- reading time
- 32 min
- exam length
- 15 Q
- coding exercises
- 7
Lessons
- Lists & Indexing OperationsKeep many values in order with lists: index and slice them, change them in place with append, insert, remove and pop, and sort them with sort() or sorted(). 8 min 12 questions
- Tuples & Sequence UnpackingGroup values that belong together with tuples, which cannot be changed, and take them apart again with unpacking, including the star form for the rest. 8 min 12 questions
- Strings & Text RepresentationWork with text as a sequence of characters: write strings in single, double or triple quotes, index and slice them, join and repeat them, and understand why they cannot be changed in place. 8 min 12 questions
- String Methods & Text SanitizationClean and reshape text with string methods: change case, strip spaces, split into words and join them back, find and replace, and test what a string contains. 8 min 12 questions
Lab: write it yourself
Real Python, real checks: write your answer, press Run checks, and keep going until it passes. (3 exercises)
The Lab needs an account. Sign in or create a free ID to run these exercises.
Lab 1: Shopping basket
Starting from ["rice", "oil"], append "dates", then print the whole list followed by its length on one line, like ['rice', 'oil', 'dates'] 3.
Sign in to practise
Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and save your practice. Practice does not award XP.
Lab 2: Top score
Cricket scores: [88, 101, 45]. Print the highest score without sorting the list manually, there is a built-in for that.
Sign in to practise
Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and save your practice. Practice does not award XP.
Lab 3: Vowel census
Count the vowels (a, e, i, o, u) in "learning python".
Sign in to practise
Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and save your practice. Practice does not award XP.
References & Further Reading
Related entries from PyLabs's own reference library.