{"id":47,"date":"2026-02-28T13:37:17","date_gmt":"2026-02-28T08:37:17","guid":{"rendered":"https:\/\/gigz.pk\/python\/?post_type=lesson&#038;p=47"},"modified":"2026-03-12T11:39:50","modified_gmt":"2026-03-12T06:39:50","slug":"boolean-data-type","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/python\/lesson\/boolean-data-type\/","title":{"rendered":"Boolean Data Type"},"content":{"rendered":"\n<p>The Boolean data type is one of the basic and important data types in Python. It is used to represent one of two possible values: True or False. These two values are mainly used in decision making and logical operations within a program.<\/p>\n\n\n\n<p>Boolean values help programs make decisions, control the flow of execution, and perform comparisons.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>WHAT IS A BOOLEAN VALUE<\/strong><\/h1>\n\n\n\n<p>A Boolean value can only be:<\/p>\n\n\n\n<p>True<br>False<\/p>\n\n\n\n<p>In Python, both True and False must start with a capital letter. Writing true or false in lowercase will cause an error.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<p>is_active = True<br>is_logged_in = False<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>BOOLEAN IN COMPARISON OPERATIONS<\/strong><\/h1>\n\n\n\n<p>Boolean values are commonly created using comparison operators. When you compare two values, Python returns either True or False.<\/p>\n\n\n\n<p>Examples:<\/p>\n\n\n\n<p>print(5 &gt; 3)<br>Output will be True<\/p>\n\n\n\n<p>print(10 == 5)<br>Output will be False<\/p>\n\n\n\n<p>Common comparison operators:<\/p>\n\n\n\n<p>Greater than &gt;<br>Less than &lt;<br>Equal to ==<br>Not equal to !=<br>Greater than or equal to &gt;=<br>Less than or equal to &lt;=<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>BOOLEAN IN CONDITIONAL STATEMENTS<\/strong><\/h1>\n\n\n\n<p>Boolean values are mainly used in decision making statements such as if conditions.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<p>age = 18<\/p>\n\n\n\n<p>if age &gt;= 18:<br>print(&#8220;You are eligible to vote&#8221;)<\/p>\n\n\n\n<p>If the condition is True, the code inside the block will run.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>BOOLEAN WITH LOGICAL OPERATORS<\/strong><\/h1>\n\n\n\n<p>Python also provides logical operators to combine conditions.<\/p>\n\n\n\n<p>and returns True if both conditions are True<br>or returns True if at least one condition is True<br>not reverses the Boolean value<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<p>print(5 &gt; 3 and 10 &gt; 5)<br>Output will be True<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>BOOLEAN USING bool FUNCTION<\/strong><\/h1>\n\n\n\n<p>You can convert values into Boolean using the bool() function.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<p>print(bool(1))<br>Output will be True<\/p>\n\n\n\n<p>print(bool(0))<br>Output will be False<\/p>\n\n\n\n<p>In Python, empty values such as 0, empty string, or empty list are considered False. Most other values are considered True.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>WHY BOOLEAN IS IMPORTANT<\/strong><\/h1>\n\n\n\n<p>The Boolean data type is essential for controlling program logic. It allows your program to make decisions, repeat actions, and validate conditions.<\/p>\n\n\n\n<p>Understanding Boolean values is a key step in learning conditional statements, loops, and building intelligent Python applications.<\/p>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1773297690772\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/python\/\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">PYTHON FUNDAMENTALS (PYF) > Variables and Data Types > Boolean Data Type<\/span><\/span><\/div>","protected":false},"menu_order":9,"template":"","class_list":["post-47","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Boolean Data Type - One Language. Endless Possibilities<\/title>\n<meta name=\"description\" content=\"Learn Python Boolean data type: True, False, logical operators, comparisons, and how to control program flow effectively.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/python\/lesson\/boolean-data-type\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Boolean Data Type - One Language. Endless Possibilities\" \/>\n<meta property=\"og:description\" content=\"Learn Python Boolean data type: True, False, logical operators, comparisons, and how to control program flow effectively.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/python\/lesson\/boolean-data-type\/\" \/>\n<meta property=\"og:site_name\" content=\"One Language. Endless Possibilities\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-12T06:39:50+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/boolean-data-type\\\/\",\"url\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/boolean-data-type\\\/\",\"name\":\"Boolean Data Type - One Language. Endless Possibilities\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/#website\"},\"datePublished\":\"2026-02-28T08:37:17+00:00\",\"dateModified\":\"2026-03-12T06:39:50+00:00\",\"description\":\"Learn Python Boolean data type: True, False, logical operators, comparisons, and how to control program flow effectively.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/boolean-data-type\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/boolean-data-type\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/boolean-data-type\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/python\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PYTHON FUNDAMENTALS (PYF) > Variables and Data Types > Boolean Data Type\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/python\\\/\",\"name\":\"One Language. Endless Possibilities\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/python\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Boolean Data Type - One Language. Endless Possibilities","description":"Learn Python Boolean data type: True, False, logical operators, comparisons, and how to control program flow effectively.","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:\/\/gigz.pk\/python\/lesson\/boolean-data-type\/","og_locale":"en_US","og_type":"article","og_title":"Boolean Data Type - One Language. Endless Possibilities","og_description":"Learn Python Boolean data type: True, False, logical operators, comparisons, and how to control program flow effectively.","og_url":"https:\/\/gigz.pk\/python\/lesson\/boolean-data-type\/","og_site_name":"One Language. Endless Possibilities","article_modified_time":"2026-03-12T06:39:50+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/python\/lesson\/boolean-data-type\/","url":"https:\/\/gigz.pk\/python\/lesson\/boolean-data-type\/","name":"Boolean Data Type - One Language. Endless Possibilities","isPartOf":{"@id":"https:\/\/gigz.pk\/python\/#website"},"datePublished":"2026-02-28T08:37:17+00:00","dateModified":"2026-03-12T06:39:50+00:00","description":"Learn Python Boolean data type: True, False, logical operators, comparisons, and how to control program flow effectively.","breadcrumb":{"@id":"https:\/\/gigz.pk\/python\/lesson\/boolean-data-type\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/python\/lesson\/boolean-data-type\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/python\/lesson\/boolean-data-type\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/python\/"},{"@type":"ListItem","position":2,"name":"PYTHON FUNDAMENTALS (PYF) > Variables and Data Types > Boolean Data Type"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/python\/#website","url":"https:\/\/gigz.pk\/python\/","name":"One Language. Endless Possibilities","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/python\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/lesson\/47","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/media?parent=47"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}