Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New Concept & Exercise]: Sequences & Thalia's Tram Troubles #3220

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
First Pass Sequences
A first pass for About.md intro and concept intro.
BethanyG committed Nov 28, 2022
commit b0a9db2a54f352170d3d1a1d98da76166060d240
2 changes: 1 addition & 1 deletion concepts/sequences/.meta/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"blurb": "TODO: add blurb for this concept",
"blurb": "A sequence is an ordered, indexable collection of items. All sequence types support a common set of operations, with lists supporting additional mutable operations. All sequences can be indexed into with bracket notation, copied in whole or in part using slice notation, and iterated over using the \"for item in <sequence>\".",
"authors": ["bethanyg", "meatball133"],
"contributors": []
}
20 changes: 9 additions & 11 deletions concepts/sequences/about.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
# Sequences

A sequence is an ordered, indexable collection of items.
All sequence types support a common set of operations that include `in`/`not in`, `min`/`max`, `.index`, `.count` and `.len`. `lists` support additional mutable operations such as [slice assignment][<url ref here>], .append, `.extend`, `.reverse`, and `.copy`.
All sequences can be iterated over using the `for item in <sequence>` construct.
`for index, item in enumerate(<sequence>)` can be used when both the element index and the element value are needed.
All sequence types support a common set of operations that include `in`/`not in`, `min()`/`max()`, `<sequence>.index`, `<sequence>.count()` and `<sequence>.len()`.
`lists` support additional mutable operations such as [slice assignment][<url ref here>], `.append()`, `.extend()`, `.reverse()`, and `.copy()`.

All sequences can be indexed into using `<sequence>[<index number>]`, copied in whole or in part using `<sequence>[<start_index>:<stop_index>:<step>]`(_a full copy can be made with `<sequence>[:]`), and iterated over using the `for item in <sequence>` construct.
`for index, item in enumerate(<sequence>)` can be used when both the element index and the element value are needed.


Pythons `list`, `tuple`, `str`, `byte`, and `range` types all belong to this wider sequence type.
In the case of `str`, the “collection” is made up of unicode code points.
In the case of `byte`, bytes.
In the case of `byte`, bytes.
Ranges are “collections” of numbers conforming to a `start:stop:step` rule.

Sequences can be copied in whole or in part via slice notation.
copy an object via the "full" slice `[:]`

e = "I am a happy person"

end = e[-6:]

## Sequence operations
## Common Sequence operations

### In operator

16 changes: 15 additions & 1 deletion concepts/sequences/introduction.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
#TODO: Add introduction for this concept.
# Sequences

A sequence is an ordered, indexable collection of items.
All sequence types support a common set of operations that include `in`/`not in`, `min()`/`max()`, `<sequence>.index`, `<sequence>.count()` and `<sequence>.len()`.
`lists` support additional mutable operations such as [slice assignment][<url ref here>], `.append()`, `.extend()`, `.reverse()`, and `.copy()`.

All sequences can be indexed into using `<sequence>[<index number>]`, copied in whole or in part using `<sequence>[<start_index>:<stop_index>:<step>]`(_a full copy can be made with `<sequence>[:]`), and iterated over using the `for item in <sequence>` construct.
`for index, item in enumerate(<sequence>)` can be used when both the element index and the element value are needed.


Pythons `list`, `tuple`, `str`, `byte`, and `range` types all belong to this wider sequence type.
In the case of `str`, the “collection” is made up of unicode code points.
In the case of `byte`, bytes.
Ranges are “collections” of numbers conforming to a `start:stop:step` rule.


4 changes: 2 additions & 2 deletions exercises/concept/thallias-tram-troubles/.meta/config.json
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@
"icon": "tracks-on-tracks-on-tracks",
"authors": ["meatball133","BethanyG"],
"files": {
"solution": ["thallias_tram_troubles.py"],
"test": ["thallias_tram_troubles_test.py"],
"solution": ["sequences.py"],
"test": ["sequences_test.py"],
"exemplar": [".meta/exemplar.py"]
}
}