加减乘除四种的调用函数
时间: 2023-12-19 15:31:54 浏览: 80
函数调用-加减乘除的基础应用
以下是加减乘除四种的调用函数演示:
1. 加法函数
```python
def addition(a, b):
return a + b
# 示例
result = addition(5, 3)
print(result) # 输出:8
```
2. 减法函数
```python
def subtraction(a, b):
return a - b
# 示例
result = subtraction(10, 4)
print(result) # 输出:6
```
3. 乘法函数
```python
def multiplication(a, b):
return a * b
# 示例
result = multiplication(7, 3)
print(result) # 输出:21
```
4. 除法函数
```python
def division(a, b):
if b != 0:
return a / b
else:
return "除数不能为0"
# 示例
result = division(15, 5)
print(result) # 输出:3.0
```
阅读全文