< Back

Test 1

Create the following directories for storing your answers to today's test. Make sure all of the files you create are stored within this directory.

$ cd ~/cs120/
$ mkdir test1
$ cd test1

You are only allowed to access this course webpage and the Python and Turtle documentation webpages. You are not allowed to access any other websites. You are not allowed to access files from your directory, or files from any other user's directories. Failure to abide by these rules is a violation of Academic Integrity, and will be treated as such.


Question 7

Create a file called question_7.py. Put your answers to the following questions there.

(15 points total)


Question 8

Half-lives

Radioactive materials experience radioactive decay. This results from the atoms of the material emitting particles as radiation. Over time, this radiation reduces the amount of material that is still present. A common measurement of this phenomenon is deemed "half-life." Half-lives for common materials can be found on Wikipedia.

Create a file called question_8.py that prompts the user to enter in an integer value that represents the amount of time (in seconds) that it takes for the material to reduce in half. The program should then ask for an integer representing an amount of material in grams.

This program should compute (and return) the duration (in seconds) that the material will continue to exist. You can compute this value by multiplying the half-life by: $$ log_{2}\left( \frac{amount}{EPSILON} \right)$$ where EPSILON is a constant with value 0.000001. You can use the log function from the math module to compute logarithms.

(15 points)


Bonus

Fibonacci Sequence

The Fibonacci sequence is a famous mathematical sequence of numbers that is strongly related to the Golden Ratio. One of the wonders of the sequence is its exceedingly simple definition. Let \(F_n\) define the \(n^{th}\) number in the Fibonacci sequence, where \(F_1 = 1\) and \(F_2 = 1\). Then, the \(n^{th}\) number can be computed as:

$$F_{n} = F_{n - 1} + F_{n - 2}$$

Create a file called bonus_question.py. In this file, write a program which prompts the user for an integer \(n > 0\). Your program should use a for loop to compute and print the \(n^{th}\) number of the Fibonacci sequence.


Submission

When you have finished, create a tar file of your test1 directory. To create a tar file, execute the following commands:

cd ~/cs120
tar czvf test1.tgz test1/

To submit your activity, go to inquire.roanoke.edu. You should see an available assignment called Test #1.