Notes from Jan 21 and 27, 2010 Scientific Programming Study Group
Jim Emery is a member of Kansas City’s STEM2 society. He has started a Scientific Programming Study Group recently at the CCCKC hackerspace. STEM2 is a group that promotes Science, Technology, Engineering and Mathematics. The topic is based on his document titled “Scientific Calculating, Programming and Writing” which can be found at the Stem2 web site.
Jim chose the Python language for these sessions. It is a powerful language with many features that make scientific computing easier.
Finding documentation on Python:
- Python Documentation – Get the official documentation from Python.org.
- Dive into Python – You can download a free copy of this book or purchase a printed copy.
- Thinking in Python – You can get this and other books from Bruce Eckel’s web site.
- A Byte of Python – This is a good introductory text for Python.
Getting Started in Linux
Since I’m using Ubuntu Linux, Python is already installed. To work through Jim’s examples I need to create the following new directories in my home folder “/vthompson“.
The next step is to open a command window and adjust the $PATH variable so any programs placed in the /bin folder can be found. First, keyin the command echo $PATH to see how this environment variable is already defined.
From the picture above, we see the /bin directory shows up in in several places. Surprisingly, the directory I just created in my home directory already shows up. How did this happen? The answer can be found in the hidden shell script also found in my home directory, vthompson/.profile. It contains the following code segment that automatically places a home directory’s /bin path as the first one in the PATH list.
# set PATH so it includes user’s private bin if it exists
if [ -d "$HOME/bin" ] ; then
A good place to find more information is the Ubuntu Documentation page on Environment Variables. Also, for more information about shell scripts check out the Beginners Bash Scripting page. Another helpful document if you’re just starting to work with the command line is this CategoryCommandLine document.
Purpose of the /bin Directory
Linux is designed as a multi user operating system. While your desktop or laptop computer may not be used by other people logging into different accounts, using the home directory’s /bin folder prevents our special programs from interfering with someone else’s computer usage habits.
Trying a Sample Program
From Jim’s book, Chapter 6 on Graphing and Programmable Calculators, I’m trying the square root sample. I’ve created a /src directory to place my program source code into. Here is the sample program written using the gedit editor:
And the resulting screen shot of the program:
Other Python Notes:
- Python Numeric and Scientific Programs – More programs using Python
– About SomeoneKnows –
(c) 2010 Vince Thompson