Page 154 - Computing E-Book Grade 7
P. 154

The City School  2021-2022





              Ed.NOTE_A_7                                A

              Ed.NOTE_A_SHARP_7                          A sharp

              Ed.NOTE_B_7                                B
              Ed.NOTE_C_8                                High C





                     Parameter Input Options                          Plays Note For (Duration)

              Ed.NOTE_SIXTEENTH                                125 milliseconds
              Ed.NOTE_EIGTH                                    250 milliseconds

              Ed.NOTE_QUARTER                                  500 milliseconds

              Ed.NOTE_HALF                                     1,000 milliseconds

              Ed.NOTE_WHOLE                                    2,000 milliseconds





             6.9. Conditional Structures in Edison



            IF Statement

            An important part of coding is making decisions. The most common way to do this

            is to use an IF statement. An IF statement asks whether a condition is true or false.
            If the result is true, then the program executes the block of statements following the

            IF statement. If the result is false, the program ignores the statements inside the if
            statement and moves to the next line of code outside of the if statement.



            Sample Code


            #--------Your code below-----------
            # loop forever

            while True:
                Ed.ObstacleDetectionBeam(Ed.ON)

                if Ed.ReadObstacleDetection()!=Ed.OBSTACLE_NONE:
                    Ed.PlayBeep()

                    Ed.ReadObstacleDetection()












                                                                                                                154
   149   150   151   152   153   154   155   156   157   158   159