Krivalar Tutorials 
Krivalar Tutorials

Python - Arithmetic Operators



<< Comment   Assignment Operators >









  • The operator is a special symbol that performs the computation like addition, subtraction, multiplication, and division.
  • The operand is the value at which the operator can perform operations.

Python supports different kinds of operators that follow.

  • Arithmetic Operators
  • Assignment Operator
  • Comparison Operators (or) Relational Operators
  • Logical Operators
  • Bitwise Operators
  • Membership Operator
  • Identity Operators

Arithmetic Operators

Python uses the Arithmetic operator to perform mathematical calculations(+, -, *, / and ** such as addition, subtraction, multiplication, division and exponentiation) on two or more operands. In Python, the "^" symbol is used for the bitwise operator(XOR). But in other languages, the "^" symbol is used for the exponentiation operator.

Sno Operator Meaning Example
1 Addition (+) Add the values of two operands and store the result on the third operand A=10 B=20 C=a+ b print(C)
2 Subtraction (-) Subtract the value of the right-hand operand from the value of the left-hand side and store the result on the third operand C = a- b
3 Multiplication (*) Multiply the values of two operands and store the result on the third one L = a * b
4 Division(/) Divides numerator operand by denominator operand C=a/b
5 Floor division(//) Floor division is applied on two integer operands and the result is a quotient in which the floor division cut off the fractional part. If either of the operands is a floating point, the result of the floor division is also floated. C = a//b
6 Modulus(%) Perform modulus operation with two operands and return the remainder C=a%b
7 Exponent(**) Calculate the power on the given operand C=a**2

Example Program with Arithmetic Operators

>> a=30
>> b=25
>> # Add  a & b and store the result in c
>> # print the result c
>> c=a+b
>> print(c)
55
>> # Subtract  b from a and store the result in c
>> # print the result c
>> c=a-b
>> print(c)
5
>> # Multiply  a & b and store the result in c
>> # print the result c
>> c=a*b
>> print(c)
750
>> # Divide a by b and store the result in c
>> # print the result c

>> c=a/b
>> print(c)
1.2
>> # Perform modulus operation and store the result in c
>> # print the result c

>> c=a%b
>> print(c)
5
>> # Perform floor division and store the result in c
>> # print the result c

>> c=a//b
>> print(c)
1

< Comment    Assignment Operators >























Searching using Binary Search Tree