<jupyter_start><jupyter_text>Introduction to Comparison OperationsComparison operators allow us to compare values on either side of the operator for numeric values. If we have values that are of mixed types, one of the values will the coerced up the nmeric tower from an integer to a float, or a float to a complex. The result of the comparison is a Boolean (True or False).[There are 8 comparison operations in Python](https://docs.python.org/3/library/stdtypes.htmlcomparisons) but we will focus on the 6 operators that are used frequently for analytics:| Operator | Description | Example | Result || :--- | :----------- |:--- | :----------- ||<|less than|`10 < 20`|`True`|<=|less than or equal to|`10 <= 20`|`True`|>|greater than|`10 > 20`|`False`|>=|greater than or equal to|`10 >= 20`|`False`|==|equal|`10 == 20`|`False`|!=|not equal|`10 != 20`|`True`Comparison operators can be used in a simliar fashion when comparing things like variables or strings as you'll see below.   Numeric comparison<jupyter_code>134>34<jupyter_output><empty_output><jupyter_text>Variable comparison<jupyter_code>a = 10
b = 75
c = 100

if (a == b):
    print('a is equal to b')
else:
    print('a is not equal to b')
    
print('----------------------------')
    
if (a < c):
    print('a is less than to c')
else:
    print('a is not less than to c')
    
print('----------------------------')

if (b > c):
    print('b is greater than to c')
else:
    print('b is not greater than to c')<jupyter_output>a is not equal to b
----------------------------
a is less than to c
----------------------------
b is not greater than to c<jupyter_text>String comparisonWhen using >, >=, <, or <=, Python is comparing the length or number of characters between both strings<jupyter_code>'Adrian'>='Javier'
'Adrian'<='Javier'<jupyter_output><empty_output><jupyter_text>When using == or !=, Python compares the the two strings character by character<jupyter_code>'Adrian'=='Adrian'
'adrian'=='Adrian'
'adrian'!='Adrian'<jupyter_output><empty_output><jupyter_text>Introduction to Arithmetic OperationsYou can perform arithmetic operations like addition, subtraction, multiplication, and division.The following are arithmetic operators that Python supports:| Operator | Description | Syntax | Example |Result|| :--- | :----------- |:--- | :----------- |:----------- || + | Addition | x+y |1 + 2|3| - | Subtraction |x-y|2 - 1|1| * | Multiplication |x*y|2 * 2|4| / | Division (float) |x/y|100 / 9|11.11..| // | Division (floor) |x // y|100 // 9|11| % | Modulus - Returns the remainder when left operand is divided by the right operand |x % y|100 % 9|1| ** | Power |x**y|2 ** 5|32<jupyter_code># Addition
52+10
# Subtraction
52-10
# Multiplication
52*10
# Division
52/10
# Modulus
# Commonly used to tell if a number is even or odd
52%10
# Power
52**10<jupyter_output><empty_output><jupyter_text>Solving a problem using variablesLet's try to solve the following problem using variables> A clothing store sells t-shirts for $10 and makes 25% profit from each sale. If the store sells 500 t-shirts this weekend, how much total profit does it make?Seems like a relatively straightforward calucation<jupyter_code>500 * (.25 * 10)<jupyter_output><empty_output><jupyter_text>So the clothing storee will make a total profit of $1250. While this is a straightfoward way to solve this problem, looking at the code, it's not clear what each number represents. One way of solving this problem is by assigning each value into a variable.<jupyter_code>cost_of_shirt = 10
profit_margin = .25
number_of_shirts_sold = 500<jupyter_output><empty_output><jupyter_text>After running the cell above, our three variables now conatin the information provided in the word problem. We check that our variables contain the correct values by running each of them<jupyter_code>cost_of_shirt
profit_margin
number_of_shirts_sold<jupyter_output><empty_output><jupyter_text>Let's combine our variables using the arithmetic operations to create a new variable we will call `total_profit`<jupyter_code>total_profit = number_of_shirts_sold * (profit_margin * cost_of_shirt)
total_profit<jupyter_output><empty_output><jupyter_text>Let's use the `print` function to display a clear message of what our stores total profit is<jupyter_code>print("The clothing store made a total profit of $", total_profit)<jupyter_output>The clothing store made a total profit of $ 1250.0
{'fraction_non_alphanumeric': 0.13886363636363636, 'fraction_numerical': 0.028409090909090908, 'mean_word_length': 4.226840855106889, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 49, 'https://': 1, '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': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '103819', 'license': 'MIT', 'n_tokens_mistral': 1427, 'n_tokens_neox': 1301, 'n_words': 497, 'path': 'notebooks/finished/Built-In Operations.ipynb', 'repo_name': 'adi727/Data-Analytics-With-Python', 'size': '4400'}