Chapter 6.2 - Variables |
Exercises1. Why do variable names (that is to say, names of variables) have to begin with a letter?2. If you're unfamiliar with raising to powers (**, shifted H) then do this exercise. At its most elementary level, 'A**B' means 'A multiplied by itself B times', but obviously this only makes sense if B is a positive whole number. To find a definition that works for other values of B, we consider the rule A ** (B+C) = A**B * A**C You should not need much convincing that this works when B & C are both positive whole numbers, but if we decide that we want it to work even when they are not, then we find ourselves compelled to accept that A**0 = 1 A**(-B) = 1/A**B A**(1/B) = the Bth root of A & A**(B*C) = (A**B)**C If you've never seen any of this before then don't try to remember it straight away; just remember that A**-1 = 1/A & A**(1/2) = the square root of A & maybe when you're familiar with these the rest will begin to make sense. Experiment with all this by telling the computer to print various expressions containing **: e.g. PRINT 3**(2+0),3**2*3**0 PRINT 4**-1,1/4 3. Type LET E=EXP 1 Now E has the value 2.718281828..., the base of natural logarithms. Test the rule EXP a number = E ** the number for various numbers. |