{"id":113459,"date":"2025-11-24T18:03:04","date_gmt":"2025-11-24T12:33:04","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/?page_id=113459"},"modified":"2025-11-24T17:30:57","modified_gmt":"2025-11-24T12:00:57","slug":"python-booleans","status":"publish","type":"page","link":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-booleans\/","title":{"rendered":"Python Booleans (True and False)"},"content":{"rendered":"\n<h1 id=\"python-booleans-true-and-false-values\">Python Booleans: True and False Values<\/h1>\n<h2 id=\"what-is-a-boolean-in-python\">What is a Boolean in Python?<\/h2>\n<p>\n    A Boolean is a data type that represents one of two possible values: <code>True<\/code> or <code>False<\/code>.\n<\/p>\n<p>\n    Booleans help your code make decisions. You can use them to create programs that do different things based on specific conditions. For example, you can check if a user is logged in before you show them a dashboard.\n<\/p>\n\n<h2 id=\"how-python-creates-boolean-values\">How Python Creates Boolean Values<\/h2>\n<p>\n    You usually get a Boolean value through a comparison. Comparison operators look at two values and return <code>True<\/code> if the statement is accurate, or <code>False<\/code> if it isn't. You don't normally type <code>True<\/code> or <code>False<\/code> directly - instead, Python evaluates an expression and gives you one of them.\n<\/p>\n\n<h3 id=\"example-simple-comparisons\">Example: Simple Comparisons<\/h3>\n<p>\n    See how Python evaluates these expressions by running the code below.\n<\/p>\n<div class=\"code-editor-container\">\n    <div id=\"editor-bool-basic\" class=\"python-code-editor\">\nprint(10 > 9)\nprint(10 == 9)\nprint(10 < 9)\n    <\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-bool-basic', 'output-bool-basic')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-bool-basic', this)\">Show Example<\/button>\n    <\/div>\n\n    <div id=\"solution-bool-basic\" class=\"code-solution\">\n        <pre><code>print(10 > 9)\nprint(10 == 9)\nprint(10 < 9)<\/code><\/pre>\n    <\/div>\n\n    <label for=\"output-bool-basic\" class=\"output-label\">Output:<\/label>\n    <pre id=\"output-bool-basic\" class=\"code-output\">Your output will appear here...<\/pre>\n<\/div>\n\n<h3 id=\"primary-comparison-operators\">Primary Comparison Operators<\/h3>\n<p>\n    Here is how to use the primary comparison operators in Python to get Booleans:\n<\/p>\n<ul>\n    <li><strong><code>==<\/code> (Equal to)<\/strong>: Checks if two values are equal. For example, <code>10 == 10<\/code> returns <code>True<\/code>.<\/li>\n    <li><strong><code>!=<\/code> (Not equal to)<\/strong>: Checks if two values are not equal. For example, <code>10 != 5<\/code> returns <code>True<\/code>.<\/li>\n    <li><strong><code>><\/code> (Greater than)<\/strong>: Checks if the value on the left is greater than the value on the right. For example, <code>10 > 5<\/code> returns <code>True<\/code>.<\/li>\n    <li><strong><code>&lt;<\/code> (Less than)<\/strong>: Checks if the value on the left is less than the value on the right. For example, <code>5 &lt; 10<\/code> returns <code>True<\/code>.<\/li>\n    <li><strong><code>>=<\/code> (Greater than or equal to)<\/strong>: Checks if the left value is greater than or equal to the right value. For example, <code>10 >= 10<\/code> returns <code>True<\/code>.<\/li>\n    <li><strong><code>&lt;=<\/code> (Less than or equal to)<\/strong>: Checks if the left value is less than or equal to the right value. For example, <code>5 &lt;= 10<\/code> returns <code>True<\/code>.<\/li>\n<\/ul>\n\n<h3 id=\"example\">Example:<\/h3>\n\n<div class=\"code-editor-container\">\n    <div id=\"editor-bool-vars\" class=\"python-code-editor\">\nuser_age = 25\nis_adult = user_age >= 18  \nprint(\"Is Adult:\", is_adult)\n\naccount_balance = 50\ncan_withdraw = account_balance > 100  \nprint(\"Can Withdraw:\", can_withdraw)\n    <\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-bool-vars', 'output-bool-vars')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-bool-vars', this)\">Show Example<\/button>\n    <\/div>\n\n    <div id=\"solution-bool-vars\" class=\"code-solution\">\n        <pre><code>user_age = 25\nis_adult = user_age >= 18  \nprint(is_adult)\n\naccount_balance = 50\ncan_withdraw = account_balance > 100  \nprint(can_withdraw)<\/code><\/pre>\n    <\/div>\n\n    <label for=\"output-bool-vars\" class=\"output-label\">Output:<\/label>\n    <pre id=\"output-bool-vars\" class=\"code-output\">Your output will appear here...<\/pre>\n<\/div>\n\n<h2 id=\"understanding-truthy-and-falsy-values\">Understanding 'Truthy' and 'Falsy' Values<\/h2>\n<p>\n    In Python, some values act like <code>False<\/code> even though they're not the Boolean value <code>False<\/code>. We call these \"falsy\" values. Everything else acts like <code>True<\/code>, and we call them \"truthy.\"\n<\/p>\n\n<h3 id=\"falsy-values\">Falsy Values<\/h3>\n<p>Python considers these values as <code>False<\/code>:<\/p>\n<ul>\n    <li>The special value <code>None<\/code><\/li>\n    <li>The Boolean value <code>False<\/code><\/li>\n    <li>The number zero: <code>0<\/code> and <code>0.0<\/code><\/li>\n    <li>Empty text: <code>\"\"<\/code><\/li>\n    <li>Empty lists: <code>[]<\/code><\/li>\n    <li>Empty dictionaries: <code>{}<\/code><\/li>\n<\/ul>\n\n<h3 id=\"truthy-values\">Truthy Values<\/h3>\n<p>Python considers any value that's not on the \"falsy\" list as <code>True<\/code>. Here are some examples:<\/p>\n<ul>\n    <li>Non-empty text like <code>\"hello\"<\/code><\/li>\n    <li>Any number except zero, like <code>1<\/code>, <code>-10<\/code>, or <code>0.5<\/code><\/li>\n    <li>Lists with items like <code>[1, 2]<\/code><\/li>\n    <li>The Boolean value <code>True<\/code><\/li>\n<\/ul>\n\n<h3 id=\"example-testing-truthy-and-falsy\">Example: Testing Truthy and Falsy<\/h3>\n<p>\n    You can test if a value is truthy or falsy using the <code>bool()<\/code> function.\n<\/p>\n<div class=\"code-editor-container\">\n    <div id=\"editor-truthy\" class=\"python-code-editor\">\nprint(bool(0))      \nprint(bool(15))     \nprint(bool(\"\"))     \nprint(bool(\"text\")) \nprint(bool([]))     \nprint(bool([1]))    \n    <\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-truthy', 'output-truthy')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-truthy', this)\">Show Example<\/button>\n    <\/div>\n\n    <div id=\"solution-truthy\" class=\"code-solution\">\n        <pre><code>print(bool(0))      # False\nprint(bool(15))     # True\nprint(bool(\"\"))     # False\nprint(bool(\"text\")) # True\nprint(bool([]))     # False\nprint(bool([1]))    # True<\/code><\/pre>\n    <\/div>\n\n    <label for=\"output-truthy\" class=\"output-label\">Output:<\/label>\n    <pre id=\"output-truthy\" class=\"code-output\">Your output will appear here...<\/pre>\n    \n<\/div>\n<div class=\"insight-box\">\n    <strong>Analysis:<\/strong> Look closely at the pattern in the output above.<br><br>\n\n    <ul>\n        <li>Notice that <strong>Zero<\/strong> (<code>0<\/code>), <strong>Empty text<\/strong> (<code>\"\"<\/code>), and <strong>Empty brackets<\/strong> (<code>[]<\/code>) all resulted in <code>False<\/code>.<\/li>\n\n        <li>Any variable containing real data (like <code>15<\/code> or <code>\"text\"<\/code>) resulted in <code>True<\/code>.<\/li>\n    <\/ul>\n\n    <p>\n        Python treats empty values as <code>False<\/code> because they represent \u201cno data.\u201d  \n        Non-empty values are considered <code>True<\/code> because they indicate useful or meaningful information.  \n        This behavior makes it easy to check whether a variable contains data without writing extra conditions.\n    <\/p>\n<\/div>\n\n\n<h2 id=\"how-functions-return-booleans\">How Functions Return Booleans<\/h2>\n<p>\n    You can create functions that return a Boolean value. This approach helps you write clean, reusable code that checks for specific conditions.\n<\/p>\n\n<div class=\"code-editor-container\">\n    <div id=\"editor-func\" class=\"python-code-editor\">\ndef is_of_legal_age(age):\n    return age >= 21\n\ncan_buy_alcohol = is_of_legal_age(25)\n\nif can_buy_alcohol:\n    print(\"Purchase approved.\")\nelse:\n    print(\"Purchase denied.\")\n    <\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-func', 'output-func')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-func', this)\">Show Example<\/button>\n    <\/div>\n\n    <div id=\"solution-func\" class=\"code-solution\">\n        <pre><code>def is_of_legal_age(age):\n    return age >= 21\n\ncan_buy_alcohol = is_of_legal_age(25)\n\nif can_buy_alcohol:\n    print(\"Purchase approved.\")\nelse:\n    print(\"Purchase denied.\")<\/code><\/pre>\n    <\/div>\n\n    <label for=\"output-func\" class=\"output-label\">Output:<\/label>\n    <pre id=\"output-func\" class=\"code-output\">Your output will appear here...<\/pre>\n<\/div>\n\n<h2 id=\"using-booleans-with-logical-operators\">Using Booleans with Logical Operators<\/h2>\n<p>\n    Logical operators (<code>and<\/code>, <code>or<\/code>, <code>not<\/code>) let you combine multiple Boolean expressions. You use them when you need to check more than one condition.\n<\/p>\n\n<h3 id=\"1-and-operator\">1. <code>and<\/code> Operator<\/h3>\n<p>\n    The <code>and<\/code> operator returns <code>True<\/code> only when both conditions are <code>True<\/code>. If either condition is <code>False<\/code>, the entire expression becomes <code>False<\/code>.\n<\/p>\n\n<h3 id=\"2-or-operator\">2. <code>or<\/code> Operator<\/h3>\n<p>\n    The <code>or<\/code> operator returns <code>True<\/code> when at least one of the conditions is <code>True<\/code>. It returns <code>False<\/code> only when both conditions are <code>False<\/code>.\n<\/p>\n\n<h3 id=\"3-not-operator\">3. <code>not<\/code> Operator<\/h3>\n<p>\n    The <code>not<\/code> operator flips a Boolean value. It turns <code>True<\/code> into <code>False<\/code> and <code>False<\/code> into <code>True<\/code>.\n<\/p>\n\n<h3 id=\"example-logical-operators-in-action\">Example: Logical Operators in Action<\/h3>\n<div class=\"code-editor-container\">\n    <div id=\"editor-logical\" class=\"python-code-editor\">\n# AND Example\nage = 22\nhas_license = True\ncan_drive = age >= 18 and has_license\nprint(\"Can Drive:\", can_drive)\n\n# OR Example\nis_weekend = True\nis_holiday = False\ncan_rest = is_weekend or is_holiday\nprint(\"Can Rest:\", can_rest)\n\n# NOT Example\nis_raining = False\ngo_outside = not is_raining\nprint(\"Go Outside:\", go_outside)\n    <\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-logical', 'output-logical')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-logical', this)\">Show Example<\/button>\n    <\/div>\n\n    <div id=\"solution-logical\" class=\"code-solution\">\n        <pre><code># AND\nprint(22 >= 18 and True)\n\n# OR\nprint(True or False)\n\n# NOT\nprint(not False)<\/code><\/pre>\n    <\/div>\n\n    <label for=\"output-logical\" class=\"output-label\">Output:<\/label>\n    <pre id=\"output-logical\" class=\"code-output\">Your output will appear here...<\/pre>\n<\/div>\n\n<h2 id=\"common-mistakes-to-avoid\">Common Mistakes to Avoid<\/h2>\n<p>\n    You can write cleaner and more reliable code when you avoid these common mistakes with Booleans:\n<\/p>\n<ul>\n    <li><strong>Confusing assignment (<code>=<\/code>) with comparison (<code>==<\/code>)<\/strong>: The single equals sign assigns a value. The double equals sign checks for equality. When you use <code>=<\/code> instead of <code>==<\/code> in a comparison, you create bugs.<\/li>\n    <li><strong>Forgetting to capitalize <code>True<\/code> and <code>False<\/code><\/strong>: Python's Boolean keywords are case-sensitive. When you use <code>true<\/code> or <code>false<\/code>, Python raises a <code>NameError<\/code>.<\/li>\n<\/ul>\n\n<h2 id=\"final-challenge-discount-eligibility\">Final Challenge: Discount Eligibility<\/h2>\n<p>\n    Apply your logic skills! Write a check to see if a customer gets a discount.\n<\/p>\n<p>Your Task:<\/p>\n<ol>\n    <li>A customer is eligible for a discount if they are a <strong>student<\/strong> OR if they are a <strong>senior<\/strong> (over 60).<\/li>\n    <li>Use logical operators to calculate the Boolean result.<\/li>\n<\/ol>\n\n<div class=\"code-editor-container\">\n    <div id=\"editor-final\" class=\"python-code-editor\">\nis_student = False\nage = 65\n\n# TODO: Check if eligible for discount (student OR age > 60)\n# has_discount = ...\n\n# print(has_discount)\n    <\/div>\n    <div class=\"button-container\">\n        <button class=\"button button-run\" onclick=\"runPythonCode('editor-final', 'output-final')\">Run Code<\/button>\n        <button class=\"button button-toggle\" onclick=\"toggleSolution('solution-final', this)\">Show Solution<\/button>\n    <\/div>\n\n    <div id=\"solution-final\" class=\"code-solution\">\n        <pre><code>is_student = False\nage = 65\n\nhas_discount = is_student or age > 60\n\nprint(has_discount)<\/code><\/pre>\n    <\/div>\n\n    <label for=\"output-final\" class=\"output-label\">Output:<\/label>\n    <pre id=\"output-final\" class=\"code-output\">Your output will appear here...<\/pre>\n<\/div>\n\n<div class=\"cta-final\">\n    <div class=\"cta-final-header\">\n        <span class=\"cta-final-trophy\">\ud83c\udfc6<\/span>\n        <h2 id=\"lesson-completed\">Lesson Completed<\/h2>\n    <\/div>\n\n    <p class=\"cta-final-intro\">\n        You have successfully learned about Python Booleans, and how to control program logic using True and False values.\n    <\/p>\n\n    <div class=\"cta-final-grid\">\n        <div class=\"cta-final-option\">\n            <div class=\"cta-final-option-header\">\n                <span>\ud83d\udcd8<\/span>\n                <h4 id=\"full-python-course\">Full Python Course<\/h4>\n            <\/div>\n            <p>Master Python with 11+ hours of content, 50+ exercises, and real-world projects.<\/p>\n            <a href=\"https:\/\/www.mygreatlearning.com\/academy\/premium\/master-python-programming?utm_source=blog\" class=\"cta-final-button-primary\">Enroll Now<\/a>\n        <\/div>\n\n        <div class=\"cta-final-option\" id=\"pt-next-lesson-container\">\n            <div class=\"cta-final-option-header\">\n                <span>\ud83d\udcdd<\/span>\n                <h4 id=\"next-lesson\">Next Lesson<\/h4>\n            <\/div>\n            <p id=\"pt-next-lesson-text\">Continue with the next lesson on Python Operators.<\/p>\n            <a href=\"#\" id=\"pt-next-lesson-button\" class=\"cta-final-button-secondary\">Next Lesson -><\/a>\n        <\/div>\n    <\/div>\n<\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn and practice Python Booleans with code examples. Understand True\/False values, comparison operators, logical operations, and common mistakes with hands-on exercises.<\/p>\n","protected":false},"author":41,"featured_media":113476,"parent":113156,"menu_order":11,"comment_status":"closed","ping_status":"closed","template":"templates\/python-tutorial.php","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25860],"tags":[36796,36893],"class_list":["post-113459","page","type-page","status-publish","has-post-thumbnail","hentry","category-software","tag-python","tag-python-tutorial"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Python Booleans (True and False)<\/title>\n<meta name=\"description\" content=\"Learn and practice Python Booleans with code examples. Understand True\/False values, comparison operators, logical operations, and common mistakes with hands-on exercises.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mygreatlearning.com\/blog\/python\/python-booleans\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Booleans (True and False)\" \/>\n<meta property=\"og:description\" content=\"Learn and practice Python Booleans with code examples. Understand True\/False values, comparison operators, logical operations, and common mistakes with hands-on exercises.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/python\/python-booleans\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-booleans.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1408\" \/>\n\t<meta property=\"og:image:height\" content=\"768\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Est. 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\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-booleans\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-booleans\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"Python Booleans (True and False)\",\"datePublished\":\"2025-11-24T12:33:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-booleans\\\/\"},\"wordCount\":865,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-booleans\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/11\\\/python-booleans.webp\",\"keywords\":[\"python\",\"python-tutorial\"],\"articleSection\":[\"IT\\\/Software Development\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-booleans\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-booleans\\\/\",\"name\":\"Python Booleans (True and False)\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-booleans\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-booleans\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/11\\\/python-booleans.webp\",\"datePublished\":\"2025-11-24T12:33:04+00:00\",\"description\":\"Learn and practice Python Booleans with code examples. Understand True\\\/False values, comparison operators, logical operations, and common mistakes with hands-on exercises.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-booleans\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-booleans\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-booleans\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/11\\\/python-booleans.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/11\\\/python-booleans.webp\",\"width\":1408,\"height\":768,\"caption\":\"Python Booleans\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/python-booleans\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Tutorial\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/python\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Python Booleans (True and False)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python Booleans (True and False)","description":"Learn and practice Python Booleans with code examples. Understand True\/False values, comparison operators, logical operations, and common mistakes with hands-on exercises.","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:\/\/www.mygreatlearning.com\/blog\/python\/python-booleans\/","og_locale":"en_US","og_type":"article","og_title":"Python Booleans (True and False)","og_description":"Learn and practice Python Booleans with code examples. Understand True\/False values, comparison operators, logical operations, and common mistakes with hands-on exercises.","og_url":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-booleans\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","og_image":[{"width":1408,"height":768,"url":"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-booleans.webp","type":"image\/webp"}],"twitter_card":"summary_large_image","twitter_site":"@Great_Learning","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-booleans\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-booleans\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"Python Booleans (True and False)","datePublished":"2025-11-24T12:33:04+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-booleans\/"},"wordCount":865,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-booleans\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-booleans.webp","keywords":["python","python-tutorial"],"articleSection":["IT\/Software Development"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-booleans\/","url":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-booleans\/","name":"Python Booleans (True and False)","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-booleans\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-booleans\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-booleans.webp","datePublished":"2025-11-24T12:33:04+00:00","description":"Learn and practice Python Booleans with code examples. Understand True\/False values, comparison operators, logical operations, and common mistakes with hands-on exercises.","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-booleans\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/python\/python-booleans\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-booleans\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-booleans.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-booleans.webp","width":1408,"height":768,"caption":"Python Booleans"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/python\/python-booleans\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Python Tutorial","item":"https:\/\/www.mygreatlearning.com\/blog\/python\/"},{"@type":"ListItem","position":3,"name":"Python Booleans (True and False)"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-booleans.webp",1408,768,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-booleans-150x150.webp",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-booleans-300x164.webp",300,164,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-booleans-768x419.webp",768,419,true],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-booleans-1024x559.webp",1024,559,true],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-booleans.webp",1408,768,false],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-booleans.webp",1408,768,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-booleans-640x768.webp",640,768,true],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-booleans-96x96.webp",96,96,true],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2025\/11\/python-booleans-150x82.webp",150,82,true]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":0,"uagb_excerpt":"Learn and practice Python Booleans with code examples. Understand True\/False values, comparison operators, logical operations, and common mistakes with hands-on exercises.","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/113459","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=113459"}],"version-history":[{"count":21,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/113459\/revisions"}],"predecessor-version":[{"id":114081,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/113459\/revisions\/114081"}],"up":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/pages\/113156"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/113476"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=113459"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=113459"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=113459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}