<jupyter_start><jupyter_text>Lesson 3: Operators In this lesson, we wil learn about...+ Arithmetic operators+ Assignment operators+ Comparison operators+ Logical operators+ Membership operators  Arithmetic OperatorsThese are used with numbers to perform mathematical operations.<jupyter_code>x = 5
y = 3

print( x + y )
print( x - y )
print( x * y )
print( x / y )
print( x % y )
print( x ** y )
print( x // y )<jupyter_output>8
2
15
1.6666666666666667
2
125
1<jupyter_text>Operator|Name|Notes:---:|:---:|:---:`+`|Addition|`-`|Subtraction|`*`|Multiplication|`/`|Division|Will return `float``%`|Modulus|Remainder of $x\div{}y$`**`|Exponentiation|$x^y$`//`|Integer Division|Truncates decimal  Assignment OperatorsThese work like the arithmetic operators, but variable being assigned is part of the equation.<jupyter_code>x = 5
x += 3
print(x)

x = 5
x -= 3
print(x)

x = 5
x *= 3
print(x)
x = 5
x /= 3
print(x)

x = 5
x %= 3
print(x)

x = 5
x **= 3
print(x)

x = 5
x //= 3
print(x)<jupyter_output>1.6666666666666667
2
125
1<jupyter_text>Operator|Name|Same As:---:|:---:|:---:`+=`|Addition|`x=x+3``-=`|Subtraction|`x=x-3``*=`|Multiplication|`x=x*3``/=`|Division|`x=x/3``%=`|Modulus|`x=x%3``**=`|Exponentiation|`x=x**3``//=`|Integer Division|`x=x//3`  Comparison OperatorsThese are used to compare two values, and always return a `bool`. They become more useful when we talk about `if...else` and loops later on.<jupyter_code>print( 3 == 5 )
print( 3 != 5 )
print( 3 > 5 )
print( 3 < 5 )
print( 3 >= 5 )
print( 3 <= 5 )<jupyter_output>False
True
False
True
False
True<jupyter_text>Logical OperatorsThese are primarily used in `if...else` and loops to combine multiple expressions.<jupyter_code>print( True and False )
print( True or False )
print( not True )<jupyter_output>False
True
False<jupyter_text>`and` Truth Table`x`|`y`|`x and y`:---:|:---:|:---:`True`|`True`|`True``True`|`False`|`False``False`|`True`|`False``False`|`False`|`False` `or` Truth Table`x`|`y`|`x or y`:---:|:---:|:---:`True`|`True`|`True``True`|`False`|`True``False`|`True`|`True``False`|`False`|`False`  Membership OperatorsThese are used to test if a sequence is present in an object. Recall that we saw this with strings, and will again with more complex data structures.<jupyter_code>print( "e" in "Hello" )
print( "e" not in "Hello" )<jupyter_output>True
False
{'fraction_non_alphanumeric': 0.1905781584582441, 'fraction_numerical': 0.035974304068522485, 'mean_word_length': 5.279569892473118, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '196138', 'license': 'MIT', 'n_tokens_mistral': 986, 'n_tokens_neox': 907, 'n_words': 244, 'path': '03-operators/03-operators.ipynb', 'repo_name': 'brandoningli/python-tutorial', 'size': '2335'}