This article mainly introduces the use of truth division and Floor Division in Python3, and analyzes the differences between truth division and Floor division based on the instance form, if you need it, refer to the example in this article to describe the use of real division and Floor Division in python3. We will share this with you for your reference. The details are as follows:
In Python3, there are two division operations: real division and Floor division. The two are classified, as shown in the code:
>>> 10/42. 5 >>>> 10 // 42 >>> 10/4. 02.5 >>>> 10 // 4.02.0
The division of a slash in Python3 is the real division, which is the same as that in other programming languages. the floating point is retained, and the Floor Division is the division that removes the floating point and retains the integer. Therefore, it is called the Floor Division.
For example, when should Floor Division be used.
XSize, ySize = avatar. sizefontSize = min (xSize, ySize) // 11 myFont = ImageFont. truetype ("/Library/Fonts/mongokamono. ttf", fontSize)
Here, xSize and ySize indicate the width and height of the image. fontSize indicates the font size, which must be an integer. Therefore, the Floor is divided by 11 to calculate the integer, from this code, we can see that fontSize is an integer smaller than width, high school, and a smaller proportion to 11.
For more details about the usage and analysis of real division and Floor Division in Python3, please follow the PHP Chinese network!