求一个数的除法余数 [英] Find the division remainder of a number

查看:63
本文介绍了求一个数的除法余数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能在 Python 中找到一个数字的除法余数?

How could I go about finding the division remainder of a number in Python?

例如:
如果数为26,被除数为7,则除法余数为5.
(因为 7+7+7=21 和 26-21=5.)

For example:
If the number is 26 and divided number is 7, then the division remainder is 5.
(since 7+7+7=21 and 26-21=5.)

推荐答案

您正在寻找模运算符:

a % b

例如:

26 % 7

当然,也许他们希望你自己实现它,这也不会太难.

Of course, maybe they wanted you to implement it yourself, which wouldn't be too difficult either.

这篇关于求一个数的除法余数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