{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "55db1b3f", "metadata": { "tags": [ "hide-input" ] }, "outputs": [], "source": [ "# Install the necessary dependencies\n", "\n", "import sys\n", "import os\n", "!{sys.executable} -m pip install --quiet jupyterlab_myst ipython" ] }, { "cell_type": "markdown", "id": "3d063176", "metadata": { "tags": [ "remove-cell" ] }, "source": [ "---\n", "license:\n", " code: MIT\n", " content: CC-BY-4.0\n", "github: https://github.com/ocademy-ai/machine-learning\n", "venue: By Ocademy\n", "open_access: true\n", "bibliography:\n", " - https://raw.githubusercontent.com/ocademy-ai/machine-learning/main/open-machine-learning-jupyter-book/references.bib\n", "---" ] }, { "cell_type": "markdown", "id": "6959d225", "metadata": {}, "source": [ "
\n", "\n", "LICENSE\n", "\n", "MIT License\n", "\n", "Copyright (c) 2018 Oleksii Trekhleb\n", "Copyright (c) 2018 Real Python\n", "\n", "Permission is hereby granted, free of charge, to any person obtaining a copy\n", "of this software and associated documentation files (the \"Software\"), to deal\n", "in the Software without restriction, including without limitation the rights\n", "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n", "copies of the Software, and to permit persons to whom the Software is\n", "furnished to do so, subject to the following conditions:\n", "\n", "The above copyright notice and this permission notice shall be included in all\n", "copies or substantial portions of the Software.\n", "\n", "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n", "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n", "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n", "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n", "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n", "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n", "SOFTWARE.\n", "\n", "
" ] }, { "attachments": {}, "cell_type": "markdown", "id": "045070fc", "metadata": {}, "source": [ "# Python programming introduction\n", "\n", "Python is a high-level programming language for general-purpose programming. It is an open-source, interpreted, objected-oriented programming language. Python was created by a Dutch programmer, Guido van Rossum. The name of the Python programming language was derived from a British sketch comedy series, Month Python's Flying Circus. The first version was released on February 20, 1991.\n", "\n", "Python is an easy-to-learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.\n", "\n", "It is used for:\n", "\n", "- web development (server-side),\n", "- software development,\n", "- mathematics,\n", "- system scripting.\n", "\n", "These Python programming-related sections are designed for beginners and professionals who want to learn Python programming language. If you are in favor of videos, you may get started with this [Python for Absolute Beginners video](https://www.youtube.com/watch?v=11OYpBrhdyM).\n", "\n", "## Why Python?\n", "\n", "It is a programming language that is very close to human language and because of that, it is easy to learn and use. Python is used by various industries and companies (including Google). It has been used to develop web applications, desktop applications, system administration, and Machine Learning libraries. Python is a highly embraced language in the data science and Machine Learning community. Hope this is enough to convince you to start learning Python. Python is eating the world and you are killing it before it eats you.\n", "\n", "## Environment setup\n", "\n", "### Installing Python\n", "\n", "To run a Python script you need to install Python. Let's [download](https://www.Python.org/) Python.\n", "\n", "If you are a windows user. Click the button encircled in red.\n", "\n", "[![installing on Windows](../../images/installing_on_windows.png)](https://www.Python.org/)\n", "\n", "If you are a macOS user. Click the button encircled in red.\n", "\n", "[![installing on Mac](../../images/installing_on_macOS.png)](https://www.Python.org/)\n", "\n", "To check if Python is installed, write the following command on your device terminal." ] }, { "attachments": {}, "cell_type": "markdown", "id": "619747e8", "metadata": { "attributes": { "classes": [ "shell" ], "id": "" } }, "source": [ "python --version" ] }, { "attachments": {}, "cell_type": "markdown", "id": "4e6e39e1", "metadata": {}, "source": [ "![Python Version](../../images/python_version.png)\n", "\n", "As you can see from the terminal, _Python 3.7.5_ version is used at the moment. Your version of Python might be different from mine, but it should be 3.6 or above. If you manage to see the Python version, well done. Python has been installed on your machine. Continue to the next section.\n", "\n", "### Python shell\n", "\n", "Python is an interpreted scripting language, so it does not need to be compiled. It means it executes the code line by line. Python comes with a _Python Shell (Python Interactive Shell)_. It is used to execute a single Python command and get the result.\n", "\n", "Python Shell waits for the Python code from the user. When you enter the code, it interprets the code and shows the result in the next line. Open your terminal or command prompt(cmd) and write:" ] }, { "attachments": {}, "cell_type": "markdown", "id": "972ce6a1", "metadata": { "attributes": { "classes": [ "shell" ], "id": "" } }, "source": [ "python" ] }, { "attachments": {}, "cell_type": "markdown", "id": "8f9c5094", "metadata": {}, "source": [ "![Python Scripting Shell](../../images/opening_python_shell.png)\n", "\n", "The Python interactive shell is opened and it is waiting for you to write Python code(Python script). You will write your Python script next to this symbol >>> and then click Enter.\n", "Let us write our very first script on the Python scripting shell.\n", "\n", "![Python script on Python shell](../../images/adding_on_python_shell.png)\n", "\n", "Well done, you wrote your first Python script on Python interactive shell. How do we close the Python interactive shell?\n", "\n", "To close the shell, next to this symbol `>>` write `exit()` command and press Enter.\n", "\n", "![Exit from the Python shell](../../images/exit_from_shell.png)\n", "\n", "Now, you know how to open the Python interactive shell and how to exit from it.\n", "\n", "Python will give you results if you write scripts that Python understands, if not it returns errors. Let's make a deliberate mistake and see what Python will return.\n", "\n", "![Invalid Syntax Error](../../images/invalid_syntax_error.png)\n", "\n", "As you can see from the returned error, Python is so clever that it knows the mistake we made and which was `Syntax Error: invalid syntax`. Using `x` as multiplication in Python is a syntax error because `x` is not the valid syntax in Python. Instead of `x`, we use an asterisk `*` for multiplication. The returned error clearly shows what to fix.\n", "\n", "The process of identifying and removing errors from a program is called _debugging_. Let us debug it by putting `*` in place of `x`.\n", "\n", "![Fixing Syntax Error](../../images/fixing_syntax_error.png)\n", "\n", "Our bug was fixed, the code ran and we got the result we were expecting. As a programmer, you will see such kinds of errors on daily basis. It is good to know how to debug. To be good at debugging you should understand what kind of errors you are facing. Some of the Python errors you may encounter are `SyntaxError`, `IndexError`, `NameError`, `ModuleNotFoundError`, `KeyError`, `ImportError`, `AttributeError`, `TypeError`, `ValueError`, `ZeroDivisionError` etc. We will see more about different Python **_error types_** in later sections.\n", "\n", "Let us practice more on how to use Python interactive shell. Go to your terminal or command prompt and write the word `Python`.\n", "\n", "![Python Scripting Shell](../../images/opening_python_shell.png)\n", "\n", "The Python interactive shell is opened. Let us do some basic mathematical operations (addition, subtraction, multiplication, division, modulus, exponential).\n", "\n", "Let us do some maths first before we write any Python code:\n", "\n", "$$ 3 + 2 = 5$$\n", "$$ 3 - 2 = 1 $$\n", "$$ 3 * 2 = 6 $$\n", "$$ 3 / 2 = 1.5 $$\n", "$$ 3 ^ 2 = 3 x 3 = 9 $$\n", "\n", "In Python we have the following additional operations:\n", "\n", "- `3 % 2 = 1` => which means finding the remainder\n", "- `3 // 2 = 1` => which means removing the remainder\n", "\n", "Let us change the above mathematical expressions to Python code. The Python shell has been opened and lets us write a comment at the very beginning of the shell.\n", "\n", "A _comment_ is a part of the code that is not executed by Python. So we can leave some text in our code to make our code more readable. Python does not run the comment part. Comment in Python starts with the hash(`#`) symbol.\n", "\n", "This is how you write a comment in Python" ] }, { "cell_type": "code", "execution_count": null, "id": "58712fbe", "metadata": { "attributes": { "classes": [ "code-cell" ], "id": "" } }, "outputs": [], "source": [ "# comment starts with hash\n", "# this is a Python comment, because it starts with a (#) symbol" ] }, { "attachments": {}, "cell_type": "markdown", "id": "a21c3357", "metadata": {}, "source": [ "![Maths on Python shell](../../images/maths_on_python_shell.png)\n", "\n", "Before we move on to the next section, let us practice more on the Python interactive shell. Close the opened shell by writing `exit()` on the shell and open it again and let us practice how to write text on the Python shell.\n", "\n", "![Writing String on Python shell](../../images/writing_string_on_shell.png)\n", "\n", "### Installing Visual Studio Code\n", "\n", "The Python interactive shell is good to try and test small script codes but it will not be for a big project. In the real work environment, developers use different code editors to write code. Will use Visual Studio Code. Visual Studio Code is a very popular open-source text editor. If you are a fan of Visual Studio Code, it is recommended to [download](https://code.visualstudio.com/) it. but if you are in favor of other editors, feel free to follow with what you have.\n", "\n", "[![Visual Studio Code](../../images/vscode.png)](https://code.visualstudio.com/)\n", "\n", "If you installed Visual Studio Code, let us see how to use it. If you prefer a video, you can follow this Visual Studio Code for Python [Video tutorial](https://www.youtube.com/watch?v=bn7Cx4z-vSo)\n", "\n", "#### How to use Visual Studio Code\n", "\n", "Open the Visual Studio Code by double-clicking the visual studio icon. When you open it you will get this kind of interface. Try to interact with the labeled icons.\n", "\n", "![Visual Studio Code](../../images/vscode_ui.png)\n", "\n", "Create a folder named `ocademy` on your desktop. Then open it using Visual Studio Code.\n", "\n", "![Opening Project on Visual studio](../../images/how_to_open_project_on_vscode.png)\n", "\n", "![Opening a project](../../images/opening_project.png)\n", "\n", "After opening it you will see shortcuts for creating files and folders inside of `ocademy` project's directory. As you can see below, the very first file is created as `helloworld.py`. You can do the same.\n", "\n", "![Creating a Python file](../../images/helloworld.png)\n", "\n", "After a long day of coding, you want to close your code editor, right? This is how you will close the opened project.\n", "\n", "![Closing project](../../images/closing_opened_project.png)\n", "\n", "Congratulations, you have finished setting up the development environment. Let us start coding.\n", "\n", "## Basic Python\n", "\n", "### Python syntax\n", "\n", "A Python script can be written in Python interactive shell or the code editor. A Python file has an extension `.py`.\n", "\n", "### Python indentation\n", "\n", "An indentation is a white space in a text. Indentation in many languages is used to increase code readability, however, Python uses indentation to create blocks of codes. In other programming languages, curly brackets are used to create blocks of codes instead of an indentation. One of the common bugs when writing Python code is the wrong indentation.\n", "\n", "![Indentation Error](../../images/indentation.png)\n", "\n", "### Comments\n", "\n", "Comments are very important to make the code more readable and to leave remarks in our code. Python does not run comment parts of our code. Any text starting with a hash(`#`) in Python is a comment.\n", "\n", "**Example: Single Line Comment**" ] }, { "cell_type": "code", "execution_count": null, "id": "81f631d0", "metadata": { "attributes": { "classes": [ "code-cell" ], "id": "" } }, "outputs": [], "source": [ "# This is the first comment\n", "# This is the second comment\n", "# Python is eating the world" ] }, { "attachments": {}, "cell_type": "markdown", "id": "463af131", "metadata": {}, "source": [ "**Example: Multiline Comment**\n", "\n", "The triple quote can be used for multiline comments if it is not assigned to a variable" ] }, { "cell_type": "code", "execution_count": null, "id": "95b5fa82", "metadata": { "attributes": { "classes": [ "code-cell" ], "id": "" } }, "outputs": [], "source": [ "\"\"\"This is multiline comment\n", "multiline comment takes multiple lines.\n", "Python is eating the world\n", "\"\"\"" ] }, { "attachments": {}, "cell_type": "markdown", "id": "c1106008", "metadata": {}, "source": [ "### Data types\n", "\n", "In Python, there are several types of data types. Let us get started with the most common ones. Different data types will be covered in detail in other sections. For the time being, let us just go through the different data types and get familiar with them. You do not have to have a clear understanding now.\n", "\n", "#### Number\n", "\n", "- Integer: integer(negative, zero and positive) numbers.\n", " Example: ... -3, -2, -1, 0, 1, 2, 3 ...\n", "- Float: decimal number.\n", " Example: ... -3.5, -2.25, -1.0, 0.0, 1.1, 2.2, 3.5 ...\n", "- Complex.\n", " Example: 1 + j, 2 + 4j\n" ] }, { "cell_type": "code", "execution_count": null, "id": "45b50a6e", "metadata": { "attributes": { "classes": [ "code-cell" ], "id": "" } }, "outputs": [], "source": [ "age = 26 # That's Interge\n", "pi = 3.14159 # That's Float\n", "# Complex. Example: 1 + j, 2 + 4j\n", "print(type(age))\n", "print(type(pi))\n" ] }, { "attachments": {}, "cell_type": "markdown", "id": "8db0a4c0", "metadata": {}, "source": [ "#### String\n", "\n", "A collection of one or more characters under a single or double quote. If a string is more than one sentence then we use a triple quote.\n" ] }, { "cell_type": "code", "execution_count": null, "id": "9b28cb48", "metadata": { "attributes": { "classes": [ "code-cell" ], "id": "" } }, "outputs": [], "source": [ "s = 'Rutherford Birchard Hayes'\n", "tokens = s.split()\n", "firstName = tokens[0]\n", "middleName = tokens[1]\n", "lastName = tokens[2]\n", "s2 = firstName + ' ' + middleName + ' ' + lastName\n", "# All objects except tokens are of type string\n", "print(type(s))\n", "print(type(s2))\n" ] }, { "attachments": {}, "cell_type": "markdown", "id": "e6e27cb3", "metadata": {}, "source": [ "#### Booleans\n", "\n", "A boolean data type is either a `True` or `False` value. `T` and `F` should be always uppercase.\n" ] }, { "cell_type": "code", "execution_count": null, "id": "843df8e2", "metadata": { "attributes": { "classes": [ "code-cell" ], "id": "" } }, "outputs": [], "source": [ "def boolean(s, s2):\n", " print(type(s == s2))\n", " if (s == s2):\n", " print('yes!!!')\n", " else:\n", " print('nooooooo')\n", "\n", "boolean(1, 2)\n", "boolean(1, '1')\n", "boolean(1, 1)\n" ] }, { "attachments": {}, "cell_type": "markdown", "id": "ebcf17ed", "metadata": {}, "source": [ "#### List\n", "\n", "Python list is an ordered collection that allows to store items of different data types. A list is similar to an array in JavaScript.\n" ] }, { "attachments": {}, "cell_type": "markdown", "id": "7f693e71", "metadata": {}, "source": [ "\n", "\n", "
\n", "
\n", "

Let's visualize it! 🎥

\n", "
\n", " \n", "
\n", "
\n", "
" ] }, { "attachments": {}, "cell_type": "markdown", "id": "658b155a", "metadata": { "attributes": { "classes": [ "code-cell" ], "id": "" } }, "source": [ "\n", "\n", "
\n", "\n", "

Show me the code ⌨️

\n", "\n", "\n", "```python\n", "beatles = ['John', 'Paul', 'George']\n", "beatles.append('Ringo')\n", "print(type(beatles))\n", "\n", "# 'for' loop - indentation matters!\n", "for b in beatles:\n", " print('Hello ' + b)\n", "\n", "```\n", "
\n" ] }, { "attachments": {}, "cell_type": "markdown", "id": "6d0f8717", "metadata": {}, "source": [ "#### Dictionary\n", "\n", "A Python dictionary object is an unordered collection of data in a key-value pair format.\n" ] }, { "attachments": {}, "cell_type": "markdown", "id": "c8c1f775", "metadata": {}, "source": [ "\n", "\n", "
\n", "
\n", "

Let's visualize it! 🎥

\n", "
\n", " \n", "
\n", "
\n", "
\n" ] }, { "attachments": {}, "cell_type": "markdown", "id": "e518811d", "metadata": { "attributes": { "classes": [ "code-cell" ], "id": "" } }, "source": [ "\n", "\n", "
\n", "\n", "

Show me the code ⌨️

\n", "\n", "```python\n", "netWorth = {}\n", "netWorth['Donald Trump'] = 3000000000\n", "netWorth['Bill Gates'] = 58000000000\n", "netWorth['Tom Cruise'] = 40000000\n", "netWorth['Joe Postdoc'] = 20000\n", "print(netWorth)\n", "print(type(netWorth))\n", "\n", "# iterating over key-value pairs:\n", "\n", "for (person, worth) in netWorth.items():\n", " if worth < 1000000:\n", " print('haha ' + person + ' is not a millionaire')\n", "\n", "# testing dict membership\n", "\n", "if 'Tom Cruise' in netWorth:\n", " print('show me the money!')\n", "```\n", "\n", "
" ] }, { "attachments": {}, "cell_type": "markdown", "id": "92a28511", "metadata": {}, "source": [ "#### Tuple\n", "\n", "A tuple is an ordered collection of different data types like a list, but tuples can not be modified once they are created. They are immutable.\n" ] }, { "cell_type": "code", "execution_count": null, "id": "e7693675", "metadata": { "attributes": { "classes": [ "code-cell" ], "id": "" } }, "outputs": [], "source": [ "ages = (18, 21, 28, 21, 22, 18, 19, 34, 9)\n", "print(ages)\n", "print(type(ages))\n", "# If you want to change ages, you will get a error." ] }, { "attachments": {}, "cell_type": "markdown", "id": "cade50d3", "metadata": {}, "source": [ "#### Set\n", "\n", "A set is a collection of data types similar to a list and tuple. Unlike the list and the tuple, a set is not an ordered collection of items. Like in Mathematics, set in Python only stores unique items. In later sections, we will go into detail about every Python data type." ] }, { "attachments": {}, "cell_type": "markdown", "id": "3a358ea4", "metadata": {}, "source": [ "\n", "\n", "
\n", "
\n", "

Let's visualize it! 🎥

\n", "
\n", " \n", "
\n", "
\n", "
\n" ] }, { "attachments": {}, "cell_type": "markdown", "id": "a0176428", "metadata": { "attributes": { "classes": [ "code-cell" ], "id": "" } }, "source": [ "\n", "\n", "
\n", "\n", "

Show me the code ⌨️

\n", "\n", "```python\n", "ages = (18, 21, 28, 21, 22, 18, 19, 34, 9)\n", "\n", "uniqueAges = set(ages)\n", "uniqueAges.add(18) # already in set, no effect\n", "uniqueAges.remove(21)\n", "\n", "\n", "# no guaranteed order when iterating over a set\n", "\n", "for thisAge in uniqueAges:\n", " print(thisAge)\n", "\n", "print(type(uniqueAges))\n", "\n", "# testing set membership\n", "\n", "if 18 in uniqueAges:\n", " print('There is an 18-year-old present!')\n", "```\n", "\n", "
" ] }, { "attachments": {}, "cell_type": "markdown", "id": "2cab21bd", "metadata": {}, "source": [ "### Control flow and function\n", "\n", "#### if\n", "\n", "The `if` statement is used for conditional execution. It allows you to execute different code blocks based on the truth or falsehood of a condition." ] }, { "attachments": {}, "cell_type": "markdown", "id": "d77423b4", "metadata": {}, "source": [ "```python\n", "if condition:\n", " # Code block to be executed if the condition is true\n", "else:\n", " # Code block to be executed if the condition is false\n", "```" ] }, { "attachments": {}, "cell_type": "markdown", "id": "890b4224", "metadata": {}, "source": [ "In this structure, the `condition` is an expression or variable that evaluates to either `True` or `False`. If the condition is true, the code block under `if` is executed. If the condition is false, the code block under `else` is executed.\n", "You can click [here](https://ocademy-ai.github.io/machine-learning/prerequisites/python-programming-introduction.html#booleans) to see sample code in boolean.\n", "\n", "#### for\n", "\n", "The `for` loop is used for iterating over a sequence of elements. It allows you to execute a block of code for each item in the sequence." ] }, { "attachments": {}, "cell_type": "markdown", "id": "0a203770", "metadata": {}, "source": [ "```python\n", "for item in sequence:\n", " # Code block to be executed for each item\n", "```" ] }, { "attachments": {}, "cell_type": "markdown", "id": "8041d8b1", "metadata": {}, "source": [ "In this structure, `item` is a variable that represents each element in the sequence, and `sequence` is the iterable object you want to loop through. The code block under the `for` loop is executed for each item in the sequence.\n", "You can click [here](https://ocademy-ai.github.io/machine-learning/prerequisites/python-programming-introduction.html#list) to see sample code in list.\n", "\n", "#### def\n", "\n", "The `def` keyword is used to define a function. Functions are blocks of reusable code that perform a specific task when called." ] }, { "attachments": {}, "cell_type": "markdown", "id": "ac67ffc9", "metadata": {}, "source": [ "```python\n", "def function_name(parameters_input):\n", " # Code block or statements\n", " # that define the function's behavior\n", " return parameters_output\n", "````" ] }, { "attachments": {}, "cell_type": "markdown", "id": "65df1653", "metadata": {}, "source": [ "Here's a breakdown of the different components:\n", "\n", "- `def`: This keyword is used to indicate the start of a function definition.\n", "- `function_name`: This is the name you choose for your function. It should be descriptive and follow Python naming conventions.\n", "- `parameters_input`: These are optional `input values` that you can pass to the function. They are placeholders for the actual values that will be provided when calling the function.\n", "- `Code block`: This is where you write the instructions or statements that define the behavior of the function. It should be indented under the function definition.\n", "- `return`: Usually `return` is found in def, and its purpose is to return `parameters_output` that follows. But if you have other outputs, you don't have to write 'return'. You can click [here](https://ocademy-ai.github.io/machine-learning/prerequisites/python-programming-introduction.html#booleans) to see sample code in boolean.\n", "- `parameters_output`: These are the `parameters` you wish to pass out.\n", "\n", "### Python file\n", "\n", "First open your project folder, `oocademy`. If you don't have this folder, create a folder name called `ocademy`. Inside this folder, create a file called `helloworld.py`. Now, let's do what we did on Python interactive shell using Visual Studio Code.\n", "\n", "The Python interactive shell was printing without using `print` but on Visual Studio Code to see our result we should use a built-in function `print()`. The `print()` built-in function takes one or more arguments as follows `print('arument1', 'argument2', 'argument3')`. See the examples below.\n" ] }, { "attachments": {}, "cell_type": "markdown", "id": "6a0053c7", "metadata": {}, "source": [ "\n", "\n", "
\n", "
\n", "

Let's visualize it! 🎥

\n", "
\n", " \n", "
\n", "
\n", "
" ] }, { "attachments": {}, "cell_type": "markdown", "id": "31c35441", "metadata": { "attributes": { "classes": [ "code-cell" ], "id": "" } }, "source": [ "\n", "\n", "
\n", "\n", "

Show me the code ⌨️

\n", "\n", "```python\n", "x = [1, 2, 3]\n", "y = [4, 5, 6]\n", "z = y\n", "y = x\n", "x = z\n", "\n", "x = [1, 2, 3] # a different [1, 2, 3] list!\n", "y = x\n", "x.append(4)\n", "y.append(5)\n", "z = [1, 2, 3, 4, 5] # a different list!\n", "x.append(6)\n", "y.append(7)\n", "y = \"hello\"\n", "\n", "\n", "def foo(lst):\n", " lst.append(\"hello\")\n", " bar(lst)\n", "\n", "def bar(myLst):\n", " print(myLst)\n", "\n", "foo(x)\n", "foo(z)\n", "```\n", "\n", "
" ] }, { "attachments": {}, "cell_type": "markdown", "id": "086c1abe", "metadata": {}, "source": [ "The file name is `helloworld.py`.\n", "\n", "To run the Python file check the image below. You can run the Python file either by running the green button on Visual Studio Code or by typing `python helloworld.py` in the terminal.\n", "\n", "![Running Python script](../../images/running_python_script.png)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "efefd74e", "metadata": {}, "source": [ "🌕 You are amazing. You have just completed our challenge and you are on your way to greatness. Now do some exercises for your brain and muscles.\n", "\n", "## Your turn! 🚀\n", "\n", "Try to [write some simple Python code](../../assignments/prerequisites/python-programming-introduction.ipynb) through Python shell, Python file, and Jupyter Notebook.\n", "\n", "## Acknowledgments\n", "\n", "Thanks to [Asabeneh](https://github.com/Asabeneh) who helped create this awesome open-source project [30-Days-Of-Python](https://github.com/Asabeneh/30-Days-Of-Python/blob/master/readme.md) for Python learning. It contributes the majority of the content in this chapter.\n", "\n", "Thanks to [pythontutor](https://pythontutor.com/) for providing the ability to visualize the code execution. It also contributes some code to this chapter." ] } ], "metadata": { "kernelspec": { "display_name": "ocademy-machine-learning-assignments", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.16" } }, "nbformat": 4, "nbformat_minor": 5 }