<jupyter_start><jupyter_text>Chapter 1.  Introduction===================Welcome to Theodore's Awesome Python notebooks!  We are going to start learning Python together in the next few notebooks.  Python is a very powerful language that can be used to build almost any software.  *Trivia*: The original Google search engine was written in Python.1.1  Python as an Awesome CalculatorNormally, when asked to find the product of two numbers like 24 * 3.1415, you would use a calculator or a pencil and paper. Well, how about using the Python shell to perform your calculation? Let’s try by executing this:<jupyter_code>24 * 3.1415<jupyter_output><empty_output><jupyter_text>Notice that when entering a multiplication calculation in Python, you use the asterisk symbol (*) instead of a multiplication sign (×).  You are using what is called a Python "interactive shell" within a Python "notebook" to perform the calculation above. Python OperatorsYou can do multiplication, addition, subtraction, and division in the Python shell, among other mathematical operations that we won’t go into right now. The basic symbols used by Python to perform mathematical operations are called operators, as listed here.| Symbol |  Operations       ||:------------:|-------------------------:|| +            | Addition             || -            | Subtraction         || *            | Multiplication     || /            | Division               | Precedence: Order of OperationsWe use parentheses in a programming language to control the order of operations. An operation is anything that uses an operator. Multiplication and division have a higher "precedence" than addition and subtraction, which means that they’re performed first. In other words, if you enter an equation in Python, multiplication or divi- sion is performed before addition or subtraction.For example, in the following equation, the numbers 3 and 4 are multiplied first, and the number 2 is added to their product.<jupyter_code>2 + 3 * 4<jupyter_output><empty_output><jupyter_text>We can change the order of operations by adding parentheses around the first two numbers, like so:<jupyter_code>(2 + 3) * 4<jupyter_output><empty_output><jupyter_text>Parentheses can be nested, which means that there can be parentheses inside parentheses, like this:<jupyter_code>((2 + 3) * 4) - 5<jupyter_output><empty_output><jupyter_text>In this case, Python evaluates the innermost parentheses first, then the outer ones, and then the final division operator.*** TAKEAWAY ***: Remember that multiplication and division always go before addition and subtraction, unless parentheses are used to control the order of operations. 1.2  VariablesThe word *variable* in programming describes a place to store infor- mation such as numbers, text, lists of numbers and text, and so on. Another way of looking at a variable is that it’s like a label for something.For example, to create a variable named fred, we use an equal sign (=) and then tell Python what information the variable should be the label for. Here, we create the variable fred and tell Python that it labels the number 100 (note that this doesn’t mean that another variable can’t have the same value):<jupyter_code>fred = 100<jupyter_output><empty_output><jupyter_text>To find out what value a variable labels, enter print in the shell, followed by the variable name in parentheses, like this:<jupyter_code>print(fred)<jupyter_output>100<jupyter_text>We can also tell Python to change the variable fred so that it labels something else. For example, here’s how to change fred to the number 200:<jupyter_code>fred = 200
print(fred)<jupyter_output>200<jupyter_text>We can also use more than one label (more than one variable) for the same item:<jupyter_code>fred = 400
john = fred
print(john)<jupyter_output>400<jupyter_text>In this example, we’re telling Python that we want the name (or variable) john to label the same thing as fred by using the equal sign between john and fred. 1.3  Using VariablesLet's use variables to help us keep track of calculations.  Let's say that we want to buy a dozen lollypops in Paris, each of which costs 2.50 euros.  How many US dollars would buying all dozen lollypops cost?<jupyter_code>num_lollypops = 12
unit_cost = 2.5
euro_to_usd = 1.2

total_euros = num_lollypops * unit_cost
total_usd = total_euros * euro_to_usd

print(total_usd)<jupyter_output>36.0<jupyter_text>Some of you would say: ok, who cares?  What if the Euro to USD exchange rate changes to 1.1 Euro to 1 USD.  We just need to update the conversion rate:<jupyter_code>euro_to_usd = 1.1
total_usd = total_euros * euro_to_usd

print(total_usd)<jupyter_output>33.0
{'fraction_non_alphanumeric': 0.06929843381248658, 'fraction_numerical': 0.0167346063076593, 'mean_word_length': 4.589928057553957, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 36, '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': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '548468', 'license': 'MIT', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1243, 'n_words': 612, 'path': '01_Calculations_and_Variables.ipynb', 'repo_name': 'philmui/AwesomePython', 'size': '4661'}