<jupyter_start><jupyter_text>Welcome to the Python course for beginnersThese notebooks should give you a basic introduction to the Python world, and should help you understand why people keep talking about snakes and pandas.<NAME>, Guck Division, MPL, 2021<jupyter_code># notebook metadata you can ignore!
info = {"tutorial": "basic-data-types",
        "version" : "0.0.2"}<jupyter_output><empty_output><jupyter_text>How to use this notebook- Click on a cell (each box is called a cell). Hit "shift+enter", this will run the cell!- You can run the cells in any order!- The output of runnable code is printed below the cell.- Check out this [Jupyter Notebook Tutorial video](https://www.youtube.com/watch?v=HW29067qVWk).See the help tab above for more information!  Basic Data Types in Python What is in this notebook?In this tutorial we cover:- Comments in python- Basic Data Types   - Textual data (strings)   - Numbers (integers and floats)   - booleans (True and False) ----------- CommentsComments are used to describe your code.Anything following a '' is a comment and is not runnable code.<jupyter_code># this is a comment<jupyter_output><empty_output><jupyter_text>You will also see comments on the same line as code like so:<jupyter_code>1 + 2  # that was some code, but I am a comment!<jupyter_output><empty_output><jupyter_text>You can write multi-line comments with three double quotes (""" the comment """) or three single quotes (''' my comment ''')<jupyter_code>"""
This
is a 

multi-line

comment
"""<jupyter_output><empty_output><jupyter_text>----------- Basic data types: strings, numbers, boolean  Strings (`str`)Strings are textual data. We use them to represent words or any textual information. We can use single quotes or double quotes to make a string<jupyter_code>print("This is a string")
print('This is also a string')<jupyter_output><empty_output><jupyter_text>What if I want to put the following into a string: Jona's message<jupyter_code># this will create an error!

'Jona's message'<jupyter_output><empty_output><jupyter_text>Instead we use single quotes and double quotes together<jupyter_code>"Jona's message"
# using the special escape character '\' will also work, but isn't as clean looking
'Jona\'s message'<jupyter_output><empty_output><jupyter_text>----------- Numbers (integer `int` and floating point `float`)Numbers are easy in Python!<jupyter_code># this is an integer
3
# now let's see a float
3.14
# let's add some numbers together
3 + 3.14

# notice how to output has many trailing zeros! It is called floating point for a reason...<jupyter_output><empty_output><jupyter_text>How to add, divide etc.?- \+ addition- \- subtraction (minus)- \* multiplication- \/ division- \// division (but does not include the remainder - round to whole number)- \% division (but returns the remainder)- \** exponent/power<jupyter_code>print(9 + 3.1)
print(9 - 3.1)
print(9 * 3.1)
print(9 / 4)
print(9 // 4)
print(9 % 4)
print(9 ** 4)<jupyter_output><empty_output><jupyter_text>----------- Boolean (`bool`)Boolean values are rather ... polarising :). Boolean arrays are fast and work well with NumPy!They are written as `True` and `False` in Python.<jupyter_code>print(True, False)
# check what equals True or False in Python
print(1 == True)
print(0 == False)
# what happens when we try True == False?
True == False

# it is indeed False!
# what about adding booleans together?
print(True + True)
print(True + 5)
print(True + 5.45)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11254295532646048, 'fraction_numerical': 0.01288659793814433, 'mean_word_length': 4.773553719008264, 'pattern_counts': {'":': 1, '<': 42, '<?xml version=': 0, '>': 42, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, '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': '161590', 'license': 'MIT', 'n_tokens_mistral': 1097, 'n_tokens_neox': 1037, 'n_words': 423, 'path': 'tutorials/Python-Beginner-01-data-types.ipynb', 'repo_name': 'GuckLab/Python-Workshops', 'size': '3502'}