Instead of boring you with more
lecture on this topic, I'm going to ask you to investigate it yourself,
by revisiting the revisited World Population model from Lab 4.
If you didn't complete this program for Lab 4, just copy-and-paste it from
page 74 of the textbook, put some blank lines and indents in to make it
correct, readable, Python,
and fill in the missing values like
`<current_year>` appropriately. Run the program to make sure it's
generating sensible output. (It should only report the result once, not
inside the loop.) Now modify it as follows:

- Report the final population
rather than the year (you can also remove the “dead code” for
initializing and accumulating the year at this point).

- Change the
`while`loop into a`for`loop for looping over`Y`years, where`Y`is another constant you initialize at the top of the program.

Now, computer scientists are lazy and would rather not compute something
in a loop that they can compute in a single command. Wikipedia has a nice
entry showing
a single formula for the sort of exponential growth that you are modeling
in this world-population program. Replace the `for` loop in your
program with this formula, making sure to check the results against the
original looping version. For the exponent, you can use the double-multiply
symbol `**`. You might also want to introduce a new variable called
`INITIAL_POPULATION`, so you can keep both the old and new population
values around.

Of course, the population doesn't jump to its new value all at once: people are being born every second of every minute of every hour of every day of every week of every month of every year. To use the monthly rate rather than the yearly rate, you can:

- Divide the growth rate by 12.

- Replace
`Y`with`(Y*12)`in the formula. Better yet, factor the 12 by creating another variable at the top of the program, call it`N`, and use that variable instead of repeating the 12.

**Question 6.1:** Report the initial population, then
the new population based on years, then months, then weeks, then days,
then hours, then minutes, then seconds.

So what does all this have to do with ** e** and

- Replace the initial population with 1.

- Replace the number of years
`Y`with 1.

- Replace the growth rate with
`1/N`, so e.g.`.0114/N`becomes`1/N`.

**Question 6.2:** What happens to the
final “population” as `N` gets very large
(maybe just keep multiplying `N` by 10)? Is there
a final value on which the population seems to settle? Once the values
of the first three or four digits of this number stop changing, copy and
paste them into Google and see what comes up. What is the commmon feature
of the links you get?

Almost done! Copy the following line of code and paste it at the top of
your `exponential.py` program:

This will give us access to thefrom math import *

**Question 6.3:** What is the approximate
result of applying
` log` (i.e.

**Just for fun:** We also saw the *sin* and *cos* functions in the
formula for generating normally-distributed random numbers for Monte
Carlo simulations and the like. Perhaps there an even
deeper relationship
between * e* and important functions and constants –
a hidden order in the universe,
just beyond our grasp!

- You may wish to run
again, because the firmware update has probably erased the personal name you gave your Scribbler in the first lab.**setName()**

- The firmware update allows us to do
, which I recommend doing once before`setPicSize('small')`,`takePicture()`, and any other command that uses the camera – for reasons we discovered in last week's lab.`getBright()`

- Unless you feel like typing in the
stuff in each time your run your program, I would omit the part of the author's code that runs**'/dev/tty...'**to get this information (as on page 111), and just do the**ask()**once as usual.**initialize('/dev/tty...')**

- For the “playpen” and corral projects, you can use the
paving stones
I'll supply to build barriers of various shapes.

- As we know by now, sensors are finicky and rarely perform as advertised – hence the need for Bayesian reasoning about their outputs in real-world tasks. So if you're making no progress with the project you've chosen, try one that uses different sensors.