Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
| Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung Nächste Überarbeitung | Vorherige Überarbeitung | ||
| gf_informatik:funktionen:aufgaben_c [2026-05-08 06:25] – gra | gf_informatik:funktionen:aufgaben_c [2026-06-12 12:43] (aktuell) – [NC3 – Text rückwärts] gra | ||
|---|---|---|---|
| Zeile 65: | Zeile 65: | ||
| * Zum Beispiel soll der Aufruf '' | * Zum Beispiel soll der Aufruf '' | ||
| * **Verwende eine While-Schleife**, | * **Verwende eine While-Schleife**, | ||
| - | * Hinweis: Python böte mit der [[https:// | + | * Hinweis: Python böte mit der [[https:// |
| * Teste deine Funktion. | * Teste deine Funktion. | ||
| Zeile 72: | Zeile 72: | ||
| * Hinweis: Mit eckigen Klammern können wir zwar einen Buchstaben aus einem String // | * Hinweis: Mit eckigen Klammern können wir zwar einen Buchstaben aus einem String // | ||
| - | === NC5 – Crimson & Clover | + | === NC5 – Crimson & Clover |
| Crimson & Clover ist der Titel [[https:// | Crimson & Clover ist der Titel [[https:// | ||
| Zeile 162: | Zeile 162: | ||
| ==== Lösungen ==== | ==== Lösungen ==== | ||
| - | < | + | < |
| ++++Lösungen zu Aufgaben NC:| | ++++Lösungen zu Aufgaben NC:| | ||
| Zeile 207: | Zeile 207: | ||
| print(f" | print(f" | ||
| </ | </ | ||
| + | |||
| === NC3 === | === NC3 === | ||
| + | <WRAP group> | ||
| + | <WRAP column half> | ||
| + | Variante mit While-Schleife: | ||
| + | |||
| + | <code python> | ||
| + | def text_reverse(text): | ||
| + | new_text = "" | ||
| + | i = len(text)-1 | ||
| + | while i >= 0: | ||
| + | new_text = new_text + text[i] | ||
| + | i = i-1 | ||
| + | return new_text | ||
| + | | ||
| + | print(text_reverse(" | ||
| + | </ | ||
| + | </ | ||
| + | <WRAP column half> | ||
| + | Kurze Variante mit Slice-Syntax (optional): | ||
| + | |||
| + | <code python> | ||
| + | def text_reverse(text): | ||
| + | return text[::-1] | ||
| + | | ||
| + | print(text_reverse(" | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | |||
| + | === NC4 === | ||
| + | <code python> | ||
| + | def replace_spaces(text, | ||
| + | i = 0 | ||
| + | new_text = "" | ||
| + | while i < len(text): | ||
| + | if text[i] == ' ': | ||
| + | new_text = new_text + char | ||
| + | else: | ||
| + | new_text = new_text + text[i] | ||
| + | i = i + 1 | ||
| + | return new_text | ||
| + | |||
| + | print(replace_spaces(" | ||
| + | </ | ||
| + | |||
| + | === NC5 === | ||
| <code python> | <code python> | ||
| import random | import random | ||
| Zeile 259: | Zeile 306: | ||
| </ | </ | ||
| - | === NC3 Zusatzaufgabe=== | + | === NC5 Zusatzaufgabe=== |
| <code python> | <code python> | ||
| import random | import random | ||
| Zeile 315: | Zeile 362: | ||
| | | ||
| i = i + 1 | i = i + 1 | ||
| - | </ | ||
| - | |||
| - | === NC4 === | ||
| - | <WRAP group> | ||
| - | <WRAP column half> | ||
| - | Variante mit While-Schleife: | ||
| - | |||
| - | <code python> | ||
| - | def text_reverse(text): | ||
| - | new_text = "" | ||
| - | i = len(text)-1 | ||
| - | while i >= 0: | ||
| - | new_text = new_text + text[i] | ||
| - | i = i-1 | ||
| - | return new_text | ||
| - | | ||
| - | print(text_reverse(" | ||
| - | </ | ||
| - | </ | ||
| - | <WRAP column half> | ||
| - | Kurze Variante mit Slice-Syntax (optional): | ||
| - | |||
| - | <code python> | ||
| - | def text_reverse(text): | ||
| - | return text[::-1] | ||
| - | | ||
| - | print(text_reverse(" | ||
| - | </ | ||
| - | </ | ||
| - | </ | ||
| - | |||
| - | |||
| - | === NC5 === | ||
| - | <code python> | ||
| - | def replace_spaces(text, | ||
| - | i = 0 | ||
| - | new_text = "" | ||
| - | while i < len(text): | ||
| - | if text[i] == ' ': | ||
| - | new_text = new_text + char | ||
| - | else: | ||
| - | new_text = new_text + text[i] | ||
| - | i = i + 1 | ||
| - | return new_text | ||
| - | |||
| - | print(replace_spaces(" | ||
| </ | </ | ||