1️⃣ Arithmetic Operators
1) Addition(+):
It adds two values and provides their sum.
💻 Example:
1 2 3 | a = 10
b = 20
print(a + b)
|
✅ Output:
30
2) Substraction(-):
It substracts second value from first and provides their difference.
💻 Example:
1 2 3 | a = 10
b = 20
print(a - b)
|
✅ Output:
-10
3) Multiplication(*):
Multiplies two values and provides their product.
💻 Example:
1 2 3 | a = 10
b = 20
print(a * b)
|
✅ Output:
200
4) Division (/):
Divides one value by second and gives their quotient.
💻 Example:
1 2 3 4 | a = 10
b = 20
print(a / b)
print(b / a)
|
✅ Output:
2
0.5
5) Floor Division(//):
It divides one value by second and gives their quotient rounded to the smallest whole number.
💻 Example:
1 2 3 4 5 6 | a = 10
b = 20
c = 35
print(a // b)
print(b // a)
print(c // a)
|
✅ Output:
0
2
3
6) Exponentiation(**):
It raises one value to the power of second.
💻 Example:
1 2 3 4 5 | a = 10
b = 2
c = 3
print(a ** b)
print(a ** c)
|
✅ Output:
100
1000
7) Modulus(%):
It divides one value by second and gives their remainder.
💻 Example:
1 2 3 4 5 6 | a = 10
b = 2
c = 3
print(a % b)
print(a % c)
print(c % b)
|
✅ Output:
0
1
1
Be prepared with below questions prior to your interview !
Frequently asked Interview Questions
What are arithmetic operators in Python?
How do you cube a particular number using python?
How can you floor divide two numbers using python?