{"id":223,"date":"2020-11-10T09:56:31","date_gmt":"2020-11-10T09:56:31","guid":{"rendered":"http:\/\/lamiaiftekhar.com\/?page_id=223"},"modified":"2020-11-10T09:56:31","modified_gmt":"2020-11-10T09:56:31","slug":"20-minutes-python-day-12","status":"publish","type":"page","link":"https:\/\/lamiaiftekhar.com\/index.php\/20-minutes-python-day-12\/","title":{"rendered":"20-Minutes Python: Day 12"},"content":{"rendered":"<body>\n<p>Time for some if-else conditions!<\/p>\n\n\n\n<p>In Python,\u00a0 if else code is very simple in syntax .\u00a0\u00a0\u00a0\u00a0<\/p>\n\n\n\n<p>if <em>condition1<\/em>:<\/p>\n\n\n\n<p>Do stuff<\/p>\n\n\n\n<p>elif condition2:<\/p>\n\n\n\n<p>Do different stuff<\/p>\n\n\n\n<p>else:<\/p>\n\n\n\n<p>Do even different stuff<\/p>\n\n\n\n<p>Notice \u2013<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>The colon positions<\/li><li>And as soon as you hit enter after putting the colons like that there will a tab in next line.<\/li><\/ul>\n\n\n\n<p>Without the tab\u00a0 (indented block)\u00a0\u00a0 \u2013 the \u2018do stuff\u2019 part won\u2019t work<\/p>\n\n\n\n<ol class=\"wp-block-list\" type=\"1\"><li>\u00a0 Type and run:<\/li><\/ol>\n\n\n\n<p>song = \u201cPurbo digonte\u201d<\/p>\n\n\n\n<p><strong>if song ==\u2019Jala Jala Jala\u2019:<\/strong><\/p>\n\n\n\n<p><strong>\u00a0\u00a0\u00a0 print(\u201cThis is a \u2018band er gaan\u2019! \u201c)<\/strong><\/p>\n\n\n\n<p><strong>elif song==\u2019Purbo digonte\u2019:<\/strong><\/p>\n\n\n\n<p><strong>\u00a0\u00a0\u00a0 print(\u201cThis is a \u2018deshattobodhok gaan\u2019!\u201d)<\/strong><\/p>\n\n\n\n<p><strong>else:<\/strong><\/p>\n\n\n\n<p><strong>\u00a0\u00a0\u00a0 print(\u201cI don\u2019t know!\u201d)<\/strong><\/p>\n\n\n\n<p>2. Type and run<\/p>\n\n\n\n<p><strong>bag =[]<\/strong><\/p>\n\n\n\n<p><strong>if bag:<\/strong><\/p>\n\n\n\n<p><strong>\u00a0\u00a0\u00a0 print(\u201cBag has something!\u201d)<\/strong><\/p>\n\n\n\n<p><strong>else:<\/strong><\/p>\n\n\n\n<p><strong>\u00a0\u00a0\u00a0 print(\u201cEmpty bag :\/ \u201c)<\/strong><\/p>\n\n\n\n<p>3. Put a number or a few numbers in the \u2018bag\u2019 list above and run the code again.<\/p>\n\n\n\n<p>4. Type and run<\/p>\n\n\n\n<p><strong>age = 21<\/strong><\/p>\n\n\n\n<p><strong>if age&gt;8:<\/strong><\/p>\n\n\n\n<p><strong>\u00a0\u00a0\u00a0 print(\u201cYou are NOT allowed to call me Aunty. Call me Apu!\u201d)<\/strong><\/p>\n\n\n\n<p><strong>else:<\/strong><\/p>\n\n\n\n<p><strong>\u00a0\u00a0\u00a0 print(\u201cOk, you can call me Aunty, you cute little munchkin!\u201d)<\/strong><\/p>\n\n\n\n<p>5. Type and run:<\/p>\n\n\n\n<p><strong>lis<\/strong><strong>t1 = [ \u2018Hawkgirl\u2019, \u2018Alucard\u2019, \u2018Peter Pan\u2019, \u2018Marry Poppins\u2019]<\/strong><\/p>\n\n\n\n<p><strong>list2 =\u00a0 [\u2018Hulk\u2019, \u2018Starfire\u2019, \u2018Hercules\u2019, \u2018Goku\u2019 ]<\/strong><\/p>\n\n\n\n<p><strong>name = \u2018Peter Pan\u2019<\/strong><\/p>\n\n\n\n<p><strong>if name in list1:<\/strong><\/p>\n\n\n\n<p><strong>\u00a0\u00a0\u00a0 print(\u201cYou can fly!\u201d)<\/strong><\/p>\n\n\n\n<p><strong>else:<\/strong><\/p>\n\n\n\n<p><strong>\u00a0\u00a0\u00a0 print(\u2018You are strong!\u2019)<\/strong><\/p>\n\n\n\n<p>6. Type and run<\/p>\n\n\n\n<p><strong>list3 = [\u2018Alucard\u2019,\u2019Goku\u2019]<\/strong><\/p>\n\n\n\n<p><strong>if list1[2] in list3:<\/strong><\/p>\n\n\n\n<p><strong>\u00a0\u00a0\u00a0 print(\u201c%s is an anime character!\u201d\u00a0 %list1[2])<\/strong><\/p>\n\n\n\n<p>7. Fix ONLY the index numbers\u00a0\u00a0 in Problem 6 (change in two places only) ,\u00a0 so that an output is printed.<\/p>\n<\/body>","protected":false},"excerpt":{"rendered":"<p>Time for some if-else conditions! In Python,\u00a0 if else code is very simple in syntax .\u00a0\u00a0\u00a0\u00a0 if condition1: Do stuff elif condition2: Do different stuff else: Do even different stuff Notice \u2013 The colon positions And as soon as you hit enter after putting the colons like that there will a tab in next line. [&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-223","page","type-page","status-publish","hentry","entry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/lamiaiftekhar.com\/index.php\/wp-json\/wp\/v2\/pages\/223","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=223"}],"version-history":[{"count":1,"href":"https:\/\/lamiaiftekhar.com\/index.php\/wp-json\/wp\/v2\/pages\/223\/revisions"}],"predecessor-version":[{"id":224,"href":"https:\/\/lamiaiftekhar.com\/index.php\/wp-json\/wp\/v2\/pages\/223\/revisions\/224"}],"wp:attachment":[{"href":"https:\/\/lamiaiftekhar.com\/index.php\/wp-json\/wp\/v2\/media?parent=223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}