Module 8 - Section 1 - Ed Py
8.1.6 - Spin and turn
Copy the following code to edpy
#-------------Setup----------------
import Ed
Ed.EdisonVersion = Ed.V2
Ed.DistanceUnits = Ed.CM
Ed.Tempo = Ed.TEMPO_MEDIUM
#--------Your code below-----------
degresToTurn = 90
Ed.Drive(Ed.SPIN_LEFT, Ed.SPEED_6, degresToTurn)
Notice that instead of entering the raw value for the third distance parameter, there is the word “degreesToTurn”. This is a variable in Python and it represents a value that has been defined as the value 90. This is called “assigning a value” to a variable.
Variables in Python are places in memory for storing values that are common throughout a program. An advantage of using variables is that if their value changes then it only has to be changed in one line in the code.
Add the following line to your program after the last line and download and run the program.
Ed.Drive(Ed.SPIN_RIGHT, Ed.SPEED_6, degreesToTurn)