# 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)

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.existorlive.cn/kai-fa-yu-yan-xue-xi/python/4.-yun-suan-fu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
