Python_Crashkurs/README.md
2026-03-06 04:43:49 +01:00

42 lines
740 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Python_Crashkurs
## Aufgabe 1 Truthiness von Listen
Erstelle ein Python-Programm, das mit der Truthiness von Listen arbeitet.
### Schritt 1
Erstelle eine Liste:
```python
numbers = [0, 1, 2, 3, 4, 5]
```
### Schritt 2
Prüfe mit einer `if`-Abfrage, ob die Liste **nicht leer** ist.
Wenn sie Elemente enthält, soll folgendes ausgegeben werden:
```
List contains elements
```
### Schritt 3
Setze anschließend die Liste auf eine leere Liste:
```python
numbers = []
```
### Schritt 4
Prüfe erneut, ob die Liste leer ist.
Wenn sie leer ist, soll folgendes ausgegeben werden:
```
List is empty
```
## Zusatzfrage
Was gibt folgendes Programm aus?
```python
x = []
if x:
print("A")
else:
print("B")
```
Begründe kurz warum.