Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 97 - 2615_KEC
P. 97

    Use Codeskulptor3-https://py3.codeskulptor.org/

                     Step-by-Step Instructions: (Plan IPO)
                     1.  Input: User enters a number (dynamic - varies with each user).
                     2.  Process: Check  if the number is greater  than zero, less than zero or exactly  zero using
                         conditional statements (if, elif, else).

                     3.  Output: Display  a message  indicating  whether the  number  is  positive,  negative  or zero.
                         Refer to the sample

                                                    The number -2 is a negative number.
                                              Code:                                              Flow:

                                                                                                  USER
                                                                                               ENTERS SIDE
                                                                                                 LENGTH

                                                                                             CALCULATE AREA

                                                                                            CALCULATE PERIMETER

                                                                                            DISPLAY TOTAL AREA

                                                                                          DISPLAY TOTAL PERIMETER

                                                                                                PROCESS
                                                                                                COMPLETE

                     Bonus Feature:
                         Decimal Values: Modify the program to accept and identify decimal values.

                         Repeat Check: Allow the user to input multiple numbers in a loop until they decide to exit.

                         Validation: Add input validation to ensure the user enters numeric values only.

                                                                                                 Introduction to Python  95

| 92 93 94 95 96 97 98 99 100 101 102 |