pyvec / pyvec/naucse.python.cz
Strings: Justify zero-based indexing
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Keine Sprachdaten
- Sterne
- 335
- Forks
- 119
- Ø Merge
- 3 Std. 6 Min.
- Gemergte PRs (30 T.)
- 1
Beschreibung
As reported by @Kobzol in #628:
Maybe we should attempt to justify zero-based indexing without resorting to statements such as "it's black magic"? Pointer-based reasoning is too complex and also not really applicable to Python, but maybe we can find better justifications.
There are multiple reasons why 0-based indexing is useful (open-closed intervals, multi-dimensional indexing, arrays represented with pointers to their first element, using modulo to calculate indices etc.). Some of them are too difficult for this part of the course, but maybe we can pick some examples that they can understand? Or if we can't find any, say that we will show some examples later and add specific references to zero-based indexing later. For example:
Jak sis možná už všiml{{a}}, programátoři počítají od nuly.
...
Proč je tomu tak? Zjednodušeně řečeno je to z mnoha důvodů praktičtější.
Některé důvody jsou zatím moc komplikované a odkážeme se na ně později, ale prozatím si například můžeš všimnout, že:
<< intuitivní a jednoduchý příklad >>
<< např.: K indexování používáme v Pythonu celá čísla. Kladné indexy nám vrací prvky od začátku řetězce, záporné indexy prvky od konce řetězce, ale pokud bychom začali počítat od jedničky, jaký prvek by poté vrátil index 0? Bylo by nepraktické mít hodnotu indexu, která by nikdy nebyla validní >>
Počítání od nuly se používá ve většině programovacích jazyků, a i když ti prozatím může přijít zvláštní, časem si na něj určitě zvykneš. Můžeš si to představovat tak, že (kladný) index N udává počet prvků od začátku řetězce/pole, o které se musíš posunout, aby ses dostal(a) k žádanému prvku.
Later, for example in slicing/substrings (s[0:n]), we can refer to this with something like "Zde je příklad toho, proč je indexování od 0 přirozenější" and talk about open-closed intervals.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Lokalisieren Sie das Kursmaterial, in dem zero-based indexing erstmals eingeführt wird, und lesen Sie die späteren Abschnitte zu slicing oder substring, auf die im Issue verwiesen wird. Verfassen Sie eine für Anfänger geeignete Begründung mit einem konkreten Beispiel und einem späteren Querverweis. Überprüfen Sie anschließend, dass die Erklärung mit der umgebenden Lektion konsistent ist und klar erläutert, was Lernende verstehen sollten.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- content, documentation
- Issue-Typ
- Dokumentation
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100