{"id":188,"date":"2020-11-07T11:06:41","date_gmt":"2020-11-07T11:06:41","guid":{"rendered":"http:\/\/lamiaiftekhar.com\/?page_id=188"},"modified":"2020-11-07T11:06:41","modified_gmt":"2020-11-07T11:06:41","slug":"20-minutes-python-day-2","status":"publish","type":"page","link":"https:\/\/lamiaiftekhar.com\/index.php\/20-minutes-python-day-2\/","title":{"rendered":"20-Minutes Python: Day 2"},"content":{"rendered":"<body>\n<p>Today we will be working with the concept of cells and cell types.\u00a0\u00a0<\/p>\n\n\n\n<ol class=\"wp-block-list\" type=\"1\"><li>So, in Jupyter Notebook, each of those lines where we can enter stuff is a cell. You can see that there is a cell number in the beginning\u00a0 \u2018In[1]\u2019 ,\u00a0 \u2018 In[2] \u2018 etc.\u00a0 (If you are using an old file where some code is already written and you are starting from, say the 15th cell,\u00a0 sometimes the numbering will be off.\u00a0 Or there won\u2019t be any number at all, just In[ ]. Don\u2019t worry too much about it,\u00a0 it has to do with this thing called \u2018Kernel\u2019\u00a0 \u2013\u00a0 which we will explore much later perhaps) .\u00a0 When\u00a0 you press Ctrl+Enter, Python runs your code in the current cell, gives the output AND\u00a0 a new cell all ready for your next input.\u00a0 Sometimes you do not want that dangling new cell\u00a0 (perhaps you are done for the day practicing python).\u00a0\u00a0 You can get rid of cells by deleting it.\u00a0<\/li><\/ol>\n\n\n\n<p><br>Let\u2019s do it manually.\u00a0<\/p>\n\n\n\n<p>Select a cell to delete (just put the cursor there)<\/p>\n\n\n\n<p>Go to Edit<\/p>\n\n\n\n<p>Click Delete Cell from the dropdown menu .<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>2. Now let\u2019s delete a cell using keyboard shortcut.\u00a0\u00a0<\/p>\n\n\n\n<p>\u00a0Write in a cell<strong> print(\u201cI\u2019m here only for a short time \u2013 for the greater good!\u201d)<\/strong> .<\/p>\n\n\n\n<p>You can run it and see output just for the sake of it :3<\/p>\n\n\n\n<p>Click back on the cell.<\/p>\n\n\n\n<p>There will be a blinking cursor at the end of the code (or wherever you clicked on the code).<\/p>\n\n\n\n<p>Now press \u2018Esc\u2019 button.\u00a0<\/p>\n\n\n\n<p>This is a\u00a0 cool\u00a0 thing\u00a0 in\u00a0 Jupyter Notebooks \u2013 which\u00a0 is called the \u2018Command Mode\u2019 and you can manipulate cells while you are in the Command Mode.\u00a0<\/p>\n\n\n\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 You can be sure you are in the Command Mode, if that blinking cursor disappears.<\/p>\n\n\n\n<p>While in the Command Mode,\u00a0 press \u2018d\u2019 twice.\u00a0<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>3. Cells can be of two\u00a0 main types \u2013\u00a0 Code\u00a0 and Markdown.\u00a0 So far, we had been working on \u2018Code\u2019 type cells where we insert pieces of codes.<\/p>\n\n\n\n<p>Markdown is like glorified commenting \u2013 amazing stuff.\u00a0 Makes a Jupyter Notebook such a powerful explanatory document.\u00a0<\/p>\n\n\n\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 We use cells in Markdown to write text that can explain our code or describe what we are doing.\u00a0<\/p>\n\n\n\n<p>For students learning Python, they can write answers to specific questions associated with their code as \u2018plain text\u2019\u00a0 by using the Markdown mode.\u00a0<\/p>\n\n\n\n<p>Let\u2019s write our first Markdown cell entry.\u00a0<\/p>\n\n\n\n<p>To make current cell Markdown:<\/p>\n\n\n\n<p>Go to Command Mode ( press Esc)<\/p>\n\n\n\n<p>Press \u2018m\u2019<\/p>\n\n\n\n<p>You will notice the \u2018 In [ ]\u2019 on the left has disappeared.<\/p>\n\n\n\n<p>Now write\u00a0 <strong>What is this Markdown thing? I cannot wait to see!<\/strong><\/p>\n\n\n\n<p>Then run it! (Shift+Enter)<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>4. You can double-click back on that output and it will return to that Markdown cell mode.\u00a0 You can edit the cell content.\u00a0 Edit it so that it reads the following:<\/p>\n\n\n\n<p><strong>What is this Markdown thing? I cannot wait to see!<\/strong><\/p>\n\n\n\n<p><strong>Aha!\u00a0 This opens up a door of possibilities.<\/strong><\/p>\n\n\n\n<p>Were you able to go to a new line in Markdown? Does pressing the\u00a0 \u2018Enter\u2019 button only once work?<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>5. You can return a cell into Code mode as follows:<\/p>\n\n\n\n<p>While cell is selected,<\/p>\n\n\n\n<p>Go to Command Mode<\/p>\n\n\n\n<p>Press \u2018y\u2019<\/p>\n\n\n\n<p>Do this for a cell which is already in Markdown mode and write <strong>print(\u201cThat was fun!\u201d) <\/strong>and run it.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>6. Now\u00a0 go to a new cell and\u00a0 get it into Markdown mode.<\/p>\n\n\n\n<p>Type\u00a0 <strong># This is a Level 1 Heading<\/strong>.\u00a0 ( Ensure the space between hashtag and the succeeding word).\u00a0<\/p>\n\n\n\n<p>Run it.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>7. Go to new cell and get it to Markdown mode.\u00a0<\/p>\n\n\n\n<p>Type<\/p>\n\n\n\n<p><strong>## This is a Level 2 Heading .<\/strong>\u00a0 Then press enter.\u00a0 You will go to next line ( but same cell \u2013 just like for Code type cell).<\/p>\n\n\n\n<p>Write\u00a0 <strong>\u00a0Level 2\u00a0 is slightly smaller in font.<\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>8. Go to new cell and get it to Markdown mode.\u00a0<\/p>\n\n\n\n<p>Type<\/p>\n\n\n\n<p><strong>### This is a Level 3 Heading .<\/strong><\/p>\n\n\n\n<p>In next line, type:<\/p>\n\n\n\n<p><strong>LIh likes this the most for casual use, as it is polite and not too loud and gaudy.\u00a0<\/strong><\/p>\n\n\n\n<p>9. In a cell at Markdown mode,\u00a0 write<\/p>\n\n\n\n<p><strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 `print` is the first function I used in Python.<\/strong><\/p>\n\n\n\n<p>Ensure those <em>backtick<\/em> marks around print. Run the cell.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>10. As the exercise for today, reproduce the text in the attached photo, exactly as it is.\u00a0<\/p>\n\n\n\n<p>Hint:\u00a0\u00a0 Surround a word\u00a0 or phrase by one asterisk on both sides to italicize it and two asterisks on both sides\u00a0 to bold it.\u00a0 E.g. *This is become italicized*\u00a0 ,\u00a0 **This will be bold**<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"1024\" height=\"199\" src=\"https:\/\/i0.wp.com\/lamiaiftekhar.com\/wp-content\/uploads\/2020\/11\/Day-2.png?resize=1024%2C199\" alt=\"\" class=\"wp-image-193\" loading=\"lazy\" srcset=\"https:\/\/i0.wp.com\/lamiaiftekhar.com\/wp-content\/uploads\/2020\/11\/Day-2.png?resize=1024%2C199&amp;ssl=1 1024w, https:\/\/i0.wp.com\/lamiaiftekhar.com\/wp-content\/uploads\/2020\/11\/Day-2.png?resize=300%2C58&amp;ssl=1 300w, https:\/\/i0.wp.com\/lamiaiftekhar.com\/wp-content\/uploads\/2020\/11\/Day-2.png?resize=768%2C150&amp;ssl=1 768w, https:\/\/i0.wp.com\/lamiaiftekhar.com\/wp-content\/uploads\/2020\/11\/Day-2.png?w=1422&amp;ssl=1 1422w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/body>","protected":false},"excerpt":{"rendered":"<p>Today we will be working with the concept of cells and cell types.\u00a0\u00a0 So, in Jupyter Notebook, each of those lines where we can enter stuff is a cell. You can see that there is a cell number in the beginning\u00a0 \u2018In[1]\u2019 ,\u00a0 \u2018 In[2] \u2018 etc.\u00a0 (If you are using an old file where [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-188","page","type-page","status-publish","hentry","entry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/lamiaiftekhar.com\/index.php\/wp-json\/wp\/v2\/pages\/188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lamiaiftekhar.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/lamiaiftekhar.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/lamiaiftekhar.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lamiaiftekhar.com\/index.php\/wp-json\/wp\/v2\/comments?post=188"}],"version-history":[{"count":1,"href":"https:\/\/lamiaiftekhar.com\/index.php\/wp-json\/wp\/v2\/pages\/188\/revisions"}],"predecessor-version":[{"id":194,"href":"https:\/\/lamiaiftekhar.com\/index.php\/wp-json\/wp\/v2\/pages\/188\/revisions\/194"}],"wp:attachment":[{"href":"https:\/\/lamiaiftekhar.com\/index.php\/wp-json\/wp\/v2\/media?parent=188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}