class: center, middle, inverse # Introducción a la Programación I Running Python --- # Agenda - REPL - Scripts - Notebook --- # REPL .center[![REPL](/prog1/presentation/run-python/repl.png))] - **R**ead-**E**valuate-**P**rint-**L**oop - Interactive Python - Run Python code directly - Useful for testing code, functions, libraries --- # REPL Code can be single or multi lined .center[![REPL Example](/prog1/presentation/run-python/repl-example.png)] .center[![Multi line REPL Example](/prog1/presentation/run-python/multiline-repl.png)] --- # Scripts - Python code saved in a file - Can be run from the command line: `python script.py` - Can be executed by an IDE, REPL or Notebook --- # Notebook .center[![Jupyter example](/prog1/presentation/run-python/jupyter-example.jpeg)] --- # What can I do in Notebooks? - Interactive Python - Run Python code directly - Useful for testing code, functions, libraries - Can be saved as a file --- # Jupyter Notebook Installing Jupyter: https://jupyter.org/install#jupyter-notebook - Jupyter is a web application that allows you to create and share documents that contain live code, equations, visualizations and explanatory text. - Uses include: data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and much more. - Stores code, results and comments in a file with extension `.ipynb` --- # Cells .center[![Jupyter Menu](/prog1/presentation/run-python/jupyter-menu.png)] - Cells can be of type Code or Markdown - **Markdown** is a markup language that is a superset of HTML. It is used to write comments and documentation. - Cells can be executed by pressing `Shift + Enter` - Green outline means cell is in edit mode - Blue outline means cell is in command mode --- # Kernel Behind every notebook runs a kernel. When you run a code cell, that code is executed within the kernel. Any output is returned back to the cell to be displayed. The kernel’s state persists over time and between cells — it pertains to the document as a whole and not individual cells. --- # Sharing Notebooks - Notebooks can be shared by exporting them as HTML, PDF, Markdown, etc. - Notebooks can be shared by uploading them to a repository (GitHub, GitLab, Google Collab, etc.) https://colab.research.google.com/