Professional Documents
Culture Documents
Operators
Types of Operator
• Arithmetic Operators
• Unary Operators
• Comparison (Relational) Operators
• Bitwise Operators
• Assignment Operators
• Membership Operators
• Logical Operators
• Identity Operators
Arithmetic Operators
• + Addition
• - Subtraction
• * Multiplication
• / Division
• %Modulus (Remainder)
• // Floor Division( removes digit after decimal point)
• ** Exponent (Raise to)
The modulus operator
• x != y # x is not equal to y
• x>y # x is greater than y
• x<y # x is less than y
• x >= y x=<y # x is greater than or equal to y
• x <= y # x is less than or equal to y
NOTE: “= is an assignment operator and == is a comparison operator”.
Also, there is no such thing as =< or =>.
Logical operators
• X=true
• Y=false
• Print(“x and y is”,x and y) #output: false
• Print(“x or y is”,x or y) #output: true
• Print(“not x is”,not x) #output: false
•
Bitwise Operators( cannot be applied to float or double variables)
~10101011 = 01010100
Membership Operators