initial commit

This commit is contained in:
2023-11-11 11:23:51 -07:00
parent 9068d4bd33
commit 6d6e138210
261 changed files with 23107 additions and 2 deletions

28
random/Dictionary.md Normal file
View File

@@ -0,0 +1,28 @@
# Dictionary
They are also known as mapping type, they map keys to the values.
## What data types you can use for keys in Python dictionary?
Any data type which is immutable can be used as a key. To understand this behavior we would
need to understand how dictionary works behind the scene, which is too
advanced for this course.
For now just remember that immutable data types such as **string, int, float, boolean, tuples,** etc, can be used
as keys.
```python
pizza = {
10: "small",
8.99: "price",
("cheese", "olives"): "toppings",
True: "available",
}
print(pizza[10]) # prints => "small"
print(pizza[8.99]) # prints => "price"
print(pizza[("cheese", "olives")]) # prints => "toppings"
print(pizza[True]) # prints => "available"
```
`pizza` is also a perfectly valid dictionary, but does not have practical usability.