schule:programmieruebungen
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
| schule:programmieruebungen [2019-12-22 09:42] – [Tic Tac Toe] added doctest marco.bakera | schule:programmieruebungen [2021-05-06 18:55] (aktuell) – [Links] elevator challenge: link zu py3 version pintman | ||
|---|---|---|---|
| Zeile 66: | Zeile 66: | ||
| --></ | --></ | ||
| + | ===== Testgetriebene Entwicklung (TDD) ===== | ||
| + | |||
| + | → [[Testgetriebene Entwicklung (Übung)]] | ||
| + | |||
| + | |||
| ===== Unterschiedliche Laufzeiten ===== | ===== Unterschiedliche Laufzeiten ===== | ||
| Zeile 203: | Zeile 208: | ||
| <file python ttt.py> | <file python ttt.py> | ||
| + | ''' | ||
| + | Auf diese Art kann die Klasse verwendet werden: | ||
| + | |||
| + | >>> | ||
| + | >>> | ||
| + | {} | ||
| + | >>> | ||
| + | >>> | ||
| + | >>> | ||
| + | {(1, 1): ' | ||
| + | >>> | ||
| + | False | ||
| + | >>> | ||
| + | False | ||
| + | >>> | ||
| + | >>> | ||
| + | >>> | ||
| + | >>> | ||
| + | True | ||
| + | >>> | ||
| + | False | ||
| + | >>> | ||
| + | {(1, 1): ' | ||
| + | ''' | ||
| + | |||
| import doctest | import doctest | ||
| class TicTacToe: | class TicTacToe: | ||
| - | | + | 'A game of tic tac toe.' |
| - | + | ||
| - | >>> | + | |
| - | >>> | + | |
| - | {} | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | {(1, 1): ' | + | |
| - | >>> | + | |
| - | False | + | |
| - | >>> | + | |
| - | False | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | True | + | |
| - | >>> | + | |
| - | False | + | |
| - | >>> | + | |
| - | {(1, 1): ' | + | |
| - | '' | + | |
| def __init__(self): | def __init__(self): | ||
| Zeile 235: | Zeile 243: | ||
| def place_x_at(self, | def place_x_at(self, | ||
| + | assert 0 <= x <= 2 and 0 <= y <= 2 | ||
| self.stones[(x, | self.stones[(x, | ||
| def place_o_at(self, | def place_o_at(self, | ||
| + | assert 0 <= x <= 2 and 0 <= y <= 2 | ||
| self.stones[(x, | self.stones[(x, | ||
| Zeile 267: | Zeile 277: | ||
| < | < | ||
| + | ''' | ||
| + | Auf diese Art kann die Klasse verwendet werden: | ||
| + | |||
| + | >>> | ||
| + | >>> | ||
| + | {} | ||
| + | >>> | ||
| + | >>> | ||
| + | >>> | ||
| + | {(1, 1): ' | ||
| + | >>> | ||
| + | False | ||
| + | >>> | ||
| + | False | ||
| + | >>> | ||
| + | >>> | ||
| + | >>> | ||
| + | >>> | ||
| + | True | ||
| + | >>> | ||
| + | False | ||
| + | >>> | ||
| + | {(1, 1): ' | ||
| + | ''' | ||
| + | |||
| import doctest | import doctest | ||
| class TicTacToe: | class TicTacToe: | ||
| - | | + | 'A game of tic tac toe.' |
| - | + | ||
| - | >>> | + | |
| - | >>> | + | |
| - | {} | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | {(1, 1): ' | + | |
| - | >>> | + | |
| - | False | + | |
| - | >>> | + | |
| - | False | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | True | + | |
| - | >>> | + | |
| - | False | + | |
| - | >>> | + | |
| - | {(1, 1): ' | + | |
| - | '' | + | |
| def __init__(self): | def __init__(self): | ||
| Zeile 299: | Zeile 312: | ||
| def place_x_at(self, | def place_x_at(self, | ||
| + | assert 0 <= x <= 2 and 0 <= y <= 2 | ||
| self.stones[(x, | self.stones[(x, | ||
| def place_o_at(self, | def place_o_at(self, | ||
| + | assert 0 <= x <= 2 and 0 <= y <= 2 | ||
| self.stones[(x, | self.stones[(x, | ||
| Zeile 356: | Zeile 371: | ||
| ===== Programm, das den eigenen Quelltext ausgibt ===== | ===== Programm, das den eigenen Quelltext ausgibt ===== | ||
| - | Schreibe ein Programm, das den eigenen | + | → [[Eigenen |
| - | Das schöne an dieser Aufgabenstellung ist, dass sie zunächst sehr einfach und nach ein paar Versuchen faktisch unmöglich erscheint. | ||
| - | Versuche dich selbst an einem [[Python]]-Programm, | ||
| - | |||
| - | Wenn du keinen Ansatz findest, kann du den (unvollständigen) Quelltext aus der Fußnote(( | ||
| - | <code python> | ||
| - | source = [ | ||
| - | ' | ||
| - | ... | ||
| - | ] | ||
| - | |||
| - | print(" | ||
| - | for line in source: | ||
| - | print(line, "," | ||
| - | ... | ||
| - | |||
| - | </ | ||
| - | )) nutzen. | ||
| ===== Katas im Randori-Prinzip ===== | ===== Katas im Randori-Prinzip ===== | ||
| Zeile 393: | Zeile 391: | ||
| ===== Links ===== | ===== Links ===== | ||
| + | * Hinter einem [[wpde> | ||
| * [[https:// | * [[https:// | ||
| * Weitere Übungen zur OOP mit Python gibt es [[https:// | * Weitere Übungen zur OOP mit Python gibt es [[https:// | ||
| Zeile 402: | Zeile 401: | ||
| * [[Flagserver]] | * [[Flagserver]] | ||
| * [[https:// | * [[https:// | ||
| + | * Bei der [[https:// | ||
| + | |||
| + | |||
schule/programmieruebungen.1577007759.txt.gz · Zuletzt geändert: von marco.bakera
