{"id":47370,"date":"2026-11-24T22:04:47","date_gmt":"2026-11-24T22:04:47","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=47370"},"modified":"2026-11-24T22:04:47","modified_gmt":"2026-11-24T22:04:47","slug":"jupyter-notebook-lab-session-10-introduction-of-data-types-variables-checkpoint","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/jupyter-notebook-lab-session-10-introduction-of-data-types-variables-checkpoint\/","title":{"rendered":"Jupyter notebook \u2013 Lab Session \u2013 10 \u2013 Introduction of Data Types, Variables &amp; checkpoint"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This lab is a Jupyter notebook that introduces Python&#039;s basic data types (str, int, float, bool), variables and naming rules, arithmetic, comparison and string operators, and the list, tuple and dict collections. The guide below explains what each group of cells shows, why some cells deliberately fail, what the word &quot;checkpoint&quot; in the file name means, and fills in topics the notebook skips, such as type conversion, floor division and safe dictionary lookups.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/devops-school\/082ee2640365eda326b5eb61aa1aef32.js\"><\/script>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">What the notebook covers<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The notebook embedded above is a run-through of Python fundamentals inside Jupyter. Each cell is short and shows one idea with its output. This table maps the cells to the concept each one demonstrates, so you can find a topic quickly.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Cells<\/th><th>Concept<\/th><th>Key takeaway<\/th><\/tr><\/thead><tbody><tr><td><code>a = &quot;hacktiv8&quot;<\/code>, <code>a = 8<\/code>, <code>a = &quot;8&quot;<\/code><\/td><td>Dynamic typing<\/td><td>A variable has no fixed type. <code>type()<\/code> reports the type of the value it currently holds, so <code>8<\/code> and <code>&quot;8&quot;<\/code> are different types.<\/td><\/tr><tr><td>Quote examples<\/td><td>String literals<\/td><td>Use the other quote style, or escape with <code>\\&#039;<\/code> \/ <code>\\&quot;<\/code>, to put a quote inside a string.<\/td><\/tr><tr><td><code>123123123123123123123 + 1<\/code><\/td><td>Integers<\/td><td>Python integers have arbitrary precision and do not overflow.<\/td><\/tr><tr><td><code>4.<\/code>, <code>.4e7<\/code>, <code>4.2e-4<\/code><\/td><td>Floats<\/td><td>Scientific notation always produces a <code>float<\/code>.<\/td><\/tr><tr><td><code>a = b = c = 300<\/code>, <code>var = 24.5<\/code> then a string<\/td><td>Assignment<\/td><td>Chained assignment, and a variable can be rebound to a value of another type.<\/td><\/tr><tr><td><code>age<\/code>, <code>Age<\/code>, <code>AGE<\/code>, <code>_age<\/code><\/td><td>Identifiers<\/td><td>Names are case-sensitive and cannot start with a digit.<\/td><\/tr><tr><td><code>+ - * \/ % **<\/code>, <code>== != &lt;= &gt;=<\/code><\/td><td>Operators<\/td><td><code>\/<\/code> always returns a <code>float<\/code>. Comparisons return <code>bool<\/code>.<\/td><\/tr><tr><td><code>s + t<\/code>, <code>s * 4<\/code>, <code>in<\/code>, <code>.upper()<\/code><\/td><td>String operations<\/td><td>Concatenation, repetition, substring test and case methods.<\/td><\/tr><tr><td>List cells<\/td><td>Lists<\/td><td>Ordered and mutable, with indexing, negative indexing, slicing, <code>del<\/code> and slice assignment.<\/td><\/tr><tr><td>Tuple cells<\/td><td>Tuples<\/td><td>Ordered and immutable. Supports unpacking into several variables.<\/td><\/tr><tr><td><code>MLB_team<\/code>, <code>person<\/code><\/td><td>Dictionaries<\/td><td>Key\/value pairs that can be added, updated, deleted and nested.<\/td><\/tr><tr><td><code>someone_is_of_working_age<\/code><\/td><td>Line continuation<\/td><td>Wrap a long expression in parentheses to split it over several lines.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Run the lab yourself<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create an isolated environment and install JupyterLab with the commands below.<\/li>\n\n\n<li>Download the notebook from the gist embedded above (via the gist&#039;s <strong>Download ZIP<\/strong> button, or with <code>git clone<\/code>), then give it a clean name.<\/li>\n\n\n<li>Start JupyterLab and open the notebook.<\/li>\n\n\n<li>Use <strong>Kernel &gt; Restart Kernel and Run All Cells<\/strong>. The cells were originally run out of order (the execution counts jump from 2 to 4, 9 to 11, and so on), and a clean top-to-bottom run shows the real outputs.<\/li>\n\n\n<li>Two cells stop with <code>SyntaxError<\/code>. This is deliberate. Read the error and move on to the next cell.<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">python3 -m venv .venv\nsource .venv\/bin\/activate        <span class=\"hljs-comment\"># Windows: .venv\\Scripts\\activate<\/span>\npip install jupyterlab\n\ngit <span class=\"hljs-keyword\">clone<\/span> https:<span class=\"hljs-comment\">\/\/gist.github.com\/082ee2640365eda326b5eb61aa1aef32.git lab10<\/span>\ncd lab10\nmv Jupyter-notebook-DataTypes-Variables-checkpoint.ipynb datatypes-variables.ipynb\n\njupyter lab<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">To run the whole notebook without the browser, for example in CI, use nbconvert. Without <code>--allow-errors<\/code>, execution stops at the first intentional <code>SyntaxError<\/code>.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-tag\">jupyter<\/span> <span class=\"hljs-selector-tag\">nbconvert<\/span> <span class=\"hljs-selector-tag\">--to<\/span> <span class=\"hljs-selector-tag\">notebook<\/span> <span class=\"hljs-selector-tag\">--execute<\/span> <span class=\"hljs-selector-tag\">--allow-errors<\/span> \\\n  <span class=\"hljs-selector-tag\">datatypes-variables<\/span><span class=\"hljs-selector-class\">.ipynb<\/span> <span class=\"hljs-selector-tag\">--output<\/span> <span class=\"hljs-selector-tag\">executed<\/span><span class=\"hljs-selector-class\">.ipynb<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> The notebook metadata shows a Python 3.8 kernel. Python 3.8 is end-of-life, so use a supported Python 3 release. All the cells behave the same on current versions, though some error messages are worded differently.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why two cells fail on purpose<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Unescaped quote.<\/strong> In <code>print(&#039;This string contains a single quote (&#039;) character.&#039;)<\/code>, the second <code>&#039;<\/code> closes the string early. Python then reads <code>character.<\/code> as code and finds a new string that never closes. Older Python versions report <code>invalid syntax<\/code>. Recent versions say <code>unterminated string literal<\/code>. There are three fixes:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-string\">\"This string contains a single quote (') character.\"<\/span>)   <span class=\"hljs-comment\"># switch outer quotes<\/span>\n<span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-string\">'This string contains a single quote (\\') character.'<\/span>)   <span class=\"hljs-comment\"># escape the quote<\/span>\n<span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-string\">\"\"<\/span><span class=\"hljs-string\">\"Quotes ' and \"<\/span> both work inside triple quotes.<span class=\"hljs-string\">\"\"<\/span><span class=\"hljs-string\">\")    # triple quotes<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Invalid identifier.<\/strong> <code>9_kepala_naga = True<\/code> fails because a variable name cannot start with a digit. Python reads <code>9_<\/code> as the start of a number (underscores are allowed in numeric literals, as in <code>1_000_000<\/code>), so it reports <code>invalid decimal literal<\/code>. Rename it to <code>kepala_naga_9<\/code> or <code>nine_headed_dragon<\/code>. Names can contain letters, digits and underscores, cannot be a keyword such as <code>class<\/code> or <code>for<\/code>, and by convention use <code>snake_case<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why a cell shows only one value<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Jupyter automatically displays only the value of the <strong>last expression<\/strong> in a cell. A bare expression earlier in the cell is evaluated, and its result is thrown away. This explains several outputs in the notebook:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>a = 30<\/code>, <code>a<\/code>, <code>b = 20<\/code>, <code>b<\/code> shows only <code>20<\/code>. The <code>a<\/code> on line 2 is never displayed.<\/li>\n\n\n<li>In the <code>name = &quot;ANI&quot;<\/code> cell, <code>name<\/code> and <code>&#039;ANI&#039;<\/code> show nothing. Only the <code>print(name)<\/code> output appears.<\/li>\n\n\n<li>In the <code>person = {}<\/code> cell, <code>type(person)<\/code> shows nothing because more statements follow it.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">To show several values from one cell, use <code>print()<\/code>, or <code>display()<\/code>, which is available in IPython kernels and keeps rich formatting:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">a = <span class=\"hljs-number\">30<\/span>\nb = <span class=\"hljs-number\">20<\/span>\n<span class=\"hljs-keyword\">print<\/span>(a, b)        <span class=\"hljs-comment\"># 30 20<\/span>\ndisplay(a)         <span class=\"hljs-comment\"># 30<\/span>\ndisplay(b)         <span class=\"hljs-comment\"># 20<\/span>\n\n<span class=\"hljs-comment\"># Or tell IPython to echo every bare expression in later cells<\/span>\nfrom IPython.core.interactiveshell import InteractiveShell\nInteractiveShell.ast_node_interactivity = <span class=\"hljs-string\">\"all\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Type conversion and operators the lab skips<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The notebook shows that <code>8<\/code> and <code>&quot;8&quot;<\/code> have different types but never converts between them. Data you read from files, forms or <code>input()<\/code> usually arrives as strings, so conversion comes up constantly. Run this cell after the lab. The expected output is in the comments.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">a = <span class=\"hljs-string\">\"8\"<\/span>\nb = int(a)\n<span class=\"hljs-keyword\">print<\/span>(b + <span class=\"hljs-number\">2<\/span>, type(b))            <span class=\"hljs-comment\"># 10 &lt;class 'int'&gt;<\/span>\n<span class=\"hljs-keyword\">print<\/span>(float(<span class=\"hljs-string\">\"4.2\"<\/span>) * <span class=\"hljs-number\">2<\/span>)          <span class=\"hljs-comment\"># 8.4<\/span>\n<span class=\"hljs-keyword\">print<\/span>(str(<span class=\"hljs-number\">8<\/span>) + <span class=\"hljs-string\">\"8\"<\/span>)              <span class=\"hljs-comment\"># 88<\/span>\n<span class=\"hljs-comment\"># \"8\" + 2  -&gt; TypeError: can only concatenate str (not \"int\") to str<\/span>\n\n<span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-number\">7<\/span> <span class=\"hljs-comment\">\/\/ 2, -7 \/\/ 2)           # 3 -4   (floor division rounds down)<\/span>\n<span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-number\">7<\/span> % <span class=\"hljs-number\">2<\/span>, divmod(<span class=\"hljs-number\">7<\/span>, <span class=\"hljs-number\">2<\/span>))       <span class=\"hljs-comment\"># 1 (3, 1)<\/span>\n<span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-number\">10<\/span> &lt; <span class=\"hljs-number\">20<\/span>, <span class=\"hljs-number\">10<\/span> &gt; <span class=\"hljs-number\">20<\/span>)          <span class=\"hljs-comment\"># True False<\/span>\n<span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-number\">18<\/span> &lt;= <span class=\"hljs-number\">42<\/span> &lt;= <span class=\"hljs-number\">65<\/span>)            <span class=\"hljs-comment\"># True  (chained comparison)<\/span>\n\n<span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-number\">0.1<\/span> + <span class=\"hljs-number\">0.2<\/span>)                 <span class=\"hljs-comment\"># 0.30000000000000004<\/span>\n<span class=\"hljs-keyword\">print<\/span>(round(<span class=\"hljs-number\">0.1<\/span> + <span class=\"hljs-number\">0.2<\/span>, <span class=\"hljs-number\">2<\/span>))       <span class=\"hljs-comment\"># 0.3<\/span>\n\n<span class=\"hljs-keyword\">print<\/span>(bool(<span class=\"hljs-number\">0<\/span>), bool(<span class=\"hljs-string\">\"\"<\/span>), bool(<span class=\"hljs-string\">\"False\"<\/span>))   <span class=\"hljs-comment\"># False False True<\/span>\n<span class=\"hljs-keyword\">print<\/span>(type(None))                <span class=\"hljs-comment\"># &lt;class 'NoneType'&gt;<\/span>\n<span class=\"hljs-keyword\">print<\/span>(isinstance(<span class=\"hljs-keyword\">True<\/span>, int))     <span class=\"hljs-comment\"># True  (bool is a subclass of int)<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Chained comparisons also make the line continuation example shorter and easier to read: <code>(18 &lt;= person1_age &lt;= 65) or (18 &lt;= person2_age &lt;= 65) or (18 &lt;= person3_age &lt;= 65)<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Lists, tuples and dictionaries: behaviour to know<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In the slice assignment cell, <code>a[1:4] = [1.1, 2.2, 3.3, 4.4, 5.5]<\/code> replaces <strong>three<\/strong> items with <strong>five<\/strong>, so the list grows from 6 to 8 elements. A slice on the left side of <code>=<\/code> does not need to match the length of the new values. The cell below covers the edge cases beginners hit most often:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># Tuples are immutable<\/span>\nt = (<span class=\"hljs-string\">'foo'<\/span>, <span class=\"hljs-string\">'bar'<\/span>)\n<span class=\"hljs-comment\"># t&#91;0] = 'x'  -&gt; TypeError: 'tuple' object does not support item assignment<\/span>\n<span class=\"hljs-keyword\">print<\/span>(type((<span class=\"hljs-string\">'foo'<\/span>)), type((<span class=\"hljs-string\">'foo'<\/span>,)))   <span class=\"hljs-comment\"># &lt;class 'str'&gt; &lt;class 'tuple'&gt;  (the comma makes the tuple)<\/span>\n\n<span class=\"hljs-comment\"># min()\/max() on strings compare by Unicode code point, not pure alphabet order<\/span>\n<span class=\"hljs-keyword\">print<\/span>(min(&#91;<span class=\"hljs-string\">'foo'<\/span>, <span class=\"hljs-string\">'Bar'<\/span>, <span class=\"hljs-string\">'apple'<\/span>]))                  <span class=\"hljs-comment\"># Bar  (uppercase sorts first)<\/span>\n<span class=\"hljs-keyword\">print<\/span>(min(&#91;<span class=\"hljs-string\">'foo'<\/span>, <span class=\"hljs-string\">'Bar'<\/span>, <span class=\"hljs-string\">'apple'<\/span>], key=str.lower))   <span class=\"hljs-comment\"># apple<\/span>\n\n<span class=\"hljs-comment\"># Missing dictionary keys<\/span>\nd = {<span class=\"hljs-string\">'a'<\/span>: <span class=\"hljs-number\">10<\/span>}\n<span class=\"hljs-comment\"># d&#91;'z']  -&gt; KeyError: 'z'<\/span>\n<span class=\"hljs-keyword\">print<\/span>(d.get(<span class=\"hljs-string\">'z'<\/span>), d.get(<span class=\"hljs-string\">'z'<\/span>, <span class=\"hljs-number\">0<\/span>))       <span class=\"hljs-comment\"># None 0<\/span>\n<span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-string\">'a'<\/span> in d)                        <span class=\"hljs-comment\"># True (checks keys, not values)<\/span>\n\n<span class=\"hljs-comment\"># Chained assignment with mutable objects shares ONE object<\/span>\nx = y = &#91;]\nx.append(<span class=\"hljs-number\">1<\/span>)\n<span class=\"hljs-keyword\">print<\/span>(y)                               <span class=\"hljs-comment\"># &#91;1]<\/span>\nx, y = &#91;], &#91;]                          <span class=\"hljs-comment\"># two independent lists<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> <code>a = b = c = 300<\/code> is safe because integers are immutable. With lists or dicts, all three names point to the same object, so a change through one name shows up through the others.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What checkpoint means in this lab<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>-checkpoint<\/code> suffix in the file name is not a Python concept. It comes from Jupyter&#039;s checkpoint feature. When you save a notebook explicitly (Ctrl+S, or <strong>Save and Checkpoint<\/strong> in the classic interface), Jupyter writes a snapshot to a hidden <code>.ipynb_checkpoints\/<\/code> folder next to the notebook, named <code>&lt;notebook&gt;-checkpoint.ipynb<\/code>. Autosave updates the notebook file itself but leaves the checkpoint alone. If you break a notebook, <strong>File &gt; Revert Notebook to Checkpoint<\/strong> restores the last explicit save.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Jupyter keeps one checkpoint per notebook by default. It is a quick undo, not version history. Use Git for history.<\/li>\n\n\n<li>Add <code>.ipynb_checkpoints\/<\/code> to <code>.gitignore<\/code> so snapshot copies are never committed or shared by mistake, which is how this lab&#039;s file name ended up with the suffix.<\/li>\n\n\n<li>Clear outputs before committing to keep diffs small: <code>jupyter nbconvert --clear-output --inplace datatypes-variables.ipynb<\/code>.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Corrections to the original notebook<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Original<\/th><th>Corrected<\/th><th>Why<\/th><\/tr><\/thead><tbody><tr><td><code>print(&quot;Hackiv8 &quot; + &quot;PTP&quot;)<\/code><\/td><td><code>print(&quot;Hacktiv8 &quot; + &quot;PTP&quot;)<\/code><\/td><td>Typo. Every other cell spells it Hacktiv8.<\/td><\/tr><tr><td><code>#len(), min(), max() berdasarkan dari urutan abjad<\/code><\/td><td><code># len(), min(), max(): min\/max compare strings by Unicode code point<\/code><\/td><td>The comment is in Indonesian (&quot;based on alphabetical order&quot;), and the order is not purely alphabetical because uppercase letters sort before lowercase.<\/td><\/tr><tr><td><code>#in Opeators<\/code><\/td><td><code># in operator<\/code><\/td><td>Typo in the comment.<\/td><\/tr><tr><td><code>&quot;Now I&#039;am a String&quot;<\/code><\/td><td><code>&quot;Now I&#039;m a String&quot;<\/code><\/td><td>Grammar in the string literal.<\/td><\/tr><tr><td><code>a = 30<\/code> \/ <code>a<\/code> \/ <code>b = 20<\/code> \/ <code>b<\/code><\/td><td><code>print(a)<\/code> and <code>print(b)<\/code><\/td><td>Only the last expression in a cell is displayed, so <code>a<\/code> never appears.<\/td><\/tr><tr><td>File saved as <code>...-checkpoint.ipynb<\/code><\/td><td>Save as a plain name such as <code>datatypes-variables.ipynb<\/code><\/td><td>The file is a Jupyter checkpoint snapshot, not the working notebook.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently asked questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Why does type(&quot;8&quot;) return str while type(8) returns int?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Quotes make a value a string literal, whatever characters it contains. Use <code>int(&quot;8&quot;)<\/code> or <code>float(&quot;8&quot;)<\/code> to convert it before doing arithmetic.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why does 10\/5 give 2.0 instead of 2 in Python?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In Python 3 the <code>\/<\/code> operator always performs true division and returns a float. Use <code>\/\/<\/code> for floor division, which returns an int when both operands are ints.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What is the .ipynb_checkpoints folder in Jupyter?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Jupyter creates it to hold a snapshot of each notebook from its last explicit save, which you can restore with Revert Notebook to Checkpoint. It is safe to delete, and you should add it to .gitignore.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why does my Jupyter cell show only the last value?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Jupyter displays only the result of the final expression in a cell. Use <code>print()<\/code> or <code>display()<\/code> for any other values you want to see.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What is the difference between a list and a tuple in Python?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Both are ordered sequences that support indexing and slicing. You can change a list in place, but a tuple is immutable, which makes it suitable for fixed records and usable as a dictionary key.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related tutorials<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/category\/data-engineering-analytics\/data-science\/\">More Data Science tutorials<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/associate-data-scientist-role-blueprint-responsibilities-skills-kpis-and-career-path\/\">Associate Data Scientist: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/top-10-data-science-platforms-features-pros-cons-comparison\/\">Top 10 Data Science Platforms: Features, Pros, Cons &amp; Comparison<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This lab is a Jupyter notebook that introduces Python&#039;s basic data types (str, int, float, bool), variables and naming rules, arithmetic, comparison and string operators, and the&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[6513],"tags":[15094],"class_list":["post-47370","post","type-post","status-publish","format-standard","hentry","category-data-science","tag-jupyter-notebook"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/47370","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=47370"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/47370\/revisions"}],"predecessor-version":[{"id":80195,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/47370\/revisions\/80195"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=47370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=47370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=47370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}