|
4 | 4 | "cell_type": "markdown",
|
5 | 5 | "metadata": {},
|
6 | 6 | "source": [
|
7 |
| - "# Python Keywords\n", |
| 7 | + "**Table of contents**<a id='toc0_'></a> \n", |
| 8 | + "- [Python Keywords](#toc1_) \n", |
| 9 | + " - [Python 35 Keywords](#toc1_1_) \n", |
| 10 | + "- [Python Identifiers](#toc2_) \n", |
| 11 | + " - [Variables](#toc2_1_) \n", |
| 12 | + " - [Constants](#toc2_2_) \n", |
| 13 | + " - [Literals](#toc2_3_) \n", |
| 14 | + "- [Python Data Types](#toc3_) \n", |
| 15 | + "- [Python Type Conversion (Type Casting)](#toc4_) \n", |
| 16 | + "- [Python Operators](#toc5_) \n", |
| 17 | + "- [Python Namespace and Scope](#toc6_) \n", |
| 18 | + " - [Python Variable Scope << Namespaces >>](#toc6_1_) \n", |
| 19 | + "- [References](#toc7_) \n", |
| 20 | + "\n", |
| 21 | + "<!-- vscode-jupyter-toc-config\n", |
| 22 | + "\tnumbering=false\n", |
| 23 | + "\tanchor=true\n", |
| 24 | + "\tflat=false\n", |
| 25 | + "\tminLevel=1\n", |
| 26 | + "\tmaxLevel=6\n", |
| 27 | + "\t/vscode-jupyter-toc-config -->\n", |
| 28 | + "<!-- THIS CELL WILL BE REPLACED ON TOC UPDATE. DO NOT WRITE YOUR TEXT IN THIS CELL -->" |
| 29 | + ] |
| 30 | + }, |
| 31 | + { |
| 32 | + "cell_type": "markdown", |
| 33 | + "metadata": {}, |
| 34 | + "source": [ |
| 35 | + "# <a id='toc1_'></a>[Python Keywords](#toc0_)\n", |
8 | 36 | "- Keywords are predefined, reserved words \n",
|
9 | 37 | "- Cannot use a keyword as a variable name, function name\n",
|
10 | 38 | "- used to define the syntax and structure of the Python language\n",
|
|
16 | 44 | "cell_type": "markdown",
|
17 | 45 | "metadata": {},
|
18 | 46 | "source": [
|
19 |
| - "## Python 35 Keywords\n", |
| 47 | + "## <a id='toc1_1_'></a>[Python 35 Keywords](#toc0_)\n", |
20 | 48 | "\n",
|
21 | 49 | "`import` `from` `as` \n",
|
22 | 50 | "\n",
|
|
71 | 99 | "cell_type": "markdown",
|
72 | 100 | "metadata": {},
|
73 | 101 | "source": [
|
74 |
| - "# Python Identifiers\n", |
| 102 | + "# <a id='toc2_'></a>[Python Identifiers](#toc0_)\n", |
75 | 103 | "\n",
|
76 | 104 | "Identifiers are the name given to variables, classes, methods, etc.\n",
|
77 | 105 | "\n",
|
78 | 106 | "`language = 'Python'`\n",
|
79 | 107 | "Here, language is a variable (an identifier) which holds the value 'Python'\n",
|
80 | 108 | "\n",
|
81 | 109 | "\n",
|
82 |
| - "## Variables\n", |
| 110 | + "## <a id='toc2_1_'></a>[Variables](#toc0_)\n", |
83 | 111 | "A `variable` is a container (storage area) to hold data. Exp: `number = 10`\n",
|
84 | 112 | "\n",
|
85 | 113 | "**Variable Naming Conventions**\n",
|
|
94 | 122 | "2. Class names should normally use the CapWords convention. Exp: class BankAccount:\n",
|
95 | 123 | "3. Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability.\n",
|
96 | 124 | "4. Python packages should also have short, all-lowercase names, although the use of underscores is discouraged.\n",
|
97 |
| - "Function names should be lowercase, with words separated by underscores as necessary to improve readability. Exp: def withdrawal(): or def bank_withdrawal():\n", |
98 |
| - "\n", |
99 |
| - "5. Variable names follow the same convention as function names.\n", |
| 125 | + "5. Function names should be lowercase, with words separated by underscores as necessary to improve readability. Exp: def withdrawal(): or def bank_withdrawal():\n", |
| 126 | + "6. Variable names follow the same convention as function names.\n", |
100 | 127 | "```\n",
|
101 | 128 | "a=[1,2,3]\n",
|
102 | 129 | "d={‘a’:1}\n",
|
103 | 130 | "colors=[‘red’,’blue’]\n",
|
104 | 131 | "```\n",
|
105 |
| - "6. Method names and also instance variables should be lowercase with words separated by underscores as necessary to improve readability.\n", |
106 |
| - "7. Use one leading underscore only for non-public methods and instance variables.\n", |
| 132 | + "7. Method names and also instance variables should be lowercase with words separated by underscores as necessary to improve readability.\n", |
| 133 | + "8. Use one leading underscore only for non-public methods and instance variables.\n", |
107 | 134 | "\n",
|
108 | 135 | "\n",
|
109 |
| - "## Constants\n", |
| 136 | + "## <a id='toc2_2_'></a>[Constants](#toc0_)\n", |
110 | 137 | "A `constant` is a special type of variable whose value cannot (is not) be changed. Exp: PI = 3.14\n",
|
111 | 138 | "\n",
|
112 |
| - "## Literals\n", |
| 139 | + "## <a id='toc2_3_'></a>[Literals](#toc0_)\n", |
113 | 140 | "`Literals` are representations of fixed values in a program. \\\n",
|
114 | 141 | "They can be numbers, characters, or strings, etc. For example, 'Hello, World!', 12, 23.0, 'C', etc.\n",
|
115 | 142 | "\n",
|
|
127 | 154 | "cell_type": "markdown",
|
128 | 155 | "metadata": {},
|
129 | 156 | "source": [
|
130 |
| - "# Python Data Types\n", |
| 157 | + "# <a id='toc3_'></a>[Python Data Types](#toc0_)\n", |
131 | 158 | "\n",
|
132 | 159 | "\n",
|
133 | 160 | "\n",
|
|
183 | 210 | "cell_type": "markdown",
|
184 | 211 | "metadata": {},
|
185 | 212 | "source": [
|
186 |
| - "# Python Type Conversion (Type Casting)\n", |
| 213 | + "# <a id='toc4_'></a>[Python Type Conversion (Type Casting)](#toc0_)\n", |
187 | 214 | "Type conversion is the process of converting data of one type to another\n",
|
188 | 215 | "\n",
|
189 | 216 | "**Type conversion in Python**\n",
|
|
259 | 286 | "cell_type": "markdown",
|
260 | 287 | "metadata": {},
|
261 | 288 | "source": [
|
262 |
| - "# Python Operators\n", |
| 289 | + "# <a id='toc5_'></a>[Python Operators](#toc0_)\n", |
263 | 290 | "Operators are special symbols that perform operations on variables and values.\n",
|
264 | 291 | "\n",
|
265 | 292 | "**Types of Python Operators**\n",
|
|
369 | 396 | "cell_type": "markdown",
|
370 | 397 | "metadata": {},
|
371 | 398 | "source": [
|
372 |
| - "# Python Namespace and Scope\n", |
| 399 | + "# <a id='toc6_'></a>[Python Namespace and Scope](#toc0_)\n", |
373 | 400 | "\n",
|
374 | 401 | "- `Namespace` is a mapping of every name used to store the values of variables and other objects in the program, and to associate them with a specific name\n",
|
375 | 402 | "- This allows us to use the same name for different variables or objects in different parts of your code, without causing any conflicts or confusion.\n",
|
|
392 | 419 | "- A local namespace is created when a function is called, which has all the names defined in it.\n",
|
393 | 420 | "- Similar is the case with class.\n",
|
394 | 421 | "\n",
|
395 |
| - "## Python Variable Scope << Namespaces >>\n", |
| 422 | + "## <a id='toc6_1_'></a>[Python Variable Scope << Namespaces >>](#toc0_)\n", |
396 | 423 | "**When a reference is made inside a function, the name is searched in the local namespace, then in the global namespace and finally in the built-in namespace.**"
|
397 | 424 | ]
|
398 | 425 | },
|
|
440 | 467 | "cell_type": "markdown",
|
441 | 468 | "metadata": {},
|
442 | 469 | "source": [
|
443 |
| - "# References\n", |
| 470 | + "# <a id='toc7_'></a>[References](#toc0_)\n", |
444 | 471 | "\n",
|
445 | 472 | "- [The Python Language Reference](https://docs.python.org/3/reference/index.html)\n",
|
446 | 473 | "- [Programiz - Python](https://www.programiz.com/python-programming/)"
|
|
0 commit comments