Page 143 - KEC Khaitan C8 Flipbook
P. 143

PROJECT NAME: Menu Driven Program

                 Software Used: Python Editor

                 Objective:

                 Create a Python program that provides a menu-driven interface for the user to check if a number
                 is even, odd, or prime, while appropriately handling invalid inputs.
                 Platform:

                    ∑  PyCharm

                    ∑  Google Colab: https://colab.research.google.com/


                 Step-by-Step Instructions


                 Plan IPO Framework
                 Step  1   Input:

                             Display a menu with the following options:

                             mathematica
                             CopyEdit


                              1.  Check if a number is Even
                              2.  Check if a number is Odd

                              3.  Check if a number is Prime

                              4.  Exit

                             Prompt the user to select an option (1-4).

                             If the user selects options 1, 2, or 3, prompt them to input a number.
                 Step  2   Process:

                             Perform the following based on the selected option:

                              o  Option 1: Check if the number is even (number % 2 == 0).

                              o  Option 2: Check if the number is odd (number % 2 != 0).

                              o  Option 3: Check if the number is prime by verifying it has no divisors other than 1
                                 and itself.

                              o  Option 4: Exit the program.

                             Handle invalid menu inputs with an appropriate message.










                                                                                                 Hands-On Project  141
   138   139   140   141   142   143   144   145   146   147   148