Python Operators
In Python, operators are special symbols or characters that perform specific operations on operands (variables or values). Python provides various types of operators to manipulate and perform calculations on data. Here are the different types of operators in Python:
- Arithmetic Operators:
- Addition: ‘+’
- Subtraction: ‘-‘
- Multiplication: ‘*’
- Division: ‘/’
- Floor Division: ‘//’
- Modulo: ‘%’
- Exponentiation: ‘**’
- Assignment Operators:
- Assignment: ‘=’
- Addition assignment: ‘+=’
- Subtraction assignment: ‘-=’
- Multiplication assignment: ‘*=’
- Division assignment: ‘/=’
- Modulo assignment: ‘%=’
- Floor division assignment: ‘//=’
- Exponentiation assignment: ‘**=’
- Comparison Operators:
- Equal to: ‘==’
- Not equal to: ‘!=’
- Greater than: ‘>’
- Less than: ‘<‘
- Greater than or equal to: ‘>=’
- Less than or equal to: ‘<=’
- Logical Operators:
- Logical AND: ‘and’
- Logical OR: ‘or’
- Logical NOT: ‘not’
- Bitwise Operators:
- Bitwise AND: ‘&’
- Bitwise OR: ‘|’
- Bitwise XOR: ‘^’
- Bitwise NOT: ‘~’
- Left shift: ‘<<‘
- Right shift: ‘>>’
- Membership Operators:
- In: ‘in’
- Not in: ‘not in’
- Identity Operators:
- Is: ‘is’
- Is not: ‘is not’
These are the fundamental operators in Python. They allow you to perform arithmetic calculations, assign values, compare values, perform logical and bitwise operations, check membership, and check object identity.