{"id":737,"date":"2021-04-29T12:07:21","date_gmt":"2021-04-29T06:37:21","guid":{"rendered":"https:\/\/cbsepython.in\/?p=737"},"modified":"2025-04-26T14:33:34","modified_gmt":"2025-04-26T09:03:34","slug":"decision-making-in-python","status":"publish","type":"post","link":"https:\/\/cbsepython.in\/decision-making-in-python\/","title":{"rendered":"Decision Making in Python"},"content":{"rendered":"<h1><strong>Decision Making in Python for Beginners (CBSE Class 11-12)<\/strong><\/h1>\n<h2><strong>Introduction to Decision Making in Python<\/strong><\/h2>\n<p>Welcome, CBSE Class 11-12 students! Decision making in Python is like giving your computer a brain to make choices. It\u2019s about telling Python, \u201cBhai, agar yeh condition true hai, toh yeh kar, nahi toh woh kar!\u201d This is a key topic for your CBSE exams and helps you write smart programs. Let\u2019s learn it step-by-step!<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Why Learn This? :<\/strong> Used in games, apps, and projects\u2014like checking if a student passed or failed.<\/p>\n<p><strong>Keywords to Remember<\/strong>: If statement, if-else, elif, nested if, Python for CBSE.<\/p>\n<p>&nbsp;<\/p>\n<h3><strong>1. If Statement in Python for Beginners<\/strong><\/h3>\n<p><strong>What is It?<\/strong>: The if statement checks a condition. If it\u2019s true, the code inside runs. Think of it as \u201cagar\u201d in Hindi!<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">if condition:\r\n    # Code to run if true<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">age = 18\r\n\r\nif age &gt;= 18:\r\n    \r\n    print(\"You can vote in elections!<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p>You can vote in elections!<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Tip:<\/strong> Always use a colon : and indent the code (4 spaces).<\/p>\n<p>&nbsp;<\/p>\n<p><strong>2. If-Else Statement for CBSE Class 10<\/strong><\/p>\n<p><strong>What is It?:<\/strong> Adds an \u201celse\u201d part. If the condition is false, else code runs. It\u2019s like \u201cagar nahi toh\u201d!<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">if condition:\r\n    \r\n    # Code if true\r\n\r\nelse:\r\n    \r\n    # Code if false<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">marks = 35\r\n\r\nif marks &gt;= 40:\r\n    \r\n    print(\"Pass your CBSE exam!\")\r\n\r\nelse:\r\n    \r\n    print(\"Sorry, try again next time!\")<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p>Sorry, try again next time!<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Real-Life Example:<\/strong> If it\u2019s hot (&gt;30\u00b0C), print \u201cDrink water!\u201d else print \u201cWeather is cool!\u201d<\/p>\n<p>&nbsp;<\/p>\n<p><strong>3. Elif Statement in Python for CBSE Class 11-12<\/strong><\/p>\n<p><strong>What is It?:<\/strong> Short for \u201celse if,\u201d it checks multiple conditions one by one. Perfect for grading systems!<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">if condition1:\r\n    \r\n    # Code if true\r\n\r\nelif condition2:\r\n    \r\n    # Code if true\r\n\r\nelse:\r\n    \r\n    # Code if all false<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">score = 85\r\n\r\nif score &gt;= 90:\r\n    \r\n    print(\"A+ Grade in CBSE!\")\r\n\r\nelif score &gt;= 70:\r\n    \r\n    print(\"A Grade\u2014Well done!\")\r\n\r\nelse:\r\n    \r\n    print(\"B Grade\u2014Keep practicing!\")<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p>A Grade\u2014Well done!<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Tip:<\/strong> Use \u201celif\u201d when you have more than two options, like marks or weather levels.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>4. Nested If Statement for CBSE Class 11-12<\/strong><\/p>\n<p><strong>What is It?:<\/strong> An \u201cif\u201d inside another \u201cif\u201d to check more conditions. It\u2019s like a decision inside a decision!<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">if condition1:\r\n    \r\n    if condition2:\r\n        \r\n        # Code if both true<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">age = 20\r\n\r\nif age &gt;= 18:\r\n    \r\n    if age &lt;= 25:\r\n        \r\n        print(\"You are a young voter!\")\r\n   \r\n    else:\r\n        \r\n        print(\"Age not in range!\")<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p>You are a young voter!<\/p>\n<p><strong>Real-Life Example:<\/strong> If it\u2019s a holiday and weather is good, print \u201cGo for a picnic!\u201d<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Exercises for Python Decision Making (CBSE Practice)<\/strong><\/p>\n<p><strong>Question 1:<\/strong> Write a program to check if a number is positive. If yes, print \u201cPositive!\u201d else print \u201cNegative!\u201d<\/p>\n<p><strong>Question 2:<\/strong> Create a program to check attendance. If &gt;75%, print \u201cEligible for exams!\u201d else print \u201cAttend more classes!\u201d<\/p>\n<p><strong>Question 3:<\/strong> Make a weather program. If temperature &gt;30, print \u201cHot day!\u201d elif 20-30, print \u201cPleasant!\u201d else print \u201cCold!\u201d<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Solution (Try First!):<\/strong><\/p>\n<p><strong>Question 1<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"># Question 1\r\n\r\nnum = 5\r\n\r\nif num &gt; 0:\r\n    \r\n    print(\"Positive!\")\r\n\r\nelse:\r\n    \r\n    print(\"Negative!\")\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>\u00a0 <\/strong><strong>Question 2<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"># Question 2\r\n\r\nattendance = 80\r\n\r\nif attendance &gt; 75:\r\n    \r\n    print(\"Eligible for exams!\")\r\n\r\nelse:\r\n    \r\n    print(\"Attend more classes!\")\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Question 3<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"> # Question 3\r\n\r\ntemp = 25\r\n\r\nif temp &gt; 30:\r\n    \r\n    print(\"Hot day!\")\r\n\r\nelif temp &gt;= 20:\r\n    \r\n    print(\"Pleasant!\")\r\n\r\nelse:\r\n    \r\n    print(\"Cold!\")<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>CBSE Exam Tips:<\/strong><\/p>\n<p>Focus on if and if-else\u2014simple programs like age or marks check.<\/p>\n<p>Practice elif and nested if for complex problems (e.g., grading or eligibility).<\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p><strong>Common Mistakes: <\/strong><\/p>\n<p>Forget colon : after if.<\/p>\n<p>Wrong indentation\u2014use 4 spaces.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Frequently Asked Questions (FAQ)<\/strong><\/p>\n<p><strong>What is an if statement in Python?<\/strong><\/p>\n<p>It\u2019s a way to run code only if a condition is true.<\/p>\n<p><strong>How to use if-else in CBSE projects? <\/strong><\/p>\n<p>Use it to handle two outcomes, like pass\/fail.<\/p>\n<p><strong>Why nested if is hard? <\/strong><\/p>\n<p>It has multiple levels\u2014start with simple ones!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Decision Making in Python for Beginners (CBSE Class 11-12) Introduction to Decision Making in Python Welcome, CBSE Class 11-12 students! Decision making in Python is like giving your computer a brain to make choices. It\u2019s about telling Python, \u201cBhai, agar yeh condition true hai, toh yeh kar, nahi toh woh kar!\u201d This is a key [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-737","post","type-post","status-publish","format-standard","hentry","category-cbse-computer-science-with-python-class-12"],"_links":{"self":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/posts\/737","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/comments?post=737"}],"version-history":[{"count":0,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/posts\/737\/revisions"}],"wp:attachment":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/media?parent=737"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/categories?post=737"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/tags?post=737"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}