Home > Backend Development > Python Tutorial > What does '//' mean in python

What does '//' mean in python

王林
Release: 2020-07-04 10:27:20
Original
194066 people have browsed it

"//" 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 '//' mean in python

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
Copy after login

Output result:

7 - c 的值为: 2
Copy after login

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!

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