category: Python
---
-### Lists
+### Tuples (immutable)
+
+ tuple = ()
+
+### Lists (mutable)
list = []
list[i:j] # returns list subset
list[-1] # returns last element
list[:-1] # returns all but the last element
+ *list # expands all elements in place
list[i] = val
list[i:j] = otherlist # replace ith to jth-1 elements with otherlist
### Dict
+ dict = {}
dict.keys()
dict.values()
"key" in dict # let's say this returns False, then...
dict["key"] # ...this raises KeyError
dict.get("key") # ...this returns None
dict.setdefault("key", 1)
+ **dict # expands all k/v pairs in place
### Iteration
```py
print(file.read()) # read the entire file and set the cursor at the end of file
print file.readline() # Reading one line
-file.seek(0, 0) # place the cursor at the beggining of the file
+file.seek(0, 0) # place the cursor at the beginning of the file
```
### Writing (overwrite)
# It closes the file automatically at the end of scope, no need for `file.close()`.
```
-