Search for question
Question

Q1. Write a short script, in Spyder, to print out the

square root of the integers 0 to 9. You'll need to use a

for-loop and also the math.sqrt() function so don't

forget to import the math library. Save the script as

you'll need it again in Q3 below.

Q2. Your isotopic-dating program includes a line

something like sumbsr = rbsr.sum(). Replace this

with a loop and test it to see if the program still gives

the same answer. In this case, do you think using a loop

is an improvement?

Q3. Alter your script from Q1 so that it prints out the

square roots of integers until it gets to an answer of

4.5. Use a while condition: statement to do this.

Q4. Download AgeFromFile.py from Moodle and open it in

Spyder. There are two changes from the program we've used

before. Firstly, I have renamed the variables from, for

example, rbs to ratio1 to emphasises that the program

now works for any isotope system. This makes no

difference at all to the program as we can call variables

by almost any name we like. Secondly, the script now

contains a list of half-lives for three different isotope

systems and calculates the decay constant (ie lambda)

from one of these. I happen to have chosen the Rb/Sr

system half life at the moment. Download the RbSrData.txt

file from Moodle and just check that the program still

works. It'll give you a slightly different answer to

before but it should still be close to the actual age of

the Earth.

Your task, is simply to use if, elif and else to allow

the user to choose which half life to use.

Fig: 1