Python basic - .format & List & Tuples & Dictionaries
Python prefers snake casing
- if you have multiple words inside a variable name, you separate them out by underscores.
ex. name_of_var = 2
print() function
no quotes, no out cell
.format()
insert objects into a string.
Label the variables
The point is that we don't need to worry about the order
List (=arrays in other languages)
Using indexing
- Python supports negative indexing
Changing an item in the list
- 변경 후 run하면 변경사항이 안보이지만, 리스트를 다시 run하면 변경사항이 나타난다.
Appending item in the list
list.append('')
Grabbing an item in the nested list
Dictionaries aka hash tables in other languages
* dictionaries in python do not retain any order
This is a really great way to store things where you need really quick access.
Boolean
False = 0
True = 1
Tuples
- parenthesis 사용
- Tuples are immutable(can't reassign the items
Compare to the list, in Tuples, a user can't change anything inside of this sequence
Sets
- Looks a lot like a dictionary, except there's no key value pair.