OPERATORS ========= ARITHMETIC OPERATORS ==> +, -, *, /,//,%, ** ASSIGNMENT OPERATORS ==> = COMPOUND OPERATOR ==> +=, -=, *=, /=, //=, %= AND **= X = 10 X = X + 10 ==> 20 X += 10 ==> 20 RELATIONAL OPERATORS ==> <, >, <=, >=, == AND != LOGICAL OPERATORS ==> and, or, not &&, ||, ! ==> Java CONDITIONAL OPERATOR/TERNARY OPERATOR identifier = expression1 if condition else expression2 BITWISE OPERATORS INTEGER ==> BITS RIGHT TO LEFT ==> ASSOCIATIVITY &, |, ^, ~, SHIFT OPERATORS SHIFT OPERATORS =============== 1) LEFT SHIFT OPERATOR ==> << ============================= ==> BINARY OPERATOR Syntax: data << n.times ex: 10 << 1 10 << 2 ==> By defining the left shift operation on the data, the data should be double for every time. ==> The Math equation for the left shift operation: data X 2^n.times 2) RIGHT SHIFT OPERATOR ==> >> =============================== ==> Binary Operator Syntax: Data >> n.times ==> By performing the right shift operation on the data, the data should be halved. ==> The Math Equation: data // 2^n.times # left shift operation print(10 << 1) print(10 << 2) print(10 << 3) # Right shift operation print(20 >> 1) print(20 >> 2) print(20 >> 3) ================================ SPECIAL OPERATORS ================== 1) MEMBERSHIP OPERATORS ======================= COLLECTIONS ARE: LIST, TUPLE, SET, STRING, DICTIONARY ETC. "PYTHON" ==> Membership Operators describe: whether the specified element is the part of the collection or not. ==> Return: Boolean Values (True/False) ==> two operators: in not in Syntax: element in collection element not in collection ==> in Operator returns "True", when the specified element is the member of the given collection. Otherwise: it returns "False". ==> not in operator returns "True" when the specified element is not member of the given collection otherwise, it returns: "False" # Membership Check std = "Python Programming" res1 = "pro" in std res2 = "Pro" in std res3 = "pro" not in std res4 = "Pro" not in std print(res1) print(res2) print(res3) print(res4) 2) IDENTITY OPERATORS/ADDRESS OPERATORS ======================================== ==> WHEN TWO MEMEBERS/VARIABLES IN A SAME PROGRAM WITH SAME DATA REPRESENTED WITH SAME ADDRESS. EX: a = 10 b = 10 ==> WHEN TWO VARIABLES IN A SAME PROGRAM WITH DIFFERENT DATA, REPRESENTED WITH DIFFERENT ADDRESSES. Ex: a = 10 b = 20 ==> THE IDENTITY OPERATORS NEED TO CHECK WHETHER THE MEMBERS OF THE PROGRAM WITH SAME ADDRESS OR NOT. ==> TWO OPERATORS: is is not Syntax: member1 is member2 member1 is not member2 is: === True, when both members represented with same address False, when both members with different addresses. is not: ======= True, when both members with different addresses. False, when both members with same address. a = 10 b = 10 c = 10 d = 20 print(id(a)) print(id(b)) print(id(c)) print(id(d)) print(a is b) print(a is c) print(a is d) print(a is not b) print(a is not c) print(a is not d) 3) range() ========== ==> range() is used to generate range of values ex: range(10) ==> 0 to 9 range(10,20) ==> 10 to 19 range(20,10,-1) ==> 20 to 11 print(range(10)) print(range(10,20)) p = range(20) print(p) for i in range(30,20,-1): print(i)