Main Collections - Summary
| Data Type | Ordered | Mutable | Duplicate |
|---|---|---|---|
| list | ✔ | ✔ | ✔ |
| dict | ✔ | ||
| tuple | ✔ | ✔ | |
| set | ✔ |
python --versionpython --version)In a terminal (for example: Git Bash)
pip list # Installed packages
pip install <package> # Install a package
pip install <package>==<version> # Specific version
pip uninstall <package>
# Distribution used
python -c 'import platform; print(platform.python_implementation())'
Data science:
#| eval: true
#| echo: true
note = 18
if note > 16:
print("Validated with honors")
elif note > 10:
print("Validated")
else:
print("Not validated")
#| eval: true
#| echo: true
for i in range(1, 5):
print(i)
#| eval: true
#| echo: true
cpt = 10
while cpt > 0:
print(cpt, end = " ")
cpt -= 1
print("boom")
#| eval: true
#| echo: true
liste = ["Alban", "Bertille", "Corine"]
for i, v in enumerate(liste):
print(f"index {i} : value {v}")
list = ["apple", "pear", 2, True]
recipe = {"strawberry": 5, "Mustard": "5g"}
primes = {2, 3, 5, 7, 11, 13}
coord = (-1, 5, 4)
Note
Many other collection types exist (Tree, Linked List…).
| Data Type | Ordered | Mutable | Duplicate |
|---|---|---|---|
| list | ✔ | ✔ | ✔ |
| dict | ✔ | ||
| tuple | ✔ | ✔ | |
| set | ✔ |
To learn the language, avoid rushing to LLMs.
Prefer:
5 notebooks are available to help you learn the basics of the language: