Page 87 - trackpad v5.1 class 8 flipbook
P. 87

AND: results in true only if both the conditions are true. If any one condition is false, the result will
                    be false.
                      OR: results in true if any one of the conditions is true. If both are false, the result will be false.

                 Now, write your answers for both.

                 1.   age =20                                       2.   shop = 500
                    IF age >= 12 AND age <= 19 THEN                     customer = "new"
                        PRINT "You are a teenager"                      IF shop > 100 OR customer = "old" THEN

                    ELSE                                                    PRINT "Eligible for a free gift"
                        PRINT "You are not a teenager"                  ELSE
                                                                            PRINT "Not eligible for a free gift









                                          Write the result for the following conditions:

                                                                                  height_inch=46
                                           day ="Sunday"                          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"
                         uiz    Bee









                           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.
                    Counting loops: These repeat a block of code a certain 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  85
   82   83   84   85   86   87   88   89   90   91   92