Commit 45f02d76 authored by Loic Huder's avatar Loic Huder
Browse files

Some typo corrections.

parent 2a0c45f5
Pipeline #33207 passed with stage
in 1 minute and 4 seconds
......@@ -6,11 +6,11 @@
Pierre Augier (LEGI), Cyrille Bonamy (LEGI), Eric Maldonado (Irstea), Franck Thollard (ISTerre), Christophe Picard (LJK), Loïc Huder (ISTerre)
# [Data structures](https://docs.python.org/3/tutorial/datastructures.html)
4 built-in containers: list, tuple, set and dict...
4 built-in containers: list, tuple, set and dict.
For more containers: see [collections](https://docs.python.org/3/library/collections.html)...
%% Cell type:markdown id: tags:
......@@ -39,11 +39,11 @@
%% Cell type:markdown id: tags:
### list: mutable sequence
The builtin function `dir` returns a list of name of the attributes. For a list, these attributes are python system attributes (with double-underscores) and 11 public methods:
The built-in function `dir` returns a list of name of the attributes. For a list, these attributes are python system attributes (with double-underscores) and 11 public methods:
%% Cell type:code id: tags:
``` python
......@@ -169,12 +169,12 @@
t0 = ()
t1 = tuple()
assert t0 == t1
# not empty tuple
t2 = (1, 2, 'a') # with the parenthesis
t2 = 1, 2, 'a' # it also works without parenthesis
t2 = (1, 2, 'a') # with the parentheses
t2 = 1, 2, 'a' # it also works without parentheses
t3 = tuple(l3) # from a list
```
%% Cell type:code id: tags:
......@@ -314,17 +314,17 @@
12
%% Cell type:markdown id: tags:
## Complity :
## Complexity :
- line 1: n insertions --> O(n)
- line 2 : n insertions --> O(n)
- line 2: n insertions --> O(n)
- line 3: one traversal O(n), with one lookup at each time (O(1) -> O(n)
-> Complixity of the whole algorithm : O(n)
-> Complexity of the whole algorithm : O(n)
# Complexity of the "sum" solution :
- One traversal for the computation of the sum O(n) with sum at each step O(1) -> O(n)
%% Cell type:markdown id: tags:
......@@ -393,11 +393,13 @@
'value1'
%% Cell type:markdown id: tags:
But warning, `dict` are not ordered (since they are based on a hashtable)!
**Warning:** In general, `dict` are not ordered (since they are based on a hashtable)!
However, since Python 3.6, the implementation changed so that `dict` now keep the order of insertion of keys.
%% Cell type:markdown id: tags:
### `dict`: public methods
......@@ -429,12 +431,11 @@
%% Cell type:code id: tags:
``` python
# loop with items
for key, value in d.items():
if isinstance(key, str):
print(key, value)
print(key, value)
```
%% Cell type:code id: tags:
``` python
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment