Home  >  Article  >  Backend Development  >  //What does it mean in python?

//What does it mean in python?

藏色散人
藏色散人Original
2019-06-27 10:58:1335489browse

//What does it mean in python?

//What does it mean in python?

In python // means taking integer division and returning the integer part of the quotient (rounded down)

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

Output:

c 的值为: 2

Note:

In Python2.x, dividing an integer by an integer can only result in an integer. If you want to get the decimal part, just change one of the numbers to a floating point number.

>>> 1/2
0
>>> 1.0/2
0.5
>>> 1/float(2)
0.5

Related recommendations: "Python Tutorial"

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