COS 109: Problem Set 5

Tue Oct 8 14:52:36 EDT 2024

Due midnight, Wednesday October 23

Collaboration policy for COS 109: Working together to really understand the material in problem sets and labs is encouraged, but once you have things figured out, you must part company and compose your written answers independently. That helps you to be sure that you understand the material, and it obviates questions of whether the collaboration was too close.
You must list any other class members with whom you collaborated.

Problem set answers need not be long, merely clear enough that we can understand what you have done, though for computational problems, show enough of your work that we can see where your answer came from.

1. A Small Matter of Programming

For these problems, make sure that your proposed solutions actually work, by running your code in Python before submitting.

Do not use ChatGPT or the like; do your own programming.

You can experiment with Python in several ways. It's easiest to use Google's Colab, which lets you write and run Python code on a web page. You will be doing the same thing for Lab 5, so this is an easy way to get started. The instructions for Lab 5 will also give you more information. There are also a dozen small examples here.

(a) Write a Python program to print the odd numbers in the range from 1 to 100 inclusive.

i = 1
# you fill in the rest

(b) Write a program to count backwards from 100 to 0 in steps of 7, like 93, 86, 79, .... (This is a common test for neurological function.) The basic idea is

n = 100
while n >= 0:
   # you fill in the rest

(c) Modify your program from part (b) to read two numbers, the initial value (e.g., 100) and the step (e.g., 2), and count backwards from the initial value by steps of the given size. Use the function input() to read the values, sort of like this:

init = input()
step = ...

# you fill in the rest

2. Yet More Numbers

(a) It is sometimes said that the amount of electrical power needed to perform a computing task falls by half every one and a half years, in the sense that newer equipment will use less power to accomplish the same task. If a supercomputer uses 10 megawatts for a particular computation today, how many years from now would improved hardware require 10 milliwatts for the same task? (This is utterly nonsensical, of course.)

(b) An article in The Guardian says that GCHQ (the British equivalent of the NSA) had tapped 200 fiber optic cables, each running at 1 GB per second. Approximately how many petabytes per day would this amount to?

(c) The Guardian article goes on to say that this would be "equivalent to sending all the information in all the books in the British Library 192 times every 24 hours." From this odd factoid, and assuming that one book is 1 MB, estimate approximately how many books there are in the British Library. State your assumptions clearly.

(d) On 12/9/09, the Wall Street Journal said that the Nook ebook reader has 2 GB of memory, "enough to hold about 1,500 digital books." The very next day, the New York Times said that a zettabyte "is equivalent to 100 billion copies of all the books in the Library of Congress." From these two statements, estimate approximately how many books there are in the Library of Congress. State your assumptions clearly.

(e) Assess the accuracy of the resulting number: too high, too low, or about right. Explain why you say so.

3. It's All Greek to Me

Exactly what do the first four lines of this cartoon say? (Decode the whole thing if you're motivated.)

Submission

Please use this Google Doc for your answers. It would be a great help if you could type your answers.

Submit your problem set in PDF format by uploading a file called pset5.pdf to Gradescope. You can submit as many times as you like; we will only look at the last one.