Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 148 - 2615_KEC
P. 148

    PROJECT 3: 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.

                      Step  3   Output:

                                    Display whether the number is even, odd, or prime, or display an error message for
                                   invalid inputs.

                      146   Premium Edition-VIII

| 143 144 145 146 147 148 149 150 151 152 153 |