|
1 | 1 | { |
2 | 2 | "cells": [ |
3 | | - { |
4 | | - "cell_type": "code", |
5 | | - "execution_count": null, |
6 | | - "metadata": {}, |
7 | | - "outputs": [], |
8 | | - "source": [ |
9 | | - "from IPython.display import HTML\n", |
10 | | - "\n", |
11 | | - "HTML(\n", |
12 | | - " \"\"\"<script>\n", |
13 | | - "code_show=true; \n", |
14 | | - "function code_toggle() {\n", |
15 | | - " if (code_show){\n", |
16 | | - " $('div.jp-OutputArea').hide();\n", |
17 | | - " } else {\n", |
18 | | - " $('div.jp-OutputArea').show();\n", |
19 | | - " }\n", |
20 | | - " code_show = !code_show\n", |
21 | | - "} \n", |
22 | | - "$( document ).ready(code_toggle);\n", |
23 | | - "</script>\n", |
24 | | - "<form action=\"javascript:code_toggle()\"><input type=\"submit\" value=\"Click here to toggle on/off the raw code.\"></form>\"\"\"\n", |
25 | | - ")" |
26 | | - ] |
27 | | - }, |
28 | 3 | { |
29 | 4 | "cell_type": "markdown", |
30 | 5 | "metadata": {}, |
|
52 | 27 | "metadata": {}, |
53 | 28 | "outputs": [], |
54 | 29 | "source": [ |
55 | | - "print(\"type of True and False: {}\".format(type(True)))" |
| 30 | + "print(f\"type of True and False: {type(True)}\")" |
56 | 31 | ] |
57 | 32 | }, |
58 | 33 | { |
|
61 | 36 | "metadata": {}, |
62 | 37 | "outputs": [], |
63 | 38 | "source": [ |
64 | | - "print(\"0: {}, 1: {}\".format(bool(0), bool(1)))\n", |
65 | | - "print(\"empty list: {}, list with values: {}\".format(bool([]), bool([\"woop\"])))\n", |
66 | | - "print(\"empty dict: {}, dict with values: {}\".format(bool({}), bool({\"Python\": \"cool\"})))" |
| 39 | + "print(f\"0: {bool(0)}, 1: {bool(1)}\")\n", |
| 40 | + "print(f\"empty list: {bool([])}, list with values: {bool(['woop'])}\")\n", |
| 41 | + "print(f\"empty dict: {bool({})}, dict with values: {bool({'Python': 'cool'})}\")" |
67 | 42 | ] |
68 | 43 | }, |
69 | 44 | { |
|
79 | 54 | "metadata": {}, |
80 | 55 | "outputs": [], |
81 | 56 | "source": [ |
82 | | - "print(\"1 == 0: {}\".format(1 == 0))\n", |
83 | | - "print(\"1 != 0: {}\".format(1 != 0))\n", |
84 | | - "print(\"1 > 0: {}\".format(1 > 0))\n", |
85 | | - "print(\"1 > 1: {}\".format(1 > 1))\n", |
86 | | - "print(\"1 < 0: {}\".format(1 < 0))\n", |
87 | | - "print(\"1 < 1: {}\".format(1 < 1))\n", |
88 | | - "print(\"1 >= 0: {}\".format(1 >= 0))\n", |
89 | | - "print(\"1 >= 1: {}\".format(1 >= 1))\n", |
90 | | - "print(\"1 <= 0: {}\".format(1 <= 0))\n", |
91 | | - "print(\"1 <= 1: {}\".format(1 <= 1))" |
| 57 | + "print(f\"{1 == 0}\")\n", |
| 58 | + "print(f\"{1 != 0}\")\n", |
| 59 | + "print(f\"{1 > 0}\")\n", |
| 60 | + "print(f\"{1 > 1}\")\n", |
| 61 | + "print(f\"{1 < 0}\")\n", |
| 62 | + "print(f\"{1 < 1}\")\n", |
| 63 | + "print(f\"{1 >= 0}\")\n", |
| 64 | + "print(f\"{1 >= 1}\")\n", |
| 65 | + "print(f\"{1 <= 0}\")\n", |
| 66 | + "print(f\"{1 <= 1}\")" |
92 | 67 | ] |
93 | 68 | }, |
94 | 69 | { |
|
104 | 79 | "metadata": {}, |
105 | 80 | "outputs": [], |
106 | 81 | "source": [ |
107 | | - "print(\"1 <= 2 <= 3: {}\".format(1 <= 2 <= 3))" |
| 82 | + "print(f\"{1 <= 2 <= 3}\")" |
108 | 83 | ] |
109 | 84 | }, |
110 | 85 | { |
|
132 | 107 | "metadata": {}, |
133 | 108 | "outputs": [], |
134 | 109 | "source": [ |
135 | | - "print(\"Python and java are both cool: {}\".format(python_is_cool and java_is_cool))\n", |
136 | | - "print(\"secret_value and python_is_cool: {}\".format(secret_value and python_is_cool))" |
| 110 | + "print(f\"Python and java are both cool: {python_is_cool and java_is_cool}\")\n", |
| 111 | + "print(f\"secret_value and python_is_cool: {secret_value and python_is_cool}\")" |
137 | 112 | ] |
138 | 113 | }, |
139 | 114 | { |
|
142 | 117 | "metadata": {}, |
143 | 118 | "outputs": [], |
144 | 119 | "source": [ |
145 | | - "print(\"Python or java is cool: {}\".format(python_is_cool or java_is_cool))\n", |
146 | | - "print('1 >= 1.1 or 2 < float(\"1.4\"): {}'.format(1 >= 1.1 or 2 < float(\"1.4\")))" |
| 120 | + "print(f\"Python or java is cool: {python_is_cool or java_is_cool}\")\n", |
| 121 | + "print(f\"{1 >= 1.1 or 2 < 1.4}\")" |
147 | 122 | ] |
148 | 123 | }, |
149 | 124 | { |
|
152 | 127 | "metadata": {}, |
153 | 128 | "outputs": [], |
154 | 129 | "source": [ |
155 | | - "print(\"Java is not cool: {}\".format(not java_is_cool))" |
| 130 | + "print(f\"Java is not cool: {not java_is_cool}\")" |
156 | 131 | ] |
157 | 132 | }, |
158 | 133 | { |
|
310 | 285 | "name": "python", |
311 | 286 | "nbconvert_exporter": "python", |
312 | 287 | "pygments_lexer": "ipython3", |
313 | | - "version": "3.10.3" |
| 288 | + "version": "3.11.0" |
314 | 289 | } |
315 | 290 | }, |
316 | 291 | "nbformat": 4, |
|
0 commit comments