Day 2 of 100 Days

Day 2: 2018/04/27

Today’s Topic: Python: A byte of python

Today’s Progress: Started from page 57 (end of flow), I went through functions, module, packages, data structure: list, tuple, dictionary, slicing of sequences, set, reference, strings. I stopped on page 88. (end of data structures) And I will start to touch the topic of “problem solving” (more life related, I think) next

Thoughts: Yesterday I thought this would be easy, but today I found that there are so many things that I need to recall (or re-recall? if that’s a word). This book is actually interesting for it teaches the function/module/pacakge BEFORE data structures (list, dictionary etc)

Notes:

  • def function (*param1, **param2) → param1 is a tuple, param2 is dictionary
  • docstring: 1st line starts Capital, ends with dot(.). 2nd line blank. starts 3rd line detailed information.
  • should I use “import X” or “from X import Y”? both are OK, as long as you do not use “from X import *”
  • dir()
  • variable < function < module (if __name__ == ‘__main__’:…) < package (__init__.py)
  • list.sort() vs sorted(list) → list.sort() (or any sequence obj sort) changes the list itself, and sorted(list) returns a new list.
  • empty_duple=(); single_tuple=(2,)
  • dict.items() → give you list of tuples [(key1, value1), (key2, value2) …]
  • membership test: test a in something (a in [a,b,c])
  • word[::-1] → reverse the word
  • string.find(‘sub_string’) → returns index (or -1 if not found)

Link to work: Link to my own Google drive to show my progress here.

This entry was posted in 象哥的學習筆記 Study Notes and tagged . Bookmark the permalink.

Leave a Reply