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

//What does it mean in python?

藏色散人
Release: 2019-08-01 15:50:22
Original
35521 people have browsed it

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

Output:

c 的值为: 2
Copy after login

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

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!

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