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

The City School  2021-2022





             Always remember that while using the Ed.FORWARD and Ed.BACKWARD command, the
             Distance parameter works as the number of steps(cm/inch) Edison has to move.
             Whereas, while using Ed.FORWARD_RIGHT, Ed.FORWARD_LEFT, Ed.SPIN_RIGHT,

             Ed.SPIN_LEFT, the Distance parameter works as the angle at which Edison has to turn.

             This means that a code like Ed.Drive(Ed.SPIN_LEFT, Ed.SPEED_5, 90) will make
             the Edison robot turn 90 degrees counterclockwise.


             Sample Code-Creating a Square with Edison

             #-------------Setup----------------                  Ed.Drive(Ed.FORWARD, Ed.SPEED_6,
             import Ed
             Ed.EdisonVersion = Ed.V2                             20):This code will drive Edison forward
             Ed.DistanceUnits = Ed.CM                             to 20cm at the speed of 6.
             Ed.Tempo = Ed.TEMPO_MEDIUM
             #--------Your code below-----------                  Ed.Drive(Ed.SPIN_LEFT, Ed.SPEED_6,
             Ed.Drive(Ed.FORWARD, Ed.SPEED_6, 20)                 90): This code will rotate the Edison to 90
             Ed.Drive(Ed.SPIN_LEFT, Ed.SPEED_6, 90)               degrees at the speed of 6.
             Ed.Drive(Ed.FORWARD, Ed.SPEED_6, 20)
             Ed.Drive(Ed.SPIN_LEFT, Ed.SPEED_6, 90)
             Ed.Drive(Ed.FORWARD, Ed.SPEED_6, 20)
             Ed.Drive(Ed.SPIN_LEFT, Ed.SPEED_6, 90)
             Ed.Drive(Ed.FORWARD, Ed.SPEED_6, 20)




             6.6. Variables in Edison


             A Python variable is a reserved memory location to store values. In other words,
             a variable in a python program gives data to the computer for processing. Most

             important function to use the variable is to have flexibility in the program, rather than
             entering data directly into a program, we use variables to represent the data. Then,

             when the program is executed, the variables are replaced with real data.






























                                                                                                                150
   145   146   147   148   149   150   151   152   153   154   155