{"id":249,"date":"2016-01-09T10:08:55","date_gmt":"2016-01-09T10:08:55","guid":{"rendered":"http:\/\/mr-west.uk\/python\/?page_id=249"},"modified":"2016-07-21T18:01:42","modified_gmt":"2016-07-21T18:01:42","slug":"boolean-operators","status":"publish","type":"page","link":"https:\/\/learnlearn.uk\/python\/boolean-operators\/","title":{"rendered":"Boolean Operators"},"content":{"rendered":"\n<div class=\"arconix-tabs-horizontal\"><ul class=\"arconix-tabs\"><li data-arconix-icon=\" \" data-arconix-color=\" \" class=\"arconix-tab tab-Starter-Riddles\"><a class=\"\" href=\"#tab-Starter-Riddles\">Starter - Riddles<\/a><\/li>\n<li data-arconix-icon=\" \" data-arconix-color=\" \" class=\"arconix-tab tab-AND\"><a class=\"\" href=\"#tab-AND\">AND<\/a><\/li>\n<li data-arconix-icon=\" \" data-arconix-color=\" \" class=\"arconix-tab tab-OR\"><a class=\"\" href=\"#tab-OR\">OR<\/a><\/li>\n<li data-arconix-icon=\" \" data-arconix-color=\" \" class=\"arconix-tab tab-NOT\"><a class=\"\" href=\"#tab-NOT\">NOT<\/a><\/li>\n<li data-arconix-icon=\" \" data-arconix-color=\" \" class=\"arconix-tab tab-CombiningLogicGates\"><a class=\"\" href=\"#tab-CombiningLogicGates\">Combining Logic Gates<\/a><\/li>\n<li data-arconix-icon=\" \" data-arconix-color=\" \" class=\"arconix-tab tab-Practice\"><a class=\"\" href=\"#tab-Practice\">Practice<\/a><\/li>\n<li data-arconix-icon=\" \" data-arconix-color=\" \" class=\"arconix-tab tab-Plenary\"><a class=\"\" href=\"#tab-Plenary\">Plenary<\/a><\/li><\/ul>\n<div class=\"arconix-panes\"><div class=\"arconix-pane pane-Starter-Riddles\">\n<div class=\"arconix-accordions arconix-accordions-vertical arconix-accordions-1\"><div class=\"arconix-accordion-title accordion-KnightsandKnavesRiddle1\"><i class=\"fa\"><\/i><p>Knights and Knaves Riddle 1<\/p><\/div><div class=\"arconix-accordion-content\">\n<h3>Knights and Knaves Riddle\u00a01<\/h3>\n<p><a href=\"http:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/knight.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-556 alignright\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/knight-300x300.jpg\" alt=\"knight\" width=\"300\" height=\"300\" srcset=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/knight-300x300.jpg 300w, https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/knight-150x150.jpg 150w, https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/knight.jpg 700w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>You have been shipwrecked on the Knights and Knaves island. On this island there are only three types of people:<\/p>\n<div class=\"arconix-list\" data-arconix-icon=\"fa-chevron-circle-right\" data-arconix-color=\"black\">\n<ul>\n<li>Knights, who always tell the truth.<\/li>\n<li>Knaves, who always lie.<\/li>\n<li>Spies, who\u00a0can either tell the truth or lie.<\/li>\n<\/ul>\n<\/div>\n<p>You are walking down a footpath and are approached by two people <strong>Amy<\/strong>\u00a0and <strong>Bill<\/strong>.<\/p>\n<div class=\"arconix-list\" data-arconix-icon=\"fa-chevron-circle-right\" data-arconix-color=\"black\">\n<ul>\n<li>Bob says &#8220;At least one of use is a Knave.&#8221;<\/li>\n<li>You know that one is a knight and one is a knave.<\/li>\n<\/ul>\n<\/div>\n<p>Who is Amy\u00a0and who is Bill?<\/p>\n<\/div><div class=\"arconix-accordion-title accordion-KnightsandKnavesRiddle2\"><i class=\"fa\"><\/i><p>Knights and Knaves Riddle 2<\/p><\/div><div class=\"arconix-accordion-content\">\n<h3>Knights and Knaves Riddle 2<\/h3>\n<p>You are sunbathing on the beach when you are approached by three people.<\/p>\n<p>You know that one is a knight, one is a knave and one is a spy. However, you don&#8217;t know who is who.<\/p>\n<div class=\"arconix-list\" data-arconix-icon=\"fa-chevron-circle-right\" data-arconix-color=\"black\">\n<ul>\n<li>Alfred says &#8220;Charlie is a\u00a0Knave&#8221;<\/li>\n<li>Beatrix says &#8220;Alfred is a Knight&#8221;<\/li>\n<li>Charlie says &#8220;I am a\u00a0spy&#8221;<\/li>\n<\/ul>\n<\/div>\n<p>Who is who?<\/p>\n<\/div><\/div>\n<\/div>\n<div class=\"arconix-pane pane-AND\">\n<div class=\"arconix-accordions arconix-accordions-vertical arconix-accordions-1\"><div class=\"arconix-accordion-title accordion-ANDGates\"><i class=\"fa\"><\/i><p>AND Gates<\/p><\/div><div class=\"arconix-accordion-content\">\n<img decoding=\"async\" loading=\"lazy\" class=\"alignright size-full wp-image-563\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/and-gate-truth-table-2.png\" alt=\"and gate truth table (2)\" width=\"399\" height=\"485\" srcset=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/and-gate-truth-table-2.png 399w, https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/and-gate-truth-table-2-247x300.png 247w\" sizes=\"(max-width: 399px) 100vw, 399px\" \/><\/p>\n<h3>AND Gates<\/h3>\n<p>Boolean AND gates are one most common logic gates used in programming. The work by returning True, only if both inputs are true.<\/p>\n<h3>Truth Table<\/h3>\n<table style=\"border-collapse: collapse; width: 341px; height: 148px;\" border=\"0\" width=\"192\" cellspacing=\"0\" cellpadding=\"0\">\n<colgroup>\n<col style=\"width: 48pt;\" span=\"3\" width=\"64\" \/> <\/colgroup>\n<tbody>\n<tr style=\"height: 15.0pt;\">\n<th class=\"xl63\" style=\"height: 15pt; width: 48pt;\" width=\"64\" height=\"20\"><strong>Input A<\/strong><\/th>\n<th class=\"xl63\" style=\"width: 48pt;\" width=\"64\"><strong>Input B<\/strong><\/th>\n<th class=\"xl63\" style=\"width: 48pt;\" width=\"64\"><strong>Output<\/strong><\/th>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">FALSE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td align=\"center\">FALSE<\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">FALSE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td align=\"center\">FALSE<\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">TRUE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td align=\"center\">FALSE<\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15pt;\" align=\"center\" height=\"20\">TRUE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td align=\"center\">TRUE<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<\/div><div class=\"arconix-accordion-title accordion-PythonANDgates\"><i class=\"fa\"><\/i><p>Python AND gates<\/p><\/div><div class=\"arconix-accordion-content\">\n<h3>Python AND gates<\/h3>\n<p>In python we can use and gates easily within our programs(in fact you probably already have!).<\/p>\n<p><script src=\"https:\/\/gist.github.com\/richardbwest\/025f9428908a95bdd4502d28eeeeb4e5.js\"><\/script><\/p>\n<p>The example above is a pretty pointless example! Below are some more sensible uses of And gates&#8230;<\/p>\n<p><strong>Example &#8211; Password checker<\/strong><\/p>\n<p>In login systems both the username and password need to be correct in order for a user to be gained access.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/richardbwest\/27621222c65469b0c8ed5ca135d75bda.js\"><\/script><\/p>\n<\/div><div class=\"arconix-accordion-title accordion-PracticeActivities\"><i class=\"fa\"><\/i><p>Practice Activities<\/p><\/div><div class=\"arconix-accordion-content\">\n<p><strong>Practice 1<\/strong><\/p>\n<p>Write a python program that asks the users for..<\/p>\n<p><strong>Practice 2<\/strong><\/p>\n<p>Use comparison operators with and<\/p>\n<\/div><\/div>\n<\/div>\n<div class=\"arconix-pane pane-OR\"><div class=\"arconix-accordions arconix-accordions-vertical arconix-accordions-1\"><div class=\"arconix-accordion-title accordion-ORGates\"><i class=\"fa\"><\/i><p>OR Gates<\/p><\/div><div class=\"arconix-accordion-content\">\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignright size-full wp-image-572\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/or-gate-python.png\" alt=\"or gate python\" width=\"399\" height=\"485\" srcset=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/or-gate-python.png 399w, https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/or-gate-python-247x300.png 247w\" sizes=\"(max-width: 399px) 100vw, 399px\" \/><\/p>\n<h3>OR Gates<\/h3>\n<p>OR gates are another commonly used gate. They are less picky that AND gates &#8211; if either of the inputs is True (or both) then the gate will output True.<\/p>\n<h3>OR Gate Truth Table<\/h3>\n<table style=\"border-collapse: collapse; width: 404px; height: 140px;\" border=\"0\" width=\"192\" cellspacing=\"0\" cellpadding=\"0\">\n<colgroup>\n<col style=\"width: 48pt;\" span=\"3\" width=\"64\" \/> <\/colgroup>\n<tbody>\n<tr style=\"height: 15.0pt;\">\n<th class=\"xl65\" style=\"height: 15pt; width: 48pt;\" width=\"64\" height=\"20\"><strong>Input A<\/strong><\/th>\n<th class=\"xl65\" style=\"width: 48pt;\" width=\"64\"><strong>Input B<\/strong><\/th>\n<th class=\"xl65\" style=\"width: 48pt;\" width=\"64\"><strong>Output<\/strong><\/th>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">FALSE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td align=\"center\">FALSE<\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">FALSE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td align=\"center\">TRUE<\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">TRUE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td align=\"center\">TRUE<\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15pt;\" align=\"center\" height=\"20\">TRUE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td align=\"center\">TRUE<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<\/div><div class=\"arconix-accordion-title accordion-Pythonorgates\"><i class=\"fa\"><\/i><p>Python or gates<\/p><\/div><div class=\"arconix-accordion-content\">\n<p>Or gates are easy to use in Python. Here is a simple example.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/richardbwest\/712721125e475a7398126bd1183e04f2.js\"><\/script><br \/>\n <\/div><div class=\"arconix-accordion-title accordion-Practice\"><i class=\"fa\"><\/i><p>Practice<\/p><\/div><div class=\"arconix-accordion-content\">\n<h3>Practice 3<\/h3>\n<h3>Practice 4<\/h3>\n<\/div><\/div><br \/>\n <\/div>\n<div class=\"arconix-pane pane-NOT\"><div class=\"arconix-accordions arconix-accordions-vertical arconix-accordions-1\"><div class=\"arconix-accordion-title accordion-NOTGates\"><i class=\"fa\"><\/i><p>NOT Gates<\/p><\/div><div class=\"arconix-accordion-content\">\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignright size-full wp-image-574\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/not-gate.png\" alt=\"not gate\" width=\"399\" height=\"485\" srcset=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/not-gate.png 399w, https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/not-gate-247x300.png 247w\" sizes=\"(max-width: 399px) 100vw, 399px\" \/><\/p>\n<h3>Not Gates<\/h3>\n<p>Not gates are the simplest form of gate. It&#8217;s job is simply to reserve whatever input it is given.<\/p>\n<div class=\"arconix-list\" data-arconix-icon=\"fa-chevron-circle-right\" data-arconix-color=\"black\">\n<ul>\n<li>If the input is True, the output is False.<\/li>\n<li>If the input is False, the output is True.<\/li>\n<\/ul>\n<\/div>\n<h3>Not gate Truth Table<\/h3>\n<table style=\"border-collapse: collapse; width: 215px; height: 102px;\" border=\"0\" width=\"128\" cellspacing=\"0\" cellpadding=\"0\">\n<colgroup>\n<col style=\"width: 48pt;\" span=\"2\" width=\"64\" \/> <\/colgroup>\n<tbody>\n<tr style=\"height: 15.0pt;\">\n<th class=\"xl65\" style=\"height: 15pt; width: 48pt;\" width=\"64\" height=\"20\"><strong>Input A<\/strong><\/th>\n<th class=\"xl65\" style=\"width: 48pt;\" width=\"64\"><strong>Output<\/strong><\/th>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">FALSE<\/td>\n<td align=\"center\">TRUE<\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">TRUE<\/td>\n<td align=\"center\">FALSE<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<\/div><div class=\"arconix-accordion-title accordion-PythonNOTgates\"><i class=\"fa\"><\/i><p>Python NOT gates<\/p><\/div><div class=\"arconix-accordion-content\">\n<p>Not gates are commonly used in Python code. Here is a simple example:<\/p>\n<p><script src=\"https:\/\/gist.github.com\/richardbwest\/c302cd8b3c91cf60f57b2126efa4a970.js\"><\/script><\/p>\n<\/div><div class=\"arconix-accordion-title accordion-Practice3\"><i class=\"fa\"><\/i><p>Practice 3<\/p><\/div><div class=\"arconix-accordion-content\">\n<strong>Practice 5<\/strong><\/p>\n<p><strong>Practice 6<\/strong><\/p>\n<\/div><\/div><\/p>\n<\/div>\n<div class=\"arconix-pane pane-CombiningLogicGates\">\n<div class=\"arconix-accordions arconix-accordions-vertical arconix-accordions-1\"><div class=\"arconix-accordion-title accordion-CombiningLogicGates\"><i class=\"fa\"><\/i><p>Combining Logic Gates<\/p><\/div><div class=\"arconix-accordion-content\">\n<h3>Combining Logic Gates<\/h3>\n<h3><span style=\"color: #000080;\">Input 1 AND\u00a0( Input 2 OR Input 2)<\/span><\/h3>\n<p>As well as using Boolean Gates on their own you can also combine logic gates together. Order to work out how to solve combined logic gates you need to solve each of the left hand gates first, and then feed the outputs to the next gate along the line.<\/p>\n<\/div><div class=\"arconix-accordion-title accordion-Example1-NOTwithANDgate\"><i class=\"fa\"><\/i><p>Example 1 - NOT with AND gate<\/p><\/div><div class=\"arconix-accordion-content\">\n<h4>Example 1 \u00a0&#8211; NOT with AND gate (NAND gate)<\/h4>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-576 alignnone\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/NAND-gate.png\" alt=\"NAND gate\" width=\"501\" height=\"99\" srcset=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/NAND-gate.png 729w, https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/NAND-gate-300x59.png 300w\" sizes=\"(max-width: 501px) 100vw, 501px\" \/><\/p>\n<h3>Truth Table<\/h3>\n<p>Have a go at writing out the truth table for this combined gate.<\/p>\n<table style=\"border-collapse: collapse; width: 352px; height: 118px;\" border=\"0\" width=\"192\" cellspacing=\"0\" cellpadding=\"0\">\n<colgroup>\n<col style=\"width: 48pt;\" span=\"3\" width=\"64\" \/> <\/colgroup>\n<tbody>\n<tr style=\"height: 15.0pt;\">\n<th class=\"xl63\" style=\"height: 15pt; width: 48pt;\" width=\"64\" height=\"20\"><strong>Input 1<\/strong><\/th>\n<th class=\"xl63\" style=\"width: 48pt;\" width=\"64\"><strong>Input 2<\/strong><\/th>\n<th class=\"xl63\" style=\"width: 48pt; text-align: center;\" width=\"64\"><strong>Output<\/strong><\/th>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15pt;\" align=\"center\" height=\"20\">FALSE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td>??<\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">FALSE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td>??<\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15pt;\" align=\"center\" height=\"20\">TRUE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td>??<\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15pt;\" align=\"center\" height=\"20\">TRUE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td>??<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"arconix-toggle-wrap\"><div class=\"arconix-toggle-title toggle-closed\"><i class='fa fa-plus-square'><\/i>Answer<\/div><div class=\"arconix-toggle-content\">\n<table style=\"border-collapse: collapse; width: 345px; height: 118px;\" border=\"0\" width=\"192\" cellspacing=\"0\" cellpadding=\"0\">\n<colgroup>\n<col style=\"width: 48pt;\" span=\"3\" width=\"64\" \/> <\/colgroup>\n<tbody>\n<tr style=\"height: 15.0pt;\">\n<th class=\"xl65\" style=\"height: 15pt; width: 48pt;\" width=\"64\" height=\"20\"><strong>Input 1<\/strong><\/th>\n<th class=\"xl65\" style=\"width: 48pt;\" width=\"64\"><strong>Input 2<\/strong><\/th>\n<th class=\"xl65\" style=\"width: 48pt;\" width=\"64\"><strong>Output<\/strong><\/th>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">FALSE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td align=\"center\">TRUE<\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">FALSE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td align=\"center\">TRUE<\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">TRUE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td align=\"center\">TRUE<\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">TRUE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td align=\"center\">FALSE<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div><\/div>\n<\/div><div class=\"arconix-accordion-title accordion-Example2-CombinedORgates\"><i class=\"fa\"><\/i><p>Example 2 - Combined OR gates<\/p><\/div><div class=\"arconix-accordion-content\">\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-581\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/OR-OR-gate.png\" alt=\"OR OR gate\" width=\"570\" height=\"99\" srcset=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/OR-OR-gate.png 570w, https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/OR-OR-gate-300x52.png 300w\" sizes=\"(max-width: 570px) 100vw, 570px\" \/><\/p>\n<h3>Truth Table<\/h3>\n<p>Have a go at writing the truth table for this combined OR gate.<\/p>\n<table style=\"border-collapse: collapse; width: 384px; height: 211px;\" border=\"0\" width=\"256\" cellspacing=\"0\" cellpadding=\"0\">\n<colgroup>\n<col style=\"width: 48pt;\" span=\"4\" width=\"64\" \/> <\/colgroup>\n<tbody>\n<tr style=\"height: 15.0pt;\">\n<th class=\"xl65\" style=\"height: 15pt; width: 48pt;\" width=\"64\" height=\"20\"><strong>Input 1<\/strong><\/th>\n<th class=\"xl65\" style=\"width: 48pt;\" width=\"64\"><strong>Input 2<\/strong><\/th>\n<th class=\"xl65\" style=\"width: 48pt;\" width=\"64\"><strong>Input 3<\/strong><\/th>\n<th class=\"xl65\" style=\"width: 48pt;\" width=\"64\"><strong>Output<\/strong><\/th>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">FALSE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td><\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">FALSE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td><\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">FALSE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td><\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">FALSE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td><\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">TRUE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td><\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">TRUE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td><\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">TRUE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td><\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15pt;\" align=\"center\" height=\"20\">TRUE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"arconix-toggle-wrap\"><div class=\"arconix-toggle-title toggle-closed\"><i class='fa fa-plus-square'><\/i>Answer<\/div><div class=\"arconix-toggle-content\">\n<table style=\"border-collapse: collapse; width: 436px; height: 219px;\" border=\"0\" width=\"256\" cellspacing=\"0\" cellpadding=\"0\">\n<colgroup>\n<col style=\"width: 48pt;\" span=\"4\" width=\"64\" \/> <\/colgroup>\n<tbody>\n<tr style=\"height: 15.0pt;\">\n<th class=\"xl65\" style=\"height: 15pt; width: 48pt;\" width=\"64\" height=\"20\"><strong>Input 1<\/strong><\/th>\n<th class=\"xl65\" style=\"width: 48pt;\" width=\"64\"><strong>Input 2<\/strong><\/th>\n<th class=\"xl65\" style=\"width: 48pt;\" width=\"64\"><strong>Input 3<\/strong><\/th>\n<th class=\"xl65\" style=\"width: 48pt;\" width=\"64\"><strong>Output<\/strong><\/th>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">FALSE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td align=\"center\">FALSE<\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">FALSE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td align=\"center\">TRUE<\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">FALSE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td align=\"center\">TRUE<\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">FALSE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td align=\"center\">TRUE<\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">TRUE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td align=\"center\">TRUE<\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">TRUE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td align=\"center\">TRUE<\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15.0pt;\" align=\"center\" height=\"20\">TRUE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td align=\"center\">FALSE<\/td>\n<td align=\"center\">TRUE<\/td>\n<\/tr>\n<tr style=\"height: 15.0pt;\">\n<td style=\"height: 15pt;\" align=\"center\" height=\"20\">TRUE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td align=\"center\">TRUE<\/td>\n<td align=\"center\">TRUE<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div><\/div>\n<\/div><div class=\"arconix-accordion-title accordion-CombininggatesusingPython\"><i class=\"fa\"><\/i><p>Combining gates using Python<\/p><\/div><div class=\"arconix-accordion-content\">\n<h3>Combining gates in Python<\/h3>\n<p>If you ever need to combine logic gates in Python, the easiest way to do so is to use brackets. This makes writing and reading the gates much easier.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/anonymous\/5fec9020be4926a7fb1189345a6494d6.js\"><\/script><\/p>\n<p>In the example above an AND gate is added, with the output feeding in to a NOT gate.<\/p>\n<p>&nbsp;<\/p>\n<\/div><\/div>\n<\/div>\n<div class=\"arconix-pane pane-Practice\">\n<div class=\"arconix-accordions arconix-accordions-vertical arconix-accordions-1\"><div class=\"arconix-accordion-title accordion-Practice-PythonQuestions\"><i class=\"fa\"><\/i><p>Practice - Python Questions<\/p><\/div><div class=\"arconix-accordion-content\">\n<p>Take a look at these statements and work out whether they will output True or False!<\/p>\n<p><strong>Python Questions<\/strong><\/p>\n<ol>\n<li>True and True<\/li>\n<li>True and False<\/li>\n<li>True or True<\/li>\n<li>False or False<\/li>\n<li>False == True<\/li>\n<li>False != False<\/li>\n<li>not True<\/li>\n<li>(True and True) and True<\/li>\n<li>(True and False) and True<\/li>\n<li>(False or False) or True<\/li>\n<\/ol>\n<\/div><div class=\"arconix-accordion-title accordion-Practice-LogicSymbols\"><i class=\"fa\"><\/i><p>Practice - Logic Symbols<\/p><\/div><div class=\"arconix-accordion-content\">\n<p><strong>Logic Symbols<\/strong><\/p>\n<p><strong>11<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-588\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/qn1.png\" alt=\"qn1\" width=\"161\" height=\"67\" \/><\/p>\n<p><strong>12<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-589\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/qn2.png\" alt=\"qn2\" width=\"157\" height=\"63\" \/><\/p>\n<p><strong>13<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-590\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/qn3.png\" alt=\"qn3\" width=\"166\" height=\"67\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>14<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-591\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/qn4.png\" alt=\"qn4\" width=\"250\" height=\"72\" \/><\/p>\n<p><strong>15<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-592\" src=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/qn5.png\" alt=\"qn5\" width=\"356\" height=\"100\" srcset=\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/qn5.png 356w, https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/qn5-300x84.png 300w\" sizes=\"(max-width: 356px) 100vw, 356px\" \/><\/p>\n<\/div><\/div>\n<\/div>\n<div class=\"arconix-pane pane-Plenary\">\n<p>http:\/\/learnpythonthehardway.org\/book\/ex28.html<\/p>\n<\/div><\/div><\/div>\n\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Boolean Operators - Python<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/learnlearn.uk\/python\/boolean-operators\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Boolean Operators - Python\" \/>\n<meta property=\"og:url\" content=\"https:\/\/learnlearn.uk\/python\/boolean-operators\/\" \/>\n<meta property=\"og:site_name\" content=\"Python\" \/>\n<meta property=\"article:modified_time\" content=\"2016-07-21T18:01:42+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/knight-300x300.jpg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/learnlearn.uk\/python\/boolean-operators\/\",\"url\":\"https:\/\/learnlearn.uk\/python\/boolean-operators\/\",\"name\":\"Boolean Operators - Python\",\"isPartOf\":{\"@id\":\"https:\/\/learnlearn.uk\/python\/#website\"},\"datePublished\":\"2016-01-09T10:08:55+00:00\",\"dateModified\":\"2016-07-21T18:01:42+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/learnlearn.uk\/python\/boolean-operators\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/learnlearn.uk\/python\/boolean-operators\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/learnlearn.uk\/python\/boolean-operators\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Python Unit Home\",\"item\":\"https:\/\/learnlearn.uk\/python\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Boolean Operators\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/learnlearn.uk\/python\/#website\",\"url\":\"https:\/\/learnlearn.uk\/python\/\",\"name\":\"Python\",\"description\":\"Programming\",\"publisher\":{\"@id\":\"https:\/\/learnlearn.uk\/python\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/learnlearn.uk\/python\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/learnlearn.uk\/python\/#organization\",\"name\":\"Python\",\"url\":\"https:\/\/learnlearn.uk\/python\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/learnlearn.uk\/python\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2019\/03\/LearnLearnLogowhite.png\",\"contentUrl\":\"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2019\/03\/LearnLearnLogowhite.png\",\"width\":710,\"height\":98,\"caption\":\"Python\"},\"image\":{\"@id\":\"https:\/\/learnlearn.uk\/python\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Boolean Operators - Python","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/learnlearn.uk\/python\/boolean-operators\/","og_locale":"en_GB","og_type":"article","og_title":"Boolean Operators - Python","og_url":"https:\/\/learnlearn.uk\/python\/boolean-operators\/","og_site_name":"Python","article_modified_time":"2016-07-21T18:01:42+00:00","og_image":[{"url":"http:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2016\/01\/knight-300x300.jpg"}],"twitter_card":"summary_large_image","twitter_misc":{"Estimated reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/learnlearn.uk\/python\/boolean-operators\/","url":"https:\/\/learnlearn.uk\/python\/boolean-operators\/","name":"Boolean Operators - Python","isPartOf":{"@id":"https:\/\/learnlearn.uk\/python\/#website"},"datePublished":"2016-01-09T10:08:55+00:00","dateModified":"2016-07-21T18:01:42+00:00","breadcrumb":{"@id":"https:\/\/learnlearn.uk\/python\/boolean-operators\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/learnlearn.uk\/python\/boolean-operators\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/learnlearn.uk\/python\/boolean-operators\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Python Unit Home","item":"https:\/\/learnlearn.uk\/python\/"},{"@type":"ListItem","position":2,"name":"Boolean Operators"}]},{"@type":"WebSite","@id":"https:\/\/learnlearn.uk\/python\/#website","url":"https:\/\/learnlearn.uk\/python\/","name":"Python","description":"Programming","publisher":{"@id":"https:\/\/learnlearn.uk\/python\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/learnlearn.uk\/python\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/learnlearn.uk\/python\/#organization","name":"Python","url":"https:\/\/learnlearn.uk\/python\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/learnlearn.uk\/python\/#\/schema\/logo\/image\/","url":"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2019\/03\/LearnLearnLogowhite.png","contentUrl":"https:\/\/learnlearn.uk\/python\/wp-content\/uploads\/sites\/4\/2019\/03\/LearnLearnLogowhite.png","width":710,"height":98,"caption":"Python"},"image":{"@id":"https:\/\/learnlearn.uk\/python\/#\/schema\/logo\/image\/"}}]}},"rttpg_featured_image_url":null,"rttpg_author":{"display_name":"learnlearnadmin","author_link":"https:\/\/learnlearn.uk\/python\/author\/learnlearnadmin\/"},"rttpg_comment":0,"rttpg_category":null,"rttpg_excerpt":null,"_links":{"self":[{"href":"https:\/\/learnlearn.uk\/python\/wp-json\/wp\/v2\/pages\/249"}],"collection":[{"href":"https:\/\/learnlearn.uk\/python\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/learnlearn.uk\/python\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/learnlearn.uk\/python\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learnlearn.uk\/python\/wp-json\/wp\/v2\/comments?post=249"}],"version-history":[{"count":0,"href":"https:\/\/learnlearn.uk\/python\/wp-json\/wp\/v2\/pages\/249\/revisions"}],"wp:attachment":[{"href":"https:\/\/learnlearn.uk\/python\/wp-json\/wp\/v2\/media?parent=249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}