diff options
Diffstat (limited to 'tutorials/module_1/notebook_1/basics_of_python.ipynb')
| -rw-r--r-- | tutorials/module_1/notebook_1/basics_of_python.ipynb | 192 |
1 files changed, 0 insertions, 192 deletions
diff --git a/tutorials/module_1/notebook_1/basics_of_python.ipynb b/tutorials/module_1/notebook_1/basics_of_python.ipynb deleted file mode 100644 index 023d3a0..0000000 --- a/tutorials/module_1/notebook_1/basics_of_python.ipynb +++ /dev/null @@ -1,192 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Basics of Python\n", - "\n", - "This page contains important fundamental concepts used in Python such as\n", - "syntax, operators, order or precedence and more.\n", - "\n", - "## Syntax\n", - "\n", - "### Indentations and blocks\n", - "\n", - "In python *indentations* or the space at the start of each line,\n", - "signifies a block of code. This becomes important when we start working\n", - "with function and loops. We will talk more about this in the controls\n", - "structures tutorial.\n", - "\n", - "### Comments\n", - "\n", - "Comments can be added to your code using the hash operator (#). Any text\n", - "behind the comment operator till the end of the line will be rendered as\n", - "a comment. If you have an entire block of text or code that needs to be\n", - "commented out, the triple quotation marks (“““) can be used. Once used\n", - "all the code after it will be considered a comment until the comment is\n", - "ended with the triple quotation marks.f\n", - "\n", - "## Operators\n", - "\n", - "In python, operators are special symbols or keywords that perform\n", - "operations on values or variables. This section covers some of the most\n", - "common operator that you will see in this course.\n", - "\n", - "### Arithmetic operators\n", - "\n", - "| Operator | Name |\n", - "|----------|----------------|\n", - "| \\+ | Addition |\n", - "| \\- | Subtraction |\n", - "| \\* | Multiplication |\n", - "| / | Division |\n", - "| % | Modulus |\n", - "| \\*\\* | Exponentiation |\n", - "| // | Floor division |\n", - "\n", - "### Comparison operators\n", - "\n", - "Used in conditional statements such as `if` statements or `while` loops.\n", - "Note that in the computer world a double equal sign (`==`) means *is\n", - "equal to*, where as the single equal sign assigns the variable or\n", - "defines the variable to be something.\n", - "\n", - "| Operator | Name |\n", - "|----------|--------------------------|\n", - "| == | Equal |\n", - "| != | Not equal |\n", - "| \\> | Greater than |\n", - "| \\< | Less than |\n", - "| \\>= | Greater than or equal to |\n", - "| \\<= | Less than or equal to |\n", - "\n", - "### Logical operators\n", - "\n", - "| Operator | Descrription |\n", - "|----------|--------------------------------------------------------|\n", - "| and | Returns True if both statemetns are true |\n", - "| or | Returns True if one of the statements is true |\n", - "| not | Reerse the result, returns False if the result is true |\n", - "\n", - "### Identity operators\n", - "\n", - "| Operator | Description |\n", - "|----------|--------------------------------------------------------|\n", - "| is | Returns True if both variables are the same object |\n", - "| is not | Returns True if both variables are not the same object |\n", - "\n", - "## Order of Operation\n", - "\n", - "Similarly to the order or precedence in mathematics, different computer\n", - "languages have their own set of rules. Here is a comprehensive table of\n", - "the order of operation that python follows.\n", - "\n", - "| Operator | Description |\n", - "|-------------------------------------|-----------------------------------|\n", - "| `()` | Parentheses |\n", - "| `**` | Exponentiation |\n", - "| `+x` `-x` `~x` | Unary plus, unary minus, and bitwise NOT |\n", - "| `*` `/` `//` `%` | Multiplication, Division, floor division, and modulus |\n", - "| `+` `-` | Addition and subtraction |\n", - "| `<<` `>>` | Bitwise left and right shifts |\n", - "| & | Bitwise AND |\n", - "| ^ | Bitwise XOR |\n", - "| \\| | Bitwise OR |\n", - "| `==` `!=` `>` `>=` `<` `<=` `is` `is not` `in` `not in` | Comparision, identity and membership operators |\n", - "| `not` | logical NOT |\n", - "| `and` | AND |\n", - "| `or` | OR |\n", - "\n", - "## Data types\n", - "\n", - "Data types are different ways a computer stores data. Other data types\n", - "use fewer bits than others allowing you to better utilize your computer\n", - "memory. This is important for engineers because The most common data\n", - "types that an engineer encounters in python are numeric types. - `int` -\n", - "integer - `float` - a decimal number - `complex` - imaginary number\n", - "\n", - "The comprehensive table below show all built-in data types available in\n", - "python.\n", - "\n", - "| Category | Data Type |\n", - "|----------|------------------------------|\n", - "| Text | int, float, complex |\n", - "| Sequance | list, tuple, range |\n", - "| Mapping | dict |\n", - "| Set | set, frozenset |\n", - "| Boolean | bytes, bytearray, memoryview |\n", - "| Binary | bytes, bytearray, memoryview |\n", - "| None | NoneType |\n", - "\n", - "## Variables\n", - "\n", - "A **variable** in Python is a name that stores a value, allowing you to\n", - "use and manipulate data efficiently.\n", - "\n", - "#### Declaring and Assigning Variables\n", - "\n", - "It is common in low-level computer languages to declare the datatype if\n", - "the variable. In python, the datatype is set whilst you assign it. We\n", - "assign values to variables using a single `=`.\n", - "\n", - "``` python\n", - "x = 10 # Integer\n", - "y = 3.14 # Float\n", - "name = \"Joe\" # String\n", - "is_valid = True # Boolean\n", - "```\n", - "\n", - "You can assign multiple variables at once:\n", - "\n", - "``` python\n", - "a, b, c = 1, 2, 3\n", - "```\n", - "\n", - "Similarly we can assign the same value to multiple variables:\n", - "\n", - "``` python\n", - "x = y = z = 100\n", - "```\n", - "\n", - "##### Rules\n", - "\n", - "- Must start with a letter or `_`\n", - "- Cannot start with a number\n", - "- Can only contain letters, numbers, and `_`\n", - "- Case-sensitive (`Name` and `name` are different)\n", - "\n", - "#### Updating Variables\n", - "\n", - "You can change a variable’s value at any time.\n", - "\n", - "``` python\n", - "x = 5\n", - "x = x + 10 # Now x is 15\n", - "```\n", - "\n", - "Or shorthand:\n", - "\n", - "``` python\n", - "x += 10 # Same as x = x + 10\n", - "```\n", - "\n", - "#### Variable Types & Type Checking\n", - "\n", - "Use `type()` to check a variable’s type.\n", - "\n", - "``` python\n", - "x = 10\n", - "print(type(x)) # Output: <class 'int'>\n", - "\n", - "y = \"Hello\"\n", - "print(type(y)) # Output: <class 'str'>\n", - "```" - ], - "id": "e14d8bfc-8b11-4e2b-aaf1-2b676706e16f" - } - ], - "nbformat": 4, - "nbformat_minor": 5, - "metadata": {} -} |
