{Cadaver}6322Late Ripple
10月18日
Ⅰ. Operator(运算符) 1. Assignment operator (赋值运算符) Simple assignment operators: = Compound assignment operators: +=, -=, *=, /= %=, **=, //= 2. Identifier (标识符) a) An identifier is a name given to a variable, function, class or module. b) be a combination of: letters in lowercase (a to z) or uppercase (A to Z),  numbers (0 to 9) , underscores( _ ). c) must start with a letter or an underscore, and cannot start with a number ! d) cannot be “language reserved words” (keywords). 3. Arithmetic operators (算术运算符) +,-,*,/ % # remainder 取模(取余) ** # exponentiation 幂 // # floor division 取整 4.Comparison operators (比较运算符) ==,!=,>,<,>=,<= 5.Logical operators (逻辑运算符) and & or | not …………
Late Ripple
易错点 1. == Vs is # equality Vs identity # 同值异物 Vs 同物 # id() 2.
Late Ripple
重点
Late Ripple
补充 以下截图源 https://www.runoob.com/python/python-tutorial.html [图片][图片][图片][图片][图片]
{Cadaver}6322Late Ripple
10月18日
Ⅱ. Basic data types #type() 1. Boolean (布尔值) Ture False 2. Integer(整型) 3. Float (浮点数) ⅰ) 取整 a.四舍五入 round() eg. b.向上/下取整 math.ceil() math.floor() eg. ⅱ)Convert between int and float int() float() 4. String(字符串) immutable  ordered ⅰ) Basics a. +.* b. in not in ⅱ) Built-in functions a. len() b. ⅲ) Index str[] ⅳ) Slicing string_x [start: stop: step] a) positions are inclusive at the start, but exclusive at the stop. b) step can be specified to specify steps in slicing; the default value of step is 1. ⅴ) String methods # All string methods returns new values. They do not change the original string. a) lower() ,upper() string.lower() string.upper() b> replace() string.replace(oldvalue, newvalue, count) c) count() string.count(value, start, end) d) find() string.find(value, start, end) e) split() string.split(separator, maxsplit) f) startswith(), endswith() string.startswith(value, start, end) string.endswith(value, start, end) g) strip() string.strip(characters) ⅵ) Conversion between data types str() int() float()
Late Ripple
易错点
Late Ripple
重点
Late Ripple
补充 Data type: [图片] Compare strings [图片]
{Cadaver}6322Late Ripple
10月19日
Print formatting 1. Using the Modulo Operator: *% ‘d’ : *integer. ‘f’ or ‘F’ : Float. ‘s’ : String. 2. Using the format() function 3. Using f-Strings
{Cadaver}6322Late Ripple
10月19日

Escape sequences (转义字符串)

\n – Newline (换行).

\t- Horizontal tab (Tab键/四个空格).

\r- Carriage return (回车符:将光标移到行首,覆盖等长的旧内容,超过新内容长度的旧内容部分会保留;不改变原内容).(常用于动态显示/更新进度)

\b- Backspace (退格删除).

\f- Form feed (换页符,很少用).

\'- Single Quote (单引号).

\"- double quote (双引号).

\\-Backslash (反斜杠).