詹惠儿

2018-12-18   阅读量: 608

数据分析师 Python编程

python常用的运算函数(2)

扫码加入数据分析学习群

4. truediv(a,b): - 此函数返回给定参数的除法
操作 - a / b。

5. floordiv(a,b): - 这个函数也返回给定参数的除法。但是值是floored值,即返回最大的小整数
操作 - a // b。

6. pow(a,b): - 此函数返回给定参数的取幂
操作 - a ** b。

7. mod(a,b): - 此函数返回给定参数的模数
操作 - a%b。

# Python code to demonstrate working of

# truediv(), floordiv(), pow(), mod()

# importing operator module

import operator

# Initializing variables

a = 5

b = 2

# using truediv() to divide two numbers

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

print (operator.truediv(a,b))

# using floordiv() to divide two numbers

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

print (operator.floordiv(a,b))

# using pow() to exponentiate two numbers

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

print (operator.pow(a,b))

# using mod() to take modulus of two numbers

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

print (operator.mod(a,b))

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

评论(0)


暂无数据

推荐课程

推荐帖子