Computer Science 101: Lab #4

As usual, read carefully through the chapter, answering my questions in red (in this case, just one) and the questions that the authors asks (the non-rhetorical ones, at least, as opposed to “can you find the battery indicator?”); and write the programs specified in the Do This: paragraphs. Then complete as many of the programming exercises as you can at the end of the chapter, remembering to emphasize quality over quantity.

Again, a very important real-world skill that I want you to develop in this course is the ability to deal intelligently with under-specified tasks. So if the author asks you to write a program to make random drawings, give it a sensible, self-descriptive name like, and think of the simplest program you can write to solve the task as specified. If the author asks you to demo your robot program to a friend outside of class, you can just run it for me.

Pro-tip: When copy/pasting a single line of code that wraps (appears as two lines) in the textbook, make sure to turn it back into a single line in your programs and in the Shell, through judicious use of the delete key. You'll see some examples of this problem on page 86.

Question 4.1: Hackers, like cats, can never leave well-enough alone. So when the author says on page 67 that “The value returned by currentTime is a number that represents the seconds elapsed since some earlier time, whatever that is”, we get curious about that last bit.1 Can you convert the value returned by currentTime into a number of years, to determine what “that earlier time” was? Google unix time to check your answer.

1Or at least, I do. Not all cats are curious – some are even tragically indifferent. C'est la vie.