> For the complete documentation index, see [llms.txt](https://gitbook.existorlive.cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.existorlive.cn/kai-fa-yu-yan-xue-xi/python/4.-yun-suan-fu.md).

# 4.运算符

#### 1. 算术运算

`/` 运算符返回结果为 浮点数 ， `//` 返回结果为 整数\
​

`**`运算符用于 乘方 运算\
​

```python
>>> 5 + 4  # 加法
9
>>> 4.3 - 2 # 减法
2.3
>>> 3 * 7  # 乘法
21
>>> 2 / 4  # 除法，得到一个浮点数
0.5
>>> 2 // 4 # 除法，得到一个整数
0
>>> 17 % 3 # 取余
2
>>> 2 ** 5 # 乘方
32
```

####

#### 2. 比较运算符

略\
​

#### 3. 位运算符

`~`, `^`, `&`, `|` ，`>>`, `<<` 等 运算符

#### 4. 逻辑运算符

python 中没有 `&&`, `||` , `!` 逻辑运算符

`and` 对应 `&&or` 对应 `||not` 对应 `!`\
​

#### 5. 成员运算符

`in` `not in` 运算符 检查某个元素是否在集合中 (arrray, set, string)\
​

```python
a = 10 
b = 11
array = [1,2,10]

print(a in array)

print(b not in array)

```
