EN
Python - arithmetic operators
0 points
In this article, we would like to show you arithmetic operators in Python.
Operator | Example | Name |
---|---|---|
+ | a + b | addition |
- | a - b | subtraction |
* | a * b | multiplication |
/ | a / b | division |
% | a % b | modulus |
** | a ** b | exponentiation |
// | a // b | floor division |
xxxxxxxxxx
1
a = 3
2
b = 2
3
4
# results
5
print(a + b) # 5
6
print(a - b) # 1
7
print(a * b) # 6
8
print(a / b) # 1.5
9
print(a % b) # 1
10
print(a ** b) # 9
11
print(a // b) # 1
Output:
xxxxxxxxxx
1
5
2
1
3
6
4
1.5
5
1
6
9
7
1