A.2. Chapter 2
A.2.1. Exercise 1 solution
The following variable names are not valid for the listed reasons.
integer -- can't use a reserved word 6_05 -- can't start with a digit month -- can't use a reserved word a$ -- can't use a $ weekday -- can't use reserved word file extension -- can't use embedded spaces
A.2.2. Exercise 2 solution
The following are invalid literal constants:
e-02 -- need a number before the exponent 2.44 e −03 -- no spaces allowed between the number, the 'e', and the exponent
A.2.3. Exercise 3 solution
200 mod 7 -- 4 100 / 25 * 4 -- 16.0 ((100.5 as integer) - (50.99 as integer) ) ^ 2 -- 2401.0 (1.234e+2 + 2.345e+3) -- 2468.4 2 ^ 0.5 -- this calculates the square root of 2 (1.414213562373) (6 ^ 2 + 8 ^ 2) ^ 0.5 -- 10.0 100.25 + 7.5 div 5 - 29 mod 8 -- 96.25
A.2.4. Exercise 4 solution
log 5 * (100 - 32) / 9 log (100 as degrees Fahrenheit) as degrees Celsius log 5 * (32 - 32) / 9 log (32 as degrees Fahrenheit) as degrees Celsius log 5 * (0 - 32) / 9 log (0 as degrees Fahrenheit) as degrees Celsius log 5 * (55 - 32) / 9 log (55 as degrees Fahrenheit) as degrees Celsius
A.2.5. Exercise 5 solution
(3.31E-8 + 2.01E-7) / (7.16E-6 + 2.01E-8)
A.2.6. Exercise 6 solution
log 365 + 7 - 365 mod 7 log 12258 + 23 - 12258 mod 23 log 996 + 4 - 996 mod 4
A.2.7. Exercise 7 solution
set D1 to date "Friday, July 22, 2005 8:34:35 PM" set D2 to date "Sunday, August 14, 2005 8:44:50 PM" set diff to D2 - D1 set numWeeks to diff div weeks set diff to diff - numWeeks * weeks ...
Get Beginning AppleScript® now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.