<jupyter_start><jupyter_text>Types of Operators- Arithematic Operators- Comparsion(relational) Operators- Assignments Operators- Logical Operators- Bitwise Operators- Membership Operators- Identity Operators  Arithematic Operators<jupyter_code>+ Addition
- Subtraction
* multiplication
/ Division
// FLoor division
% Modulus
**power<jupyter_output><empty_output><jupyter_text>- Addition<jupyter_code>2 + 7
2.0 + 5.0
2 + 5.0
'A' + 'B'
['Qasim', 'Hassan'] + ['Muneeb', 'Khan']
(1,2) + (3,4)
{3,4} + {5,6} # addition doesn't support Set addition --> Error Occur
{1 :'A'} + {2:'B'} # addition doesn't support dictionary addition --> Error Occur<jupyter_output><empty_output><jupyter_text>- Subtraction<jupyter_code>5 -3
5.6 -2
[1,2,3,4] - [4,5,6] # subtraction doesn't support list subtraction
{2,4,5,6,7,8} - {6,7} # simple operation of set difference= a-b
{'A','B','C', 'D'} - {'B','D'}
{1: 'A'} - {1:'A'} # subtraction doesn't support dictionary subtraction<jupyter_output><empty_output><jupyter_text>- Multiplication<jupyter_code>4 * 3
3.0 * 2
'A' * 3
['A'] * 3
('aA') * 3
('aA',) * 3
('aA','bB') * 3
[1,2,3,4] * [2,3,4,5]<jupyter_output><empty_output><jupyter_text>- Division<jupyter_code>12/4
12//4<jupyter_output><empty_output><jupyter_text>- Modulus %<jupyter_code>5 * 2 = 10 
12 - 10 = 2<jupyter_output><empty_output><jupyter_text>12 %5<jupyter_code>- power **<jupyter_output><empty_output><jupyter_text>2 ** 3 'A' **3  not supported<jupyter_code>### Comparsion Operators<jupyter_output><empty_output><jupyter_text>== > < >= <= !=<jupyter_code>2 ==3
2 ==2
2 == 2.0
2 == 2.1
 5 > 3
5 >= 3
9 <= 3
'A' > 'B'<jupyter_output><empty_output><jupyter_text>'A' = 65  'Z' =90'a' = 97  'z' = 122'0' = 48  '9' = 57<jupyter_code>print(ord('a'), ord('A'), ord('0'), sep= ' >> ')
print(ord('z'), ord('Z'), ord('9'), sep= " >> ")
chr(65), chr(90)
'qasim' != 'Qasim'
6 <= 5 > 4<jupyter_output><empty_output><jupyter_text>Assignment Operators<jupyter_code>= 
+=
-=
*=
/=
//=
%=<jupyter_output><empty_output><jupyter_text>a = 5 a += 5a = a +5a a,a,a = 5,6,7a a = 5a -= 2a a = 5 a *= 2a a = 5 a /= 5a a = 5a //= 5a a = 5a **a a = 12a %= 5a  a = 'A'a += 'B'a a = [ 1,2,3,4]a += [5,6,7] a<jupyter_code>### Logical Operators
- and  &
- or  |
- not !<jupyter_output><empty_output><jupyter_text>True and True True & True True and False and True not(True) False | True True or Flase user = input()pasward = input()user == 'Admin' and pasward == '123' 'Admin' == 'Admin' and '123' =='123'        True        and    True                   True user = input()pasward = input()(user == 'Admin') & (pasward == '123') 'Admin' == 'Admin' and '234' == '123'        True        and    Fasle                   False user = input()pasward = input()((user == 'Qasim') or\ (user == 'Hassan') or \ (user == 'Muneeb')) and (pasward == '123') user = input()pasward = input()not((user == 'Ali') & (pasward == '123')) not(False) not(True)<jupyter_code>### Bitwise Operators<jupyter_output><empty_output><jupyter_text>1,2,4,8,16,32,64,128,512 ---> bits OPERATOR |	DESCRIPTION          | SYNTAX&	     |   Bitwise AND	     |  x & y|	     |   Bitwise OR	         |  x | y~	     |   Bitwise NOT	     |    ~x^	     |   Bitwise XOR	     |  x ^ y>>	     |   Bitwise right shift |	  x>><<	     |   Bitwise left shift	 |    x<<<jupyter_code># 28 --> 11100
# 29 --> 11101
# ===============
# 28  --> 11100
# ===============
28 & 29 
# a = 10 = 1010 (Binary)
# b = 4 =  0100 (Binary
# ======================
# a|b =    1110 (Binary)

