Page 122 - TP_Pluse_V2.2_Class_7
P. 122

Tech Fact

                          ASCII is made up of 128 symbols in the character set. These symbols consist of letters
                     (both uppercase and lowercase), numbers, punctuation marks, special characters and control
                                                              characters.





                         CONDITIONS IN A PROGRAM

                  While writing a program, we need to make certain decisions based on the logic of the program.
                  Such situations are called conditions. Conditional statements are used in a program to instruct the
                  computer to make a decision. The result of a condition will always be either True or False.


                       if-then-else

                  The program executes the statements                                  Start
                  written  inside the IF  block when  the
                  condition  is True. If  the condition  is
                  False, the  statements  written  inside
                                                                                    IF (Condition)
                  the else block  will  be  executed.  A                           to be checked
                  block refers to a section of code that is        True                                     False
                  grouped together.                         Statements inside IF block           Statements inside ELSE
                                                                  will execute                     block will execute



                                                                                       Stop


                  Look at these examples:
                         Example 1:                                         Example 2:

                         READ Subject                                       READ marks
                         IF Subject = "Maths" THEN                          IF marks > 50 THEN
                             PRINT "Take out Maths book & notebook"             PRINT "Pass"
                         ELSE                                               ELSE
                             PRINT "Check timetable"                            PRINT "Fail"


                         Example 3:                                         Example 4:

                         READ Rain                                          READ age
                         IF Rain = True THEN                                IF age >= 18 THEN
                             PRINT "Carry an umbrella"                          PRINT “You are eligible to vote.”
                         ELSE                                               ELSE
                             PRINT "Do not carry an umbrella"                   PRINT “You are not eligible to vote.”



                  120   Plus (Ver. 2.2)-VII
   117   118   119   120   121   122   123   124   125   126   127