Page 137 - TP_Plus_v2.2_Class_8
P. 137

OR: Results in true if at least one of the conditions is true. If both are false, the result will be false.
                 Now, write your answers for both.


                 1.                                                2.   shop = 500
                    age =20                                             customer = "new"
                    IF age >= 12 AND age <= 19 THEN                     IF shop > 100 OR customer = "old" THEN
                        PRINT "You are a teenager"                          PRINT "Eligible for a free gift"
                    ELSE                                                ELSE
                        PRINT "You are not a teenager"                      PRINT "Not eligible for a free gift











                         Let’s CatCh uP

                   Write the result for the following conditions:

                                                                          height_inch=46
                           a.  day ="Sunday"                          b.  ticket ="no"
                               IF day = "Saturday" OR day= "Sunday"       IF height_inch > 40 AND ticket = "yes"
                               THEN                                       THEN
                                    PRINT "It's a holiday"                     PRINT "Entry allowed"

                               ELSE                                       ELSE
                                    PRINT "It's not a holiday"                 PRINT "Entry not allowed"











                        LOOPS IN A PROGRAM


                 A loop allows a set of instructions or a block of code to be executed repeatedly. It helps in automating
                 repetitive tasks and makes the code more efficient by avoiding the need to write the same instructions
                 multiple times. When a loop repeats forever (endlessly), it is called an infinite loop. There are two types
                 of loops, which are as follows:

                    Counting loops: These repeat a block of code a specific number of times.

                    Conditional loops: These repeat until a certain condition is reached, which means they keep going
                   until the condition remains true.







                                                                                            Algorithmic Intelligence  135
   132   133   134   135   136   137   138   139   140   141   142