File type: the
.py python源文件 由python解释器执行.pyc python源码编译后生成的文件(字节代码)编译方法: 源码文件中使用py_compile模块 import py_compile py_complie.compile(‘***.py‘) .pyo python源码优化编译后后文件 python -O -m compile ***.py (无需要源码中使用 compile模块) -O 表示优化 -m 表示模块
Python variables
A variable is an area of computer memory that can store values within a specified range, and the value can be changed
The python under variable is a reference to a data
Variable
The python under variable is a reference to a data
Variable assignment is an area that points to a variable
Change the value of a variable to point to another area
Variable assignment does not need to declare a variable type, it automatically determines the type based on the value
Built-in functions
id() 内置函数 查看内存地址type() 内置函数 查看类型从键盘读取输入input("提示符") 字符串需用‘‘,适用于数字raw_input(“提示符”) 将所有输入做为字符串 建议使用
Assignment operators:
= x = 2 将2赋于x+= x += 2 <=> x = x + 2-= x -= 2 <=> x = x - 2*= x *= 2 <=> x = x * 2/= x /= 2 <=> x = x / 2%= x %= 2 <=> x = x % 2 ```### 算术运算符:
- Connecting two number addition operations concatenate two strings, stitching strings
- Subtraction
- Multiplication
/Division A number is a floating point and the result shows the number of decimal parts 4.0/3
Divisible
% take-up
* * exponentiation
### 关系运算符:(返回值为布尔值 true fales)
Greater than
Less than
= greater than or equal to
<= less than or equal to
= = constant equals
! = does not equal
### 逻辑运算符
Add logic with True and False
or logical OR False or True
Not Logic not True
### 格式化字符串
%s
Print "%s +%s =%s"% (3, 4, 3+4)
Output:3 + 4 = 7
```
Python Basics Review-1-1 file types, variables, operators, expressions