<jupyter_start><jupyter_text>python behaves like a calculator<jupyter_code>8*8<jupyter_output><empty_output><jupyter_text>Predict the following output<jupyter_code>print((5+5)/25)
print(5 + 5/25)<jupyter_output><empty_output><jupyter_text>python does order of operations, etc. just like a calculator  Most of the notation is intuitive. Write out the following in a cell.  What value to you get?$$ (5 \times 5 + \frac{4}{2} - 8)^{2}$$ Most notation is intuitive.  Only weirdo is that "raise x to the power of y" is given by `x**y` rather than `x^y`.   What is the value of $sin(2)$?<jupyter_code>sin(2)<jupyter_output><empty_output><jupyter_text>Python gives very informative errors (if you know how to read them).  What do you think `NameError` means? `NameError` means that the current python "interpreter" does know what `sin` means To get access to more math, you need `import math`<jupyter_code>import math

math.sin(2)<jupyter_output><empty_output><jupyter_text>Once you have math imported, you have access to a whole slew of math functions.<jupyter_code>print(math.factorial(10))
print(math.sqrt(10))
print(math.sin(math.pi))
print(math.cos(10))
print(math.exp(10))
print(math.log(10))
print(math.log10(10))<jupyter_output><empty_output><jupyter_text>If you want to see what the `math` module has to offer, type `math.` and then hit `TAB`.<jupyter_code># for example
math.<jupyter_output><empty_output><jupyter_text>You can also get information about a function by typing `help(FUNCTION)`.  If you run the next cell, it will give you information about the `math.factorial` function.<jupyter_code>help(math.factorial)<jupyter_output><empty_output><jupyter_text>Variables Predict what will happen.<jupyter_code>x = 5
print(x)
x = 5
x = x + 2
print(x)<jupyter_output><empty_output><jupyter_text>In python "`=`" means "assign the stuff on the right into the stuff on the left."  Predict what will happen.<jupyter_code>x = 7 
5*5 = x
print(x)<jupyter_output><empty_output><jupyter_text>What happened?   `SyntaxError` is something python can't interpret.In python, `=` means store the output of the stuff on the **right** in the variable on the **left**.  It's nonsensical to try to store anything in `5*5`, so the command fails.  Predict what will happen.<jupyter_code>this_is_a_variable = 5
another_variable = 2
print(this_is_a_variable*another_variable)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11148365465213747, 'fraction_numerical': 0.01802179379715004, 'mean_word_length': 6.529968454258675, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, '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': '12288', 'license': 'Unlicense', 'n_tokens_mistral': 843, 'n_tokens_neox': 800, 'n_words': 255, 'path': 'chapters/00_inductive-python/02_python-as-a-calculator.ipynb', 'repo_name': 'lperezmo/pythonic-science', 'size': '2386'}