In this Python Tutorial, we are going to learn about Arithmetic Operations in Python on Numbers, there are different Arithmetic Operations that you can do on Python Numbers Data Type, for example you can add numbers, you can divide numbers, you can subtract numbers, you can multiply numbers and also modulus. so Operators are functionality that do something and can be represented by symbols such as + or by special keywords. Operators require some data to operate on and such data is called operands. In this case, 2 and 3 are the operands.
Also you can check More GUI Development Tutorials in the below link.
1: PyQt5 GUI Development Tutorials
2: TKinter GUI Development Tutorials
3: Pyside2 GUI Development Tutorials
4: Kivy GUI Development Tutorials
4: TKinter GUI Development Tutorials
You can watch the complete video for Python Tutorial – Arithmetic Operations in Python
So now in this example, iam going to add two numbers.
1 2 3 4 5 6 7 8 9 |
#two numbers for adding a = 10 b = 4 #add two numbers add = a + b #print the result print("Sum is ", add) |
This is the output
1 2 3 |
Sum is 14 Process finished with exit code 0 |
Also you can do other operations like this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
#two numbers for adding a = 10 b = 4 #add two numbers add = a + b #print the result print("Sum is : ", add) #minus minus = a - b print(" Minus : ", minus) #multiplication multy = a * b print("Multiplication : ", multy) #division div = a / b print("Divison : ", div) |
This is the output
1 2 3 4 5 6 |
Sum is : 14 Minus : 6 Multiplication : 40 Divison : 2.5 Process finished with exit code 0 |
What is Modulo Operation ?
In computing, the modulo operation finds the remainder or signed remainder after division of one number by another. so for example we have two numbers a and b, after division of a and b the remainder of these two numbers are called modulo operation.
So this is the simple example
1 2 3 4 5 6 7 8 9 |
#two numbers for adding a = 10 b = 4 #find the remainder remainder = a % b #print the remainder print(remainder) |
This is the output, we have received 2 because 10 division by 4, the remainder is 2.
1 2 3 |
2 Process finished with exit code 0 |
Subscribe and Get Free Video Courses & Articles in your Email