Home>Article>Backend Development> What does "//" mean in python

What does "//" mean in python

王林
王林 Original
2020-07-04 10:27:20 193795browse

"//" in python is an arithmetic operator, indicating integer division, which can return the integer part of the quotient (rounded down). The specific usage is as follows: [a = 10 b = 5 c = a//b], and the result is an integer 2.

What does

In python, "//" is an arithmetic operator, indicating integer division, which can return the integer part of the quotient (rounded down).

(Recommended learning:python tutorial)

Code example:

#!/usr/bin/python # -*- coding: UTF-8 -*- a = 10 b = 5 c = a//b print "7 - c 的值为:", c

Output result:

7 - c 的值为: 2

Note: Python2.x Here, dividing an integer by an integer can only produce an integer. If you want to get the decimal part, just change one of the numbers to a floating point number.

The above is the detailed content of What does "//" mean 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