How to get the remainder in python

藏色散人
Release: 2019-07-01 09:35:26
Original
30395 people have browsed it

How to get the remainder in python

How to get the remainder in python?

In Python, the calculation formula for remainder is no different from other languages: remainder r=a-n*[a//n], where a is the dividend and n is the divisor.

This will involve the dividend or the divisor being a negative number. But as long as you know the principles, you can solve it.

If the divisor is a negative number, the result will also be a negative number.

How to get the remainder in python

Note:

The definition of modulo operation: a % b = a - n*b, n is not greater than a /b The largest integer.

% operator: modulus - returns the remainder of division

//Operator: rounding division - returns the integer part of the quotient (rounded down)

Related recommendations : "Python Tutorial"

The above is the detailed content of How to get the remainder in python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!