詹惠儿

2018-12-18   阅读量: 599

数据分析师 Python编程 Python数据分析

python常用的运算函数(1)

扫码加入数据分析学习群

Python为模块“operator”下的许多数学,逻辑,关系,按位等操作预定义了函数。下面介绍一些常用的运算函数。

1.加(A,B) :-该函数返回另外的给定的参数。
操作 - a + b。

2. sub(a,b): - 此函数返回给定参数的差异
操作 - a - b。

3. mul(a,b): - 此函数返回给定参数的乘积

操作 -a * b。

# Python code to demonstrate working of

# add(), sub(), mul()

# importing operator module

import operator

# Initializing variables

a = 4

b = 3

# using add() to add two numbers

print ("The addition of numbers is :",end="");

print (operator.add(a, b))

# using sub() to subtract two numbers

print ("The difference of numbers is :",end="");

print (operator.sub(a, b))

# using mul() to multiply two numbers

print ("The product of numbers is :",end="");

print (operator.mul(a, b))

输出:

添加CDA认证专家【维克多阿涛】,微信号:【cdashijiazhuang】,提供数据分析指导及CDA考试秘籍。已助千人通过CDA数字化人才认证。欢迎交流,共同成长!
0.0000 0 2 关注作者 收藏

评论(0)


暂无数据

推荐课程

推荐帖子