Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 120 - 2615_KEC
P. 120

    2.  Process: Compare the three numbers using conditional statements (if, elif, else) and determine
                          the greatest number among the three inputs.
                      3.  Output: Display the greatest number in a formatted message. Refer to the sample

                                       The number 200 is the highest among 110,200 and 30 number.

                                    Code:                                             Flow:

                                                                                  ENTER THREE NUMBERS

                                                                                  COMPARE THE NUMBERS
                                                                                         YES

                                                                                   IS THE FIRST NUMBER
                                                                                      GREATEST?

                                                                                                 NO
                                                                                             IS THE SECOND
                                                                       YES
                                                                                           NUMBER GREATEST?
                                                                                          YES              NO

                                                            DISPLAY FIRST NUMBER   DISPLAY SECOND    DISPLAY THIRD NUMBER
                                                                AS GREATEST      NUMBER AS GREATEST      AS GREATEST

                      Bonus Feature:
                          Logical Operators: Try implementing the same task using logical operators (and, or).

                          Equal Numbers Check: Enhance the program to handle cases where two or all three numbers
                          are equal.
                          Looping Feature: Allow users to check multiple sets of numbers without restarting the program.

                                STRING

                      A sequence of characters which is enclosed or surrounded by single (' '), double (" ") or Triple
                      ('''  ''') quotes is known as a string. The sequence may include a letter, number, special characters
                      or a backslash. Python treats single quotes as double quotes.

                      Program 14: To print a string.
                          Program14.py

                       File  Edit  Format   Run   Options  Window    Help
                                                                                    Output
                       str = "This is Shweta's pen."
                       print(str)                                                 This is Shweta's pen.

                       118  Premium Edition-VII

| 115 116 117 118 119 120 121 122 123 124 125 |