{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Introduction to Python \n", "\n", "## Statements and Builtin Functions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Python has some basic expressions called statements.\n", "#### Statements are instructions written in the source code for execution, but they are not functions. \n", "\n", "There are different types of statements in the Python programming language like *Assignment* statement, *Conditional* statements, *Looping* statements etc. These all help the user to get the required output. \n", "\n", "These are the most common Python statements:\n", "\n", "#### 1. [Simple statements](https://docs.python.org/3/reference/simple_stmts.html) \n", "\n", "+ assert\n", "+ assignment (=)\n", "+ augmented_assignment (+=, -=, /=, *=)\n", "+ annotated_assignment (Python >= 3.5)\n", "+ del\n", "+ return and yield\n", "+ raise\n", "+ pass, break, continue\n", "+ import\n", "+ future\n", "+ global, nonlocal\n", "\n", "#### 2. [Compound statements](https://docs.python.org/3/reference/compound_stmts.html) \n", "\n", "+ if (stmt) + elif, else\n", "+ while (stmt) + break, continue\n", "+ for (stmt) + break, continue\n", "+ try (stmt) + except, else, finally\n", "+ with (stmt) + as\n", "+ def (def)\n", "+ class (def)\n", "+ async_with (stmt)\n", "+ async_for (stmt)\n", "+ async_func (def)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Some statements are also considered ____Keywords____.\n", "#### Keywords are the reserved words in Python. We cannot use a keyword as a variable name, function name or any other identifier." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']\n" ] } ], "source": [ "import keyword\n", "print(keyword.kwlist)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Statements will be presented throughout the course." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Python _builtin_ Functions\n", "\n", "The Python interpreter has a number of functions and types built into it that are always available. \n", "They are listed here in alphabetical order.\n", "\n", "
\n", " | \n", " | Built-in Functions | \n",
"\n", " | \n", " |
---|---|---|---|---|
\n", " | \n", " | \n", " | \n", " | \n", " |
\n", " | \n", " | \n", " | \n", " | \n", " |
\n", " | \n", " | \n", " | \n", " | \n", " |
\n", " | \n", " | \n", " | \n", " | \n", " |
\n", " | \n", " | \n", " | \n", " | \n", " |
\n", " | \n", " | \n", " | \n", " | \n", " |
\n", " | \n", " | \n", " | \n", " | \n", " |
\n", " | \n", " | \n", " | \n", " | \n", " |
\n", " | \n", " | \n", " | \n", " | \n", " |
\n", " | \n", " | \n", " | \n", " | \n", " |
\n", " | \n", " | \n", " | \n", " | \n", " |
\n", " | \n", " | \n", " | \n", " | \n", " |
\n", " | \n", " | \n", " | \n", " | \n", " |
\n", " | \n", " | \n", " | \n", " | \n", " |