OPERATORS IN PYTHON

SAIROSHNI



Operators

Operators are used to perform mathematical and logical operations in the program.

  1. Arithmetic operators
  2. Comparison operators
  3. Assignment operators
  4. Logical operators

Arithmetic Operators:

It is used to perform arithmetic operations between values.

  • Addition(+)
  • Subtraction( -)
  • Multiplication(*)
  • Divide(/)
  • Reminder(%)
  • Floor division(//)
  • Exponent(**)

Comparison Operators:

Comparison operator is used to compare two values and return boolean values true/false as result.
  • Less than(<)
  • Less than or equal to(<=)
  • Greater than(>)
  • Greater than(>=)
  • Equal to(==)
  • Not equal (!=)

Assignment Operators:

  It is used to assign values on the right side to the left side variable.
OPERATOR OPERATOR EQUIVALENT EXPRESSION(m=15) RESULT
(=) y=a+b y=10+20 30
(+=) m+=10 m=m+10 25
(-=) m-=10 m=m-10 5
(*=) m*=10 m=m*10 150
(/=) m/=10 m=m/10 1.5
(%=) m%=10 m=m%10 5
(**=) m**=10 m=m^2 22.5
(//=) m//=10 m=m//10 1


Logical Operators:

           Logical operator is used to evaluate expressions and to make decisions.
OPERATOR MEANING EXAMPLE RESULT
AND Logical and (5<2 and="">3) false
OR Logical or (5<2 or="">3) true
NOT Logical not not(5>2) true





More topic in Python

Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send