Programming task — enter your code and have it checked. There are two types of parts: At the Place-exercises (Part 1, 3, 5) you create the list yourself - the check checks whether the data structure is correct. At the Calculator-exercises
(Part 2, 4, 6) your program reads values input() a; the check feeds in fixed inputs and compares your output character by character. Therefore give there only
what is required (no additional texts). The prompt in input("…") hides the test.
Part 1 — Create a list yourself
You determine the values - you don't have to read a list.
Exercise
- Make a list
farbenwith three Favorite colors (strings) - the values you choose yourself, without anyinput(). - Output the entire list.
Do you choose e.g. B. the colors “red”, “blue” and “green” is the output
['rot', 'blau', 'gruen'] (the way Python displays a list). It is checked that farben is a list of three strings and is output unchanged.
Part 1 — Your Code
Loading Python…Tests
Part 2 — Output first element
Index 0 points to the first element.
Exercise
- Lis four integers one after the other with each
int(input())and collect them in a list. - Pass only the first element the list - the first entry is at index 0.
In the inputs 5, 10, 15, 20 the output is exact 5.
Part 2 — Your Code
Loading Python…Tests
Part 3 — Element with append() add
Lists can be expanded later.
Exercise
- Make a list
tierewith three Animals (strings) on — the animals you choose yourself, withoutinput(). - Append a fourth animal with the method
.append()to the listtiereon. - Then output the list.
Do you start e.g. B. with ["Hund", "Katze", "Maus"] and append “bird,” is the output ['Hund', 'Katze', 'Maus', 'Vogel']. It is checked that
tiere after appending four contains strings and is output unchanged.
Part 3 — Your Code
Loading Python…Tests
Part 4 — Output last element
With index -1 reach to the end.
Exercise
- Lis five integers one after the other with each
int(input())and collect them in a list. - Pass only the last element the list — with the index
-1you reach for the end.
In the inputs 1, 2, 3, 4, 5 the output is exact 5. The index -1 always hits the last entry - no matter how long the list is.
Part 4 — Your Code
Loading Python…Tests
Part 5 — Replace the second entry
Assignment by index overwrites the old element.
Exercise
- Put the list
namenwith exactly these three entries (noinput()): “Anna”, “Ben”, “Clara”. - Replace that second entry (Index
1, previously "Ben") with another name of your choice - assign the new value to index 1 via assignment. - Output the changed list.
If you replace “Ben” e.g. B. by “Tom”, becomes ['Anna', 'Ben', 'Clara'] the list
['Anna', 'Tom', 'Clara'] — the index starts at 0, so the second entry is at index 1. The check is that index 1 is no longer there Ben is and the list keeps three strings.
Part 5 — Your Code
Loading Python…Tests
Part 6 — Sum of the first three elements
Calculate multiple index accesses.
Exercise
- Lis four integers one after the other with each
int(input())and collect them in a list. - Calculate the sum of the first three Elements (index 0, 1 and 2) — the fourth number is left out.
- Pass only this sum.
In the inputs 5, 10, 15, 20 the output is exact 30
— the fourth number counts not with.
Part 6 — Your Code
Loading Python…Tests
Report as PDF
Document and download your results.
Module overview
| Part | Status |
|---|---|
| Part 1: Create a list | Open |
| Part 2: First Element | Open |
| Part 3: append | Open |
| Part 4: Last element | Open |
| Part 5: Replace element | Open |
| Part 6: Total | Open |
Not all parts are completed yet - you can still create the report, which will then mark which parts are open.
Download PDF
Enter your name and download the report as a PDF.