Tutorial introduction to Python
Short Description
Tutorial introduction to Python. A simple program. Much of physics is concerned with the formulation and solution of differential. equations. …
Website: www.phy.uct.ac.za | Filesize: 106kb
Content
Tutorial introduction to Python
A simple program
Much of physics is concerned with the formulation and solution of dierential
equations.
Perhaps the simplest non-trivial dierential equation is the equation that
gives rise to the exponential decay law,
dy(t)
dt
= .. y(t)
where is a decay constant. This equation might describe the decay of a
sample of a radioactive isotope as a function of time, or with appropriate
variables, the absorption of a light ray in a medium as a function of distance
travelled, etc.
The solution is well-known:
y(t) = y(0)e..t
In the following we will assume that we start with 100% of our nuclei at time
t = 0, and that the decay constant = 1:0 s..1.
We can begin our programming in the simplest way, using the computer to
evaluate mathematical expressions.
Here is a simple program in Python to calculate the number of nuclei as a
function of time:
1 # decaya.py - rwf
2 # Simple python program
# straightforward evaluation of expressions
4
from math import *
6
# Constants
8 y0=100.0…
Get the file Download here
Related Books:Related Searches: decay constant, radioactive isotope, exponential decay, python program, mathematical expressions
Comments
Leave a Reply