Home >Backend Development >Python Tutorial >What does '//' mean in python?
"//" in python means rounding and dividing, and returns the integer part of the quotient (rounded down). There are other operators in python: " " (addition), "-" (subtraction), "*" (multiplication), "%" (modulo), "/" (division), "**" (power) .
python//Indicates integer division and returns the integer part of the quotient (rounded down)
There are other operators in python:
Add - Add two objects a b Output result 30
- Subtract - Get a negative number or subtract one number from another number a - b Output result -10
* Multiply - Multiply two numbers or return a string repeated several times a * b Output result 200
/ Division - Divide x by y b / a Output result 2
% Modulo - Return the remainder of division b % a Output result 0
** Power - Return x raised to the y power a**b is 20 of 10 Power, the output result is 100000000000000000000
// Divide by integer - return the integer part of the quotient (rounded down)
Example:
#!/usr/bin/python # -*- coding: UTF-8 -*- a = 21 b = 10 c = 0 c = a + b print "1 - c 的值为:", c c = a - b print "2 - c 的值为:", c c = a * b print "3 - c 的值为:", c c = a / b print "4 - c 的值为:", c c = a % b print "5 - c 的值为:", c # 修改变量 a 、b 、c a = 2 b = 3 c = a**b print "6 - c 的值为:", c a = 10 b = 5 c = a//b print "7 - c 的值为:", c
Result:
1 - c 的值为: 31 2 - c 的值为: 11 3 - c 的值为: 210 4 - c 的值为: 2 5 - c 的值为: 1 6 - c 的值为: 8 7 - c 的值为: 2
Recommended tutorial: "python tutorial"
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!