Doing Calculations in TUTOR
You can make TUTOR calculate things for you. For example:
The –arrow- statement, as written, is completely equivalent to “arrow 1509”. Or consider this:
The radius of the circle will be taken to be the square root of the sum of 41 squared and 72.6 squared.
Just about any expression that would have made sense to your high school algebra teacher will be understood and correctly evaluated. For example:
|2×3+2||14 (NOT 22)|
|sin(30°)||0.5 (See Appendix C for other functions.)|
|6/5×10-3||1200 (NOT 1.2x 10-3 )|
If your high school algebra is rusty, we remind you that “2 x 5 +3” means “(2 x 5)+3” which is 13, not “2 x (5+3)” which is 16. The rule is that multiplication is “more important” than addition or subtraction and gets done first. If you are unsure at some point, you may use parentheses around several portions of your expression to make the meaning unambiguous.
A similar point holds true for division, which is considered “more important” than addition or subtraction. “8+6/2” means “8±(6/2)” which is 11, not “(8+6)/2” which would be 7. The only ticklish point is whether multiplication is more or less “important” than division. TUTOR agrees with most mathematical books and journals that multiplication is more important than division, so that “6 x 4/3 x 2” means “(6 x 4)/(3 x2)” which is 4. Note that this means that TUTOR considers “1/2(6 +4)” to be “1/(2(6+4))” which is 0.05, not “(1/2)(6 +4)” which would be 5. Again, when in doubt use parentheses. You could write “.5(6+4)” if you wish, which is unambiguous.
Experience has shown that students tend to write algebraic responses according to these rules, and making TUTOR conform to these rules facilitates the correct judging of student algebraic and numerical responses.
Having seen how expressions are handled, we can introduce “student variables” which may be used to hold numerical values obtained by evaluating expressions. These stored results can be used later in the lesson. As an example, a “variable” might hold the student's score on a diagnostic quiz, and this score could be used later to determine how much drill to give the student. The storage place is called a “variable” because what it holds may vary at different times in the lesson. Another variable might count the number of times the student has requested help, in which case the number which it holds would vary from 0 to 1 to 2, etc.
There are 150 “student variables” which can be used for storing up to 150 numerical values. These “student variables” are unimaginatively called:
Later in this section we will learn how to give variables names (such as “radius,” “wrongs,” “tries,” “speed,” etc.) which are appropriate to their particular usage in a specific lesson. But first, we will look at variables using their primitive names: vl through v150.
These variables are called student variables because each of the many students who may simultaneously be studying your lesson has his or her own private set of 150 variables. You might use variable v23 to count the number of correct responses on a certain topic, which will be different for each student. If there are forty students working on your lesson, TUTOR is keeping track of forty different “v23's”, each one different. This is done automatically for you, so that you can write the lesson with one individual student in mind, and v23 may be considered simply as containing that individual student's count of correct responses. Thus, one student might be sent to a remedial unit because the contents of his variable number 23 show that he did poorly on this topic. Another student might be pushed ahead because the contents of her variable 23 indicate an excellent grasp of the material. It is through manipulation of the student variables that a lesson can be highly individualized for each student.
Variables arc useful in building certain kinds of displays. Let's see how to build a subroutine which can draw a half-circle in various sizes, depending on variables which we set up. In order to specify the size of the figure and its location on the screen, we must specify a center (x and y) and a radius. We let variables vl and v2 hold the horizontal x and vertical y positions of the center, and we let variable v3 hold the value for the radius.
We can draw such a figure with the following unit:
In order to use this subroutine we might write:
The statement “calc v1⇦150” means “perform a calculation to put the number 150 in variable v2”. The statement “calc v1⇦v1+v3” means “calculate the sum of the numbers presently held in variables vl and v3, and put the result in variable v1”. In the present case, this operation will store the number 250 (150+100) in variable vl for use in the second “do halfcirc”. Note that the second “do halfcirc” will use the original values of v2 and v3, which have not been changed. This unit will produce this picture:
The symbol ⇦ is called the “assignment” symbol, because it assigns a numerical value to the variable on its left. This numerical value is obtained by evaluating the expression to the right of the assignment symbol.
A slightly more complicated example of a -calc- statement is:
This statement means “multiply by 5 the number currently held in v2, add this to the number held in v1, and store the result in v3.” In conversation you might read this as “calc v3 assigned five v2 plus vl” or “calc v3 becomes five v2 plus v1”. Notice that it is common practice to refer simply to “v2” when we really mean “the number currently held in variable v2”.
The simplest possible -calc- statement merely assigns a number to a variable, as in “calc v2⇦150”. It is permissible to make more than one assignment in a -calc- statement:
This will assign the value 18.62 to both variables v3 and v7.