Notes

  • Variables:
    • Strings and Integers will be important while word embedding
  • Collection Types:
    • lists: ordered
    • tuples
    • set: unordered - tho order is not , no duplicates
    • dictionary:
  • Syntax:
    • indentations carry meaning
    • whitespaces around operators make your code easier to read & understand
    • colons indicate blocks
  • Conditionals:
    • “if” statement
    • “if - else” statement
    • “if - elif - else” statement

Cheatsheet for Data Types and Data Structures in Python

NameTypeCategoryExampleTrickMutable
stringstrtext"William"quotesno
integerintnumber1no decimalno
floatfloatnumber1.1with decimalno
BooleanboolbooleanTrueTrue or Falseno
listlistsequence[1, 1.1, "one"][]yes
tupletuplesequence(1, 1.1, "one")()no
setsetsequence{1, 1.1, "one"}{} - uniqueyes
dictionarydictmapping{"name": "tom"}{key:value}yes

Working with Strings as Data

  • String Methods
    • string.upper() — LIKE THIS.
    • string.lower() — like this.
    • string.capitalize() — Like this.
    • string.replace(“the thing to replace”, “the thing you want to replace it with”)
    • string.split(“argument to split from”)

Cheatsheet for Mathematical Operations

operationcodedescriptionexampleresult
addition+adds numbers together1+12
subtraction-subtracts one number from another1-10
multiplication*multiplies two numbers1*22
exponential multiplication**performs exponential multiplication2**24
division/divides one number from another2/21
modulo%remainder2%71
floor//occurences2//73

Mutability vs Immutability

  • mylist.append(“one”)