作业系统链接
Python 是一门面向对象友好的语言,支持多种内置数据类型,包括整数(int)、浮点数(float)、布尔值(bool)、字符串(str)、列表(list)、元组(tuple)、集合(set)、字典(dict)、复数(complex)、函数(function)和模块(module)。Python 还提供了一些内置常数,如True、False、None、math.pi、math.e、math.tau、math.inf和**-math.inf**。运算符的运作方式会受到运算数据的类型的影响,例如整除(//)和模运算(%)。Python 的逻辑运算采用短路求值,确保在某些情况下不会执行可能导致崩溃的代码。此外,**isinstance()函数比type()**函数更具有稳健性,特别是在处理继承关系时。1
📊表格速览
| 主题 | 关键信息 | 信息颗粒度细化 |
|---|---|---|
| Python 数据类型和操作 | 整数 (int) | type(2) 返回 <class 'int'> |
| 浮点数 (float) | type(2.2) 返回 <class 'float'> | |
| 布尔值 (bool) | type(2 < 2.2) 返回 <class 'bool'> | |
| 类型 (type) | type(type(42)) 返回 <class 'type'> | |
| 字符串 (str) | type("2.2") 返回 <class 'str'> | |
| 列表 (list) | type([1, 2, 3]) 返回 <class 'list'> | |
| 元组 (tuple) | type((1, 2, 3)) 返回 <class 'tuple'> | |
| 集合 (set) | type({1, 2}) 返回 <class 'set'> | |
| 字典 (dict) | type({1: 42}) 返回 <class 'dict'> | |
| 复数 (complex) | type(2 + 3j) 返回 <class 'complex'> | |
| 函数 (function) | type(f) 返回 <class 'function'> | |
| 模块 (module) | type(math) 返回 <class 'module'> | |
| 内置常数 | True | 布尔真值 |
| False | 布尔假值 | |
| None | 空值 | |
| math.pi | 数学常数 π | |
| math.e | 数学常数 e | |
| math.tau | 数学常数 τ | |
| math.inf | 浮点正无穷大 | |
| 内置运算符 | 算术运算符 | +, -, *, /, //, **, % |
| 关系运算符 | <, <=, >=, >, ==, != | |
| 赋值运算符 | +=, -=, *=, /=, //=, **=, %= | |
| 逻辑运算符 | and, or, not | |
| 整除和模运算 | 整除 (//) | 5 // 3 返回 1 |
| 模运算 (%) | 5 % 3 返回 2 | |
| 类型影响语义 | 运算符优先级 | 2 + 3 * 4 返回 14 |
| 短路求值 | no() and crash() 成功运行 | |
| type() vs isinstance() | type() | type("p2s") == str 返回 True |
| isinstance() | isinstance("p2s", str) 返回 True | |
| isNumber() | isinstance(x, numbers.Number) 判断是否为数字 |

📍名词解释
- 整数 (Integer):在Python中,整数是一种基本数据类型,用于表示没有小数部分的数值。例如,
2是一个整数。 - 浮点数 (Float):浮点数是Python中用于表示带有小数部分的数值的数据类型。例如,
2.2是一个浮点数。 - 布尔值 (Boolean):布尔值是Python中用于表示逻辑真假的数据类型,只有两个值:
True和False。 - 类型 (Type):在Python中,类型是一种用于描述数据类型的对象。例如,
type(42)返回<class 'int'>,表示42是一个整数类型。 - 整除 (Integer Division):整除是Python中的一种除法操作,结果为整数,舍弃余数。例如,
5 // 3的结果是1。



















