{"id":221,"date":"2020-11-10T09:51:51","date_gmt":"2020-11-10T09:51:51","guid":{"rendered":"http:\/\/lamiaiftekhar.com\/?page_id=221"},"modified":"2020-11-10T09:51:51","modified_gmt":"2020-11-10T09:51:51","slug":"20-minutes-python-day-11","status":"publish","type":"page","link":"http:\/\/lamiaiftekhar.com\/index.php\/20-minutes-python-day-11\/","title":{"rendered":"20-Minutes Python: Day 11"},"content":{"rendered":"<body>\n<p class=\"wp-block-paragraph\">Alright, so now that we are familiar with the concepts of True and False,\u00a0 let\u2019s look at three new operators (called logical operators) \u2013\u00a0 AND, NOT and OR.<\/p>\n\n\n\n<ol class=\"wp-block-list\" type=\"1\"><li>The \u2018not\u2019 operator takes one operand\u00a0 (one Boolean variable or statement etc.\u00a0 )\u00a0\u00a0 and\u00a0 just inverts it.<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Type and run<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>print(not True)<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>print(not(7&gt;8)==True)<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the first print \u2013\u00a0\u00a0 we start with True, then invert it to get False.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the second print \u2013\u00a0 Start with 7&gt;8 which is False.\u00a0 Invert this False to get True.\u00a0\u00a0 Then do True==True\u00a0\u00a0 \u2013\u00a0 which is True!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2. The \u2018and\u2019 operator takes two operands. It returns\u00a0 a \u2018True\u2019\u00a0 only if the operands on both side of it are \u2018True\u2019 . If at least one of them evaluates as \u2018False\u2019\u00a0 \u2013 the end result is \u2018False\u2019.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Type and run<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Ibrahim_cgpa=2.8<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Ibrahim_semester =9<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Rokeya_cgpa=3.3<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Rokeya_semester =4<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>#A student can do an internship at Company X only when<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>#his or her CGPA is greater than 2.5<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>#AND\u00a0<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>#he or she has completed at least\u00a0 2 years (6 semesters)<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>print(\u201cIbrahim can apply for the internship: %s\u201d\u00a0 %(Ibrahim_cgpa&gt;2.5\u00a0 and\u00a0 Ibrahim_semester&gt;=6) )<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>print(\u201cRokeya can apply for the internship: %s\u201d\u00a0 %(Rokeya_cgpa&gt;2.5\u00a0 and\u00a0 Rokeya_semester&gt;=6) )<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3. The \u2018or\u2019 operator also works with two operands.\u00a0 It is the more relaxed guy, compared to \u2018and\u2019 \ud83d\ude00\u00a0\u00a0 It yields \u2018True\u2019 as long as one of the operands\u00a0 is \u2018True\u2019.\u00a0 Both operands do not need to be true!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong># Company X decides to relax\u00a0 semester completion requirments if student has leadership experience<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Rokeya_IEEEevents = 3<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>print(\u201cRokeya can apply for the internship: %s\u201d\u00a0 %(Rokeya_semester&gt;=6 or Rokeya_IEEEevents&gt;0) )<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Exercise:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let us do some True and False exercise like the way we used to do in school!\u00a0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Look at the following print commands and deduce where each of the statement inside the print command is True or False.\u00a0 Do this mentally and do not print the statements yet.\u00a0<\/p>\n\n\n\n<ol class=\"wp-block-list\" type=\"1\"><li><strong>pri<\/strong><strong>nt(42&gt;40)<\/strong><\/li><li><strong>pri<\/strong><strong>nt(7*3&gt;20)<\/strong><\/li><li><strong>pri<\/strong><strong>nt(21&lt;=7*3)<\/strong><\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>a=[]<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>b=[]<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>c=a<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>d = [\u2018bag has something\u2019]<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\" type=\"1\"><li><strong>pri<\/strong><strong>nt( a is b)<\/strong><\/li><li><strong>pri<\/strong><strong>nt(a is b or a is c)<\/strong><\/li><li><strong>pri<\/strong><strong>nt(not a)<\/strong><\/li><li><strong>pri<\/strong><strong>nt(not d)<\/strong><\/li><li><strong>pri<\/strong><strong>nt(a==c and a != b)<\/strong><\/li><li><strong>pri<\/strong><strong>nt(8.0 != 8)<\/strong><\/li><li><strong>prin<\/strong><strong>t(9.0 is 9)<\/strong><\/li><li><strong>prin<\/strong><strong>t(\u2018feluda\u2019 is not \u2018shonku\u2019)<\/strong><\/li><li><strong>prin<\/strong><strong>t(2+3-4*6 &lt;= 0)<\/strong><\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Then write your answer in Markdown mode. Translate each statement to \u2018English\u2019 and then write on the right whether it is true or false. For example,\u00a0 translating and writing the first one in Markdown is simply this:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>42 is greater than 40:\u00a0 True<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then in Code mode,\u00a0 run the code ( print all the sentences given) and double check with your Markdown answers.<\/p>\n<\/body>","protected":false},"excerpt":{"rendered":"<p>Alright, so now that we are familiar with the concepts of True and False,\u00a0 let\u2019s look at three new operators (called logical operators) \u2013\u00a0 AND, NOT and OR. The \u2018not\u2019 operator takes one operand\u00a0 (one Boolean variable or statement etc.\u00a0 )\u00a0\u00a0 and\u00a0 just inverts it. Type and run print(not True) print(not(7&gt;8)==True) In the first print [&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-221","page","type-page","status-publish","hentry","entry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/lamiaiftekhar.com\/index.php\/wp-json\/wp\/v2\/pages\/221","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/lamiaiftekhar.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/lamiaiftekhar.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/lamiaiftekhar.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/lamiaiftekhar.com\/index.php\/wp-json\/wp\/v2\/comments?post=221"}],"version-history":[{"count":1,"href":"http:\/\/lamiaiftekhar.com\/index.php\/wp-json\/wp\/v2\/pages\/221\/revisions"}],"predecessor-version":[{"id":222,"href":"http:\/\/lamiaiftekhar.com\/index.php\/wp-json\/wp\/v2\/pages\/221\/revisions\/222"}],"wp:attachment":[{"href":"http:\/\/lamiaiftekhar.com\/index.php\/wp-json\/wp\/v2\/media?parent=221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}