{"id":11148,"date":"2022-12-20T10:20:56","date_gmt":"2022-12-20T10:20:56","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=11148"},"modified":"2023-04-18T13:10:01","modified_gmt":"2023-04-18T13:10:01","slug":"menu-driven-program-in-python","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/","title":{"rendered":"Menu Driven Program in Python"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671519245920-Menu%20Driven%20Program%20in%20Python.jpg\" alt=\"\" \/><\/p>\n<p>Menu Driven Programs are designed to increase the level of user interaction within the program. Such programs receive user input and provide an output based on the selected input. In this article, we will be exploring Menu Driven Programs implemented in Python.<\/p>\n<h2>Menu Driven Program in Python<\/h2>\n<p>A menu-driven program in Python is a program that operates through a menu presented to the user, allowing them to choose from a list of options. These menus are commonly seen in devices that have microprocessors, such as washing machines and ATMs.<\/p>\n<p>The usage of a menu-driven system provides two advantages. Firstly, input is reduced to a single keystroke, which decreases the likelihood of mistakes. Secondly, the system restricts the input characters, making them more clear and unambiguous. As a result, it results in an intuitive and user-friendly interface.<\/p>\n<p>So, let\u2019s get started by learning the conditional statements first.<\/p>\n<h2>Understanding the Conditional Statements in Python<\/h2>\n<p>Conditional statements are statements that are used to impose some conditions on code execution. Basically, a python program runs from top to bottom and left to write (in the order in which the code is written). However, sometimes it might happen that we want to run a piece of code only if a certain condition is met. This is where conditional statements come into the picture. Consider the following example given below.<\/p>\n<h3>Even-Odd &#8211; If Else Program in Python<\/h3>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_11130 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_11130 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_11130 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_11130 .wpsm_nav-tabs > li.active > a, #tab_container_11130 .wpsm_nav-tabs > li.active > a:hover, #tab_container_11130 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_11130 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_11130 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_11130 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_11130 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_11130 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_11130 .wpsm_nav-tabs > li > a:hover , #tab_container_11130 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_11130 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_11130 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_11130 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_11130 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_11130 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_11130 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_11130 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_11130 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_11130 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_11130 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_11130 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_11130\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_11130\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_11130_1\" aria-controls=\"tabs_desc_11130_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>Python<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_11130\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_11130_1\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"python\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-eanlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\nnum = int(input())\r\nif num%2==0:\r\n    print(&quot;Even&quot;)\r\nelse:\r\n    print(&quot;Odd&quot;)\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_11130 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_11130 a\"),jQuery(\"#tab-content_11130\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p><strong>Input:<\/strong><\/p>\n<pre><code>4<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>Even<\/code><\/pre>\n<p><strong>Explanation:<\/strong> The code above determines whether a number is an even number or an odd number. We take input from the user and if the number is divisible by 2 i.e. on dividing by 2 it leaves the remainder 0 (or number % 2 =0), then this number is even. Otherwise, the number will be odd. So, we take the input and apply the conditional statements <strong>\u201cif-else\u201d<\/strong> as shown. The piece of code written under the if suite only executes if the condition (number % 2 == 0) is true, else the condition in the \u201celse\u201d suite will execute.<\/p>\n<p>We can extend this concept to multiple conditions as well. For instance, let us say that we want to determine whether a number is positive, negative, or 0. So, we can do it as shown in the code below.<\/p>\n<h3>Positive, Negative, or Zero &#8211; If Elif Else<\/h3>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_11131 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_11131 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_11131 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_11131 .wpsm_nav-tabs > li.active > a, #tab_container_11131 .wpsm_nav-tabs > li.active > a:hover, #tab_container_11131 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_11131 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_11131 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_11131 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_11131 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_11131 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_11131 .wpsm_nav-tabs > li > a:hover , #tab_container_11131 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_11131 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_11131 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_11131 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_11131 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_11131 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_11131 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_11131 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_11131 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_11131 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_11131 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_11131 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_11131\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_11131\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_11131_1\" aria-controls=\"tabs_desc_11131_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>Python<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_11131\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_11131_1\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"python\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-eanlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\nn = int(input())\r\nif n &lt; 0:\r\n    print(&quot;Negative&quot;)\r\nelif n==0:\r\n    print(&quot;The number is 0&quot;)\r\nelse:\r\n    print(&quot;Positive&quot;)\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_11131 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_11131 a\"),jQuery(\"#tab-content_11131\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p><strong>Input:<\/strong><\/p>\n<pre><code>-3<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code>Negative<\/code><\/pre>\n<p><strong>Explanation:<\/strong> We have taken a number as input and we have applied conditions. The code under the \u201cif\u201d suite will execute only if the number is negative i.e. number &lt; 0 and the code under \u201celif\u201d suite will only execute if the number is 0 and the code under the \u201celse\u201d suite executes in all other conditions. Since there is only one possible condition other than the 2 mentioned above i.e. a number can only be positive if it is not negative or 0, so, we can say that the code under the \u201celse\u201d suite executes if the number is positive.<\/p>\n<p>So, this is the if-elif-else. In Python, we don\u2019t have switch-case statements. So, a Menu driven program in Python can only be created using the if-elif-else only. So, let us now create a Menu driven program in Python.<\/p>\n<h2>Example of Menu-driven Program in Python<\/h2>\n<p>Consider the following situation. We at PrepBytes, have a university called PrepBytes University. So, we are creating a Menu driven program in Python for students who are willing to take admitted to our University. They will see 5 options. These options are the branches available in our University. They can select one among the 5 branches of Engineering. Once they select a branch from the menu, they will be displayed the subjects taught in that branch and they will have to confirm their selection. If they confirm, they will be enrolled in the University, else, they will again get a chance to select from the available branches. The menu will be provided to them until they either select a branch and confirm it, or they exit the program by entering the choice to exit the program.<\/p>\n<p>The Menu driven program in Python to implement the above logic is shown below.<\/p>\n<h2>Code for Menu driven Program in Python \u2013 PrepBytes University<\/h2>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_11132 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_11132 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_11132 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_11132 .wpsm_nav-tabs > li.active > a, #tab_container_11132 .wpsm_nav-tabs > li.active > a:hover, #tab_container_11132 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_11132 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_11132 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_11132 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_11132 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_11132 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_11132 .wpsm_nav-tabs > li > a:hover , #tab_container_11132 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_11132 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_11132 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_11132 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_11132 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_11132 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_11132 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_11132 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_11132 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_11132 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_11132 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_11132 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_11132\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_11132\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_11132_1\" aria-controls=\"tabs_desc_11132_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>Python<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_11132\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_11132_1\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"python\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-eanlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\ndef cse():\r\n    print(&quot;You will get the following subjects&quot;)\r\n    print(&quot;DSA&quot;)\r\n    print(&quot;DBMS&quot;)\r\n    print(&quot;Computer Networks (CN)&quot;)\r\ndef it():\r\n    print(&quot;You will get the following subjects&quot;)\r\n    print(&quot;DSA&quot;)\r\n    print(&quot;DBMS&quot;)\r\n    print(&quot;Computer Networks (CN)&quot;)\r\n    print(&quot;MPMC (Multi processor and Multi Controller)&quot;)\r\n    print(&quot;Information Security&quot;)\r\ndef ece():\r\n    print(&quot;You will get the following subjects&quot;)\r\n    print(&quot;Wireless Communication&quot;)\r\n    print(&quot;Switching Theory and Logic Design (STLD)&quot;)\r\n    print(&quot;Mobile Systems Communication&quot;)\r\ndef ee():\r\n    print(&quot;You will get the following subjects&quot;)\r\n    print(&quot;Switching Theory and Logic Design (STLD)&quot;)\r\n    print(&quot;Control Systems&quot;)\r\n    print(&quot;Electrical Circuits and Designs&quot;)\r\ndef mech():\r\n    print(&quot;You will get the following subjects&quot;)\r\n    print(&quot;Force and Friction&quot;)\r\n    print(&quot;Motors and its Types&quot;)\r\ndef main():\r\n    print(&quot;Welcome to PrepBytes University Portal!!!&quot;)\r\n    print(&quot;Select one of the following streams in which you want to study&quot;)\r\n    while(True):\r\n        print(&quot;1. Computer Science&quot;)\r\n        print(&quot;2. Information Technology&quot;)\r\n        print(&quot;3. Electronics and Communication&quot;)\r\n        print(&quot;4. Electrical and Electronics&quot;)\r\n        print(&quot;5. Mechanical&quot;)\r\n        print(&quot;10. Exit&quot;)\r\n        print(&quot;Enter the choice number from above&quot;)\r\n        choice = int(input())\r\n        if choice == 1:\r\n            print(&quot;You have chosen Computer Science.&quot;);\r\n            cse();\r\n            print(&quot;Are you sure you want to lock this stream? Choose either A or B.&quot;)\r\n            print(&quot;A. Yes, I'm sure&quot;)\r\n            print(&quot;B. No, I'm not sure&quot;)\r\n            ch = input()[0]\r\n            if ch == 'A':\r\n                print(&quot;Congratulations!! You are now a CSE student at PrepBytes&quot;);\r\n                break\r\n        elif choice == 2:\r\n            print(&quot;You have chosen Information Technology.&quot;);\r\n            it();\r\n            print(&quot;Are you sure you want to lock this stream? Choose either A or B.&quot;)\r\n            print(&quot;A. Yes, I'm sure&quot;)\r\n            print(&quot;B. No, I'm not sure&quot;)\r\n            ch = input()[0]\r\n            if ch == 'A':\r\n                print(&quot;Congratulations!! You are now an IT student at PrepBytes&quot;);\r\n                break\r\n        elif choice == 3:\r\n            print(&quot;You have chosen Electronics and Communication.&quot;);\r\n            ece();\r\n            print(&quot;Are you sure you want to lock this stream? Choose either A or B.&quot;)\r\n            print(&quot;A. Yes, I'm sure&quot;)\r\n            print(&quot;B. No, I'm not sure&quot;)\r\n            ch = input()[0]\r\n            if ch == 'A':\r\n                print(&quot;Congratulations!! You are now an ECE student at PrepBytes&quot;);\r\n                break\r\n        elif choice == 4:\r\n            print(&quot;You have chosen Electrical and Electronics.&quot;);\r\n            ee();\r\n            print(&quot;Are you sure you want to lock this stream? Choose either A or B.&quot;)\r\n            print(&quot;A. Yes, I'm sure&quot;)\r\n            print(&quot;B. No, I'm not sure&quot;)\r\n            ch = input()[0]\r\n            if ch == 'A':\r\n                print(&quot;Congratulations!! You are now an EE student at PrepBytes&quot;);\r\n                break\r\n        elif choice == 5:\r\n            print(&quot;You have chosen Mechanical Engineering.&quot;);\r\n            mech();\r\n            print(&quot;Are you sure you want to lock this stream? Choose either A or B.&quot;)\r\n            print(&quot;A. Yes, I'm sure&quot;)\r\n            print(&quot;B. No, I'm not sure&quot;)\r\n            ch = input()[0]\r\n            if ch == 'A':\r\n                print(&quot;Congratulations!! You are now a ME student at PrepBytes&quot;);\r\n                break\r\n        elif choice == 10:\r\n            break\r\n        else:\r\n            print(&quot;You have entered an invalid choice.&quot;)\r\n\r\nif __name__ == '__main__':\r\n    main()\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_11132 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_11132 a\"),jQuery(\"#tab-content_11132\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p><strong>Output:<\/strong><\/p>\n<pre><code>Welcome to PrepBytes University Portal!!!\nSelect one of the following streams in which you want to study\n1. Computer Science\n2. Information Technology\n3. Electronics and Communication\n4. Electrical and Electronics\n5. Mechanical\n10. Exit\nEnter the choice number from above\n2\nYou have chosen Information Technology.\nYou will get the following subjects\nDSA\nDBMS\nComputer Networks (CN)\nMPMC (Multi processor and Multi Controller)\nInformation Security\nAre you sure you want to lock this stream? Choose either A or B.\nA. Yes, I'm sure\nB. No, I'm not sure\nA\nCongratulations!! You are now an IT student at PrepBytes<\/code><\/pre>\n<p>So, the above program is one of the simplest and most extensive examples of a menu driven program in Python.<\/p>\n<p><strong>Conclusion<\/strong><br \/>\nIn this article, we learned about the menu driven program in Python. We have discussed the conditional statements in python as they are necessary for the complete understanding of the menu driven program in Python. And after that we discussed the menu driven program for the PrepBytes University example. With this, we come to the end of our discussion in this article. We hope that you liked the discussion and hope to see you again soon at PrepBytes.<\/p>\n<h2>Frequently Asked Questions(FAQs)<\/h2>\n<p>Here are some Frequently Asked Questions on \u201cMenu Driven Program in Python\u201d<\/p>\n<p><strong>Ques 1. What are the advantages of a menu driven program in Python?<\/strong><br \/>\n<strong>Ans.<\/strong> Menu driven program in Python provide an intuitive and easy-to-use interface for users. They limit the characters that can be entered, reducing the chances of user error.<\/p>\n<p><strong>Ques 2. How do I create a menu driven program in Python?<\/strong><br \/>\n<strong>Ans.<\/strong> You can create a menu driven program in Python by using loops, conditional statements, and functions.<\/p>\n<p><strong>Ques 3. What is the difference between a switch-case statement and if-else statements in menu driven program in Python?<\/strong><br \/>\n<strong>Ans.<\/strong> Switch-case statements are better suited for menu driven program in python because they provide a clearer and more concise code structure. If-else statements can quickly become unwieldy and difficult to read for larger menus.<\/p>\n<p><strong>Other Python Programs<\/strong><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/python\/python-program-to-reverse-a-number\/\" title=\"Python program to reverse a number\">Python program to reverse a number<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/heap\/python-program-for-heap-sort\/\" title=\"Python program for heap sort\">Python program for heap sort<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/python\/python-program-to-check-armstrong-number\/\" title=\"Python program to check armstrong number\">Python program to check armstrong number<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/python\/python-program-to-check-leap-year\/\" title=\"Python program to check leap year\">Python program to check leap year<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/python\/python-program-to-convert-celsius-to-fahrenheit\/\" title=\"Python program to convert celsius to fahrenheit\">Python program to convert celsius to fahrenheit<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/python\/python-program-to-find-factorial-of-a-number\/\" title=\"Python program to find factorial of a number\">Python program to find factorial of a number<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/python\/python-program-to-reverse-a-linked-list\/\" title=\"Python program to reverse a linked list\">Python program to reverse a linked list<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/python-program-to-find-the-middle-of-a-linked-list-using-only-one-traversal\/\" title=\"Python Program to find the middle of a linked list using only one traversal\">Python Program to find the middle of a linked list using only one traversal<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/python\/python-program-to-add-two-numbers\/\" title=\"Python Program to Add Two Numbers\">Python Program to Add Two Numbers<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/python\/python-program-to-check-palindrome-number\/\" title=\"Python Program to Check Palindrome Number\">Python Program to Check Palindrome Number<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/python\/python-program-to-print-the-fibonacci-series\/\" title=\"Python Program to Print the Fibonacci Series\">Python Program to Print the Fibonacci Series<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Menu Driven Programs are designed to increase the level of user interaction within the program. Such programs receive user input and provide an output based on the selected input. In this article, we will be exploring Menu Driven Programs implemented in Python. Menu Driven Program in Python A menu-driven program in Python is a program [&hellip;]<\/p>\n","protected":false},"author":52,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[154],"tags":[],"class_list":["post-11148","post","type-post","status-publish","format-standard","hentry","category-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Menu Driven Program in Python<\/title>\n<meta name=\"description\" content=\"Learn how to write a menu driven program in Python and Understand the Conditional Statements with program example in Python.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Menu Driven Program in Python\" \/>\n<meta property=\"og:description\" content=\"Learn how to write a menu driven program in Python and Understand the Conditional Statements with program example in Python.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"PrepBytes Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prepbytes0211\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-12-20T10:20:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-04-18T13:10:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671519245920-Menu%20Driven%20Program%20in%20Python.jpg\" \/>\n<meta name=\"author\" content=\"Prepbytes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prepbytes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Menu Driven Program in Python\",\"datePublished\":\"2022-12-20T10:20:56+00:00\",\"dateModified\":\"2023-04-18T13:10:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/\"},\"wordCount\":1005,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671519245920-Menu%20Driven%20Program%20in%20Python.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/\",\"name\":\"Menu Driven Program in Python\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671519245920-Menu%20Driven%20Program%20in%20Python.jpg\",\"datePublished\":\"2022-12-20T10:20:56+00:00\",\"dateModified\":\"2023-04-18T13:10:01+00:00\",\"description\":\"Learn how to write a menu driven program in Python and Understand the Conditional Statements with program example in Python.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671519245920-Menu%20Driven%20Program%20in%20Python.jpg\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671519245920-Menu%20Driven%20Program%20in%20Python.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/43.205.93.38\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\",\"item\":\"https:\/\/prepbytes.com\/blog\/category\/python\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Menu Driven Program in Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/43.205.93.38\/#website\",\"url\":\"http:\/\/43.205.93.38\/\",\"name\":\"PrepBytes Blog\",\"description\":\"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING\",\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/43.205.93.38\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/43.205.93.38\/#organization\",\"name\":\"Prepbytes\",\"url\":\"http:\/\/43.205.93.38\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"contentUrl\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"width\":160,\"height\":160,\"caption\":\"Prepbytes\"},\"image\":{\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/prepbytes0211\/\",\"https:\/\/www.instagram.com\/prepbytes\/\",\"https:\/\/www.linkedin.com\/company\/prepbytes\/\",\"https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\",\"name\":\"Prepbytes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"caption\":\"Prepbytes\"},\"url\":\"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Menu Driven Program in Python","description":"Learn how to write a menu driven program in Python and Understand the Conditional Statements with program example in 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:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/","og_locale":"en_US","og_type":"article","og_title":"Menu Driven Program in Python","og_description":"Learn how to write a menu driven program in Python and Understand the Conditional Statements with program example in Python.","og_url":"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2022-12-20T10:20:56+00:00","article_modified_time":"2023-04-18T13:10:01+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671519245920-Menu%20Driven%20Program%20in%20Python.jpg","type":"","width":"","height":""}],"author":"Prepbytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prepbytes","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Menu Driven Program in Python","datePublished":"2022-12-20T10:20:56+00:00","dateModified":"2023-04-18T13:10:01+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/"},"wordCount":1005,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671519245920-Menu%20Driven%20Program%20in%20Python.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/","url":"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/","name":"Menu Driven Program in Python","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671519245920-Menu%20Driven%20Program%20in%20Python.jpg","datePublished":"2022-12-20T10:20:56+00:00","dateModified":"2023-04-18T13:10:01+00:00","description":"Learn how to write a menu driven program in Python and Understand the Conditional Statements with program example in Python.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671519245920-Menu%20Driven%20Program%20in%20Python.jpg","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671519245920-Menu%20Driven%20Program%20in%20Python.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/menu-driven-program-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/43.205.93.38\/"},{"@type":"ListItem","position":2,"name":"Python","item":"https:\/\/prepbytes.com\/blog\/category\/python\/"},{"@type":"ListItem","position":3,"name":"Menu Driven Program in Python"}]},{"@type":"WebSite","@id":"http:\/\/43.205.93.38\/#website","url":"http:\/\/43.205.93.38\/","name":"PrepBytes Blog","description":"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING","publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/43.205.93.38\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/43.205.93.38\/#organization","name":"Prepbytes","url":"http:\/\/43.205.93.38\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/","url":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","contentUrl":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","width":160,"height":160,"caption":"Prepbytes"},"image":{"@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/prepbytes0211\/","https:\/\/www.instagram.com\/prepbytes\/","https:\/\/www.linkedin.com\/company\/prepbytes\/","https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA"]},{"@type":"Person","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e","name":"Prepbytes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","caption":"Prepbytes"},"url":"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/"}]}},"_links":{"self":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/11148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/users\/52"}],"replies":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/comments?post=11148"}],"version-history":[{"count":3,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/11148\/revisions"}],"predecessor-version":[{"id":15743,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/11148\/revisions\/15743"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=11148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=11148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=11148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}