python中remainder_带有Python示例的math.remainder()方法

Python math.remainder() 方法

math.remainder()方法是数学模块的库方法,用于查找给定数字的余数,它接受两个数字(整数或浮点数),并针对浮点数中的第二个数字返回第一个数字的余数。

注意: math.remainder()的新版本的Python中提供了该方法– Python 3.7

它的语法 math.remainder() 方法:

math.remainder(a, b)

Parameter(s): a,b –需要计算其余数的数字。

返回值: float-它返回一个浮点值,该值是a相对于b的余数。

示例

Input:

a = 10

b = 7

# 函数调用

print(math.remainder(a, b))

Output:

3.0

Python代码演示示例 math.remainder() 方法

# python代码演示示例

# math.remainder() method

# 导入数学模块

import math

# 数字

a = 10

b = 7

# 寻找余数

print(math.remainder(a,b))

a = 10.2

b = 7.1

# 寻找余数

print(math.remainder(a,b))

输出结果

3.0

3.0999999999999996

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值