python中remainder

编程入门 行业动态 更新时间:2024-10-14 22:22:02

<a href=https://www.elefans.com/category/jswz/34/1770869.html style=python中remainder"/>

python中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

更多推荐

python中remainder

本文发布于:2024-03-11 16:01:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1729340.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:python   remainder

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!