See More

1.variables must stary with a letter or underscore_ CASE sensitive!! 2. ** power % remainder / 不是整数除法,就是正常的除 (in python 3) python2 和 c++一样还是整数除法 1+1.0 // 2.0 auto do the float convert for you // --- Interger Division 5//3 #1 10//3 #3 (always round down) 1/2 #0.5 python always get float 2**3 #8 49**0.5 #7 13%2 #1 3. naming_conventions most variables should be lower case, CAPITAL_NAME usually is constants UpperCamelCase : refer to a class "dunder" for double underscore *** 4.string format interpolate #插入 f-strings (python 3.6+) x = 10 formatted = f"I told you {x} times!" #不可以忘了这个f! #you can also do math in the {} # in python 2 .format() --play ground only support it print("the {} is ).format(sth) first = "Colt" last = "Steele" formatted = "First Name: {}, Last Name: {}". format(first, last) #可以直接在string 后加 5.is vs == is check with the memory and == checks value is--checking equality a = 1 a == 1 #True a is 1 #True a = [1,2,3] b = [1,2,3] a == b #True a is b #Flase, they are different objects c = b b is c #True, b and c are pointing to the same stuff a = 13 b = 13 a == b #True a is b #True 6. use # for comments in python ''' for python multiple line comments 7. python use indent to distinguish block, which is 4 spaces, it is better to use space than tab, to avoid difference between different editors 8. python 里的print() 有自动换行功效 9. for installing package in jupyter https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/