10 | 4
~29
~99
~-30<jupyter_output><empty_output><jupyter_text>MemberShip Operator<jupyter_code>names = ['Qasim', 'Hassan', 'Muneeb', 'Khan'] # without membership operator
i= 0
while i <len(names):
    if names[i] == 'Khan':
        print(True)
        break
    i+=1
'Khan' in names
user = input()

user in 'Pakistan'
'Qasim' not in user
user = input()
user = user.split('-')
user<jupyter_output>Qasim-Hassan<jupyter_text>Identity Operator<jupyter_code>a = '5'
b = 5
c = a
print(a is b)
print(a is c)
id(a) == id (c) #shallow copy
id(a)
id(c)<jupyter_output><empty_output><jupyter_text>Since both a & c are at same place Shallow copy occur In deep copy both have their own Physical address  SUMMARY ***or Operator*** The Python or operator combines two Boolean expressions and evaluates to True if at least one of the expressions returns True. Otherwise, if both expressions are False, then the entire expression evaluates to False.<jupyter_code>print(True or True)      # Evaluates to True
print(True or False)     # Evaluates to True
print(False or False)    # Evaluates to False
print(1 < 2 or 3 < 1)    # Evaluates to True
print(3 < 1 or 1 > 6 )   # Evaluates to False
print(1 == 1 or 1 < 2)   # Evaluates to True<jupyter_output>True
True
False
True
False
True<jupyter_text>***and Operator***The Python and operator performs a Boolean comparison between two Boolean values, variables, or expressions. If both sides of the operator evaluate to True then the and operator returns True. If either side (or both sides) evaluates to False, then the and operator returns False. A non-Boolean value (or variable that stores a value) will always evaluate to True when used with the and operator.<jupyter_code>print(True and True)     # Evaluates to True
print(True and False)    # Evaluates to False
print(False and False)   # Evaluates to False
print(1 == 1 and 1 < 2)  # Evaluates to True
print(1 < 2 and 3 < 1)   # Evaluates to False
print("Yes" and 100)     # Evaluates to True<jupyter_output>True
False
False
True
False
100<jupyter_text>***not Operator***The Python Boolean not operator is used in a Boolean expression in order to evaluate the expression to its inverse value. If the original expression was True, including the not operator would make the expression False, and vice versa.<jupyter_code>print(not True)     # Evaluates to False
print(not False)    # Evaluates to True
print(1 > 2)        # Evaluates to False
print(not 1 > 2)    # Evaluates to True
print(1 == 1)       # Evaluates to True
print(not 1 == 1)  # Evaluates to False<jupyter_output>False
True
False
True
True
False<jupyter_text>***Boolean Values***Booleans are a data type in Python, much like integers, floats, and strings. However, booleans only have two values:- True- False Specifically, these two values are of the bool type. Since booleans are a data type, creating a variable that holds a boolean value is the same as with other data types.<jupyter_code>is_true = True
is_false = False
 
print(type(is_true)) # will output: <class 'bool'><jupyter_output><class 'bool'><jupyter_text>***Comparison Operators***In Python, relational operators compare two values or expressions. The most common ones are:- "<" less than- ">" greater than- "<=" less than or equal to- ">=" greater than or equal too If the relation is sound, then the entire expression will evaluate to True. If not, the expression evaluates to False.<jupyter_code>a = 2
b = 3
print(a < b)  # evaluates to True
print(a > b)  # evaluates to False
print(a >= b) # evaluates to False
print(a <= b) # evaluates to True
print(a <= a) # evaluates to True<jupyter_output>True
False
False
True
True
{'fraction_non_alphanumeric': 0.1502597949726162, 'fraction_numerical': 0.038477741890183964, 'mean_word_length': 4.172113289760349, 'pattern_counts': {'":': 0, '<': 102, '<?xml version=': 0, '>': 108, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '21', 'dir': 'jupyter-structured-clean-dedup', 'id': '588683', 'license': 'MIT', 'n_tokens_mistral': 2760, 'n_tokens_neox': 2536, 'n_words': 808, 'path': 'Day2 operators/.ipynb_checkpoints/Day2 python_operators-checkpoint.ipynb', 'repo_name': 'aiwithqasim/Python-Programmer', 'size': '7121'}