
Python Operator
Python Operators
Operators are inbuilt methodology to execute certain manipulation with the given data or operand. Operand is a Variables or inputs. Operators is a Function to be executed.
Types of Operators
- Arithmetic Operators
- Comparison (Relational) Operators
- Assignment Operators
- Logical Operators
- Bitwise Operators
- Membership Operators
- Identity Operators
Artithmetic Operators:
( +, – , * , //, / , % )
Example:
Input1 = 10Input = 20Output = Input1 + Input 2Print(Output) |
Comparison (or) Relational Opertors:
(< , > , <= , >= , == , !=)
Example:
Input1 = 10Input2 = 20 If Input2>Input1: Print(“Input2 is greater than Input1) |
Assignment Operators:
(+=, *= , -= , %= , /= , //=)
Example:
Count = 0For x in range(10): X += 10 Print(Count) |
Logical operators:
( AND, NOT, OR)
Example:
Input = “Python is programming:For x,y in enumerate(Input): If x%2 == 0 OR y == i: Print(x,y) |
Bitwise Operators:
(&,|,^,~,<<,>>)
Membership Operators:
(IN , NOT IN)
Example:
Input_Data = “Python is programming” Vowels = “aeiou”: For x in Input_Data: If x in Vowels: Print(x) |
Identity Operators:
(IS, NOTIS)
Example:
Input_Data = “Dhoni” Print(Input_Data.isupper()) |