热线电话:13121318867

登录
2019-01-07 阅读量: 637
python中的数学函数(3)

5. copysign(a,b): - 此函数返回值为“a”但带有“b”符号的数字。返回的值是float类型。

6. gcd(): - 此函数用于计算其参数中提到的2个数字的最大公约数。此函数适用于python 3.5及更高版本

# Python code to demonstrate the working of

# copysign() and gcd()

# importing "math" for mathematical operations

import math

a = -10

b = 5.5

c = 15

d = 5

# returning the copysigned value.

print ("The copysigned value of -10 and 5.5 is : ", end="")

print (math.copysign(5.5, -10))

# returning the gcd of 15 and 5

print ("The gcd of 5 and 15 is : ", end="")

print (math.gcd(5,15))

0.0000
2
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子