Lesson 2/6High school~150 min
Lists
Lists of numbers and names: generating random values, sorting, filtering, finding the maximum and reading until an end marker.
You can solve exercises without signing in; sign in and your progress is kept.
After this lesson you'll be able to:
- Build lists with a loop and
append - Sort, reverse and filter lists
- Read values until an end marker (
-1) - Separate randomness from program logic with functions
What you practise here
- List methods: append, pop, remove, …
- len, sum, min, max and sorted
- while loops
- Looping over a list
- Return values: return
- Finding the minimum and maximum
- Formatting output: sep, end, f-strings
- Integer division and remainder: // and %
- Counting and summing in a loop
- Slicing
+ 9
Short tasks that check you understand: multiple choice, predicting the output, finding the bug, completing code.
Start the exercisesReal programming tasks: write a program, run it and submit it to be checked, hidden tests included.
Start the challenges- Write a programElements that occur only onceElementary20 XP
- Small projectShopping basketIntermediate30 XP
- Write a programSki jumpersElementary20 XP
- Write a programFibonacci into a listBasic10 XP
- Write a programEven and odd, sortedElementary20 XP
- Write a programA random list reversedBasic10 XP
- Write a programSum of even numbersBasic10 XP
- Write a programThe second largest numberElementary20 XP
- Write a programVowel or consonantElementary20 XP
- Write a programGuest namesElementary20 XP
- Write a programCommon elements of two listsElementary20 XP
- Write a programEntered values reversedBasic10 XP
- Write a programThe largest and the smallest numberBasic10 XP
- Write a programThe most frequent elementElementaryOptional20 XP