Home  >  Article  >  Backend Development  >  What is the operation symbol of % in python?

What is the operation symbol of % in python?

醉折花枝作酒筹
醉折花枝作酒筹Original
2021-06-25 15:45:2385896browse

In python, "%" is an arithmetic operation symbol, which means to find remainder or modulus and return the remainder of division. For example, "a=5, b=3", the value of "a%b" is 2, take the remainder of dividing a by b.

What is the operation symbol of % in python?

The operating environment of this tutorial: windows7 system, python3 version, Dell G3 computer.

Find remainder/modulo, return the remainder of division, such as a=5, b=3, a%b=2; take the remainder of dividing a by b

#!/usr/bin/python
# -*- coding: UTF-8 -*-

a = 21
b = 10
c = 0


c = a % b
print "5 - c 的值为:", c

The result is:

5 - c 的值为: 1

Extended information:

arithmetic operators

What is the operation symbol of % in python?

Related free learning recommendations:python video tutorial !

The above is the detailed content of What is the operation symbol of % in python?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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
Previous article:What software is python?Next article:What software is python?