Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
| de:modul:m319:learningunits:lu99:loesungen:xmas [2025/10/27 09:10] – angelegt msuter | de:modul:m319:learningunits:lu99:loesungen:xmas [2025/10/27 09:12] (aktuell) – msuter | ||
|---|---|---|---|
| Zeile 2: | Zeile 2: | ||
| <WRAP center round info 60%> | <WRAP center round info 60%> | ||
| - | Die einzelnen Lösungsschritte sind jeweils in einer eigenen Funktion realisiert | + | Die einzelnen Lösungsschritte sind jeweils in einer eigenen Funktion realisiert. |
| + | Zum Testen einer bestimmten Funktion, ändern Sie den Aufruf in '' | ||
| </ | </ | ||
| - | {{gh>https://github.com/teacher-python/m319-lb01-a01-xmas/ | + | <code python> |
| + | def make_tree(): | ||
| + | """ | ||
| + | prints an Xmas tree | ||
| + | :return: None | ||
| + | """ | ||
| + | step3() | ||
| + | |||
| + | def step1(): | ||
| + | height = int(input(' | ||
| + | lines = 1 | ||
| + | while lines <= height: | ||
| + | print() | ||
| + | lines += 1 | ||
| + | |||
| + | def step2(): | ||
| + | height = int(input(' | ||
| + | lines = 1 | ||
| + | while lines <= height: | ||
| + | symbols = 0 | ||
| + | while symbols < (height - lines): | ||
| + | print(' | ||
| + | symbols += 1 | ||
| + | print() | ||
| + | lines += 1 | ||
| + | |||
| + | def step3(): | ||
| + | height = int(input(' | ||
| + | lines = 1 | ||
| + | while lines <= height: | ||
| + | symbols = 0 | ||
| + | while symbols < (height | ||
| + | print(' | ||
| + | symbols += 1 | ||
| + | counter = 0 | ||
| + | while counter < (lines * 2 - 1): | ||
| + | print(' | ||
| + | counter += 1 | ||
| + | print() | ||
| + | lines += 1 | ||
| + | |||
| + | def step4(): | ||
| + | height = int(input(' | ||
| + | lines = 1 | ||
| + | while lines <= height: | ||
| + | symbols = 0 | ||
| + | while symbols < (height | ||
| + | print(' | ||
| + | symbols += 1 | ||
| + | counter = 0 | ||
| + | while counter < (lines * 2 - 1): | ||
| + | print(' | ||
| + | counter += 1 | ||
| + | print() | ||
| + | lines += 1 | ||
| + | |||
| + | indent = 0 | ||
| + | while indent < (height - 1): | ||
| + | print(' | ||
| + | indent += 1 | ||
| + | print (' | ||
| + | |||
| + | |||
| + | if __name__ == ' | ||
| + | make_tree() | ||
| + | </ | ||