Description
Unix/command prompt basics
For this course you will need a basic understanding of the directory structure your computer uses and some
basic commands for navigating it from the terminal (if you are on a macintosh or Linux system) or the
command prompt (if you are on a Windows PC).
The commands you will need are as follows:
• cd /path/to/directory- This command changes the directory you are currently in to the diretory inputted.
• ls – Lists the files in your current directory
• pwd – Prints the path of your current directory (unix only)
2
• cd (with no arguments) – Prints the path of your current directory (windows only)
• mkdir – used to make a new directory
• rm – used to delete files (but not directories)
• rmdir – used to delete directories
• ./ – used to run a compiled program in your current directory
The following exercises are meant to give you some familiarity with these commands.
5 exercise 1
1. Open up command prompt or terminal on your computer. This can be found in the start menu if you
are on Windows, using search and typing terminal if you are on a Macintosh, or on Linux, clicking on
the Desktop and choosing “Open terminal”.
2. In the terminal window, type the command pwd. Save the output to a summary file. Note that this
output is telling you what your system’s home directory is.
3. Type the command ls into your terminal. Note the output to yourself (no need to put this in your
summary file). This is listing all the files and directories located inside your current directory.
4. Make a directory called test using the command mkdir test. Afterwards, type the command ls.
Has the output changed at all from the previous step? Note the change in output in your summary
file.
5. Move to your newly created directory test directory using the command cd test. Next, type the
command ls. Note what the output is (it should be nothing, since there is nothing in this directory
yet).
6. Download the executable file hello world.sh from Canvas. Save it to the directory test. Use the ls
command to verify that this file is there.
7. Now delete the file hello world.sh with the command rm hello world.sh. Type the command ls
to verify that it has been deleted.
8. Now move up one level in your directory back to the home directory using the command cd … Here
the two dots are a shortcut for the name of the level above your current directory.
9. Delete the test directory using the command rmdir test. Use the command ls. Do you still see the
directory test in the output? If not then it has been successfully deleted.
6 Python Introduction
Python is an open-source object oriented programming language. It is one of the most popular programming
languages in the world and has become an industry standard in the fields of scientific computing, data science
and machine learning. The purpose of this course is not to teach you the Python programming language,
but to use it as a tool to explore the numerical methods you will be learning about during the lecture portion
of this class. However, we will be introducing some of the modern day tooling that is used for professional
Python development. You will be required to use all of the tools discussed in the following sections except
for the Visual Studio Code (VScode) editor. You are welcome to use any text editor of your choosing.
Some links and references will be included at the end of the lab if you are interested in learning more. If
you have never programmed before I highly suggest you go through one of the free basic tutorials which is
available online.
7 Visual Studio Code
VScode is a lightweight open-source text editor made by Microsoft for Windows, Linux, and MacOS. While
there are many text editors available, VScode is currently the most popular developer environment tool in
3
the world. It offers support for many programming languages beyond Python. I personally use it for all of
my work and recommend you do too for this class.
8 Exercise 2
1. Download and install VScode for your operating system from the site https://code.visualstudio.com/
9 Installing Python via Anaconda
There are a number of different ways to install Python on your computer. Depending on your operating
system (non Windows) Python may already be installed on your computer. However, a default installation
will come with just the Python standard library. The Python standard library is an extensive set of Python
modules that handles things like string handling, text processing, and basic math functionality. However,
the real power of Python comes with the vast number of available 3rd party open-source packages.
The default installer for these packages is the Python package installer pip. A difficulty with using pip
however is that frequently different packages will have conflicts with one another. Resolving these conflicts
manually represents a significant amount of work, especially in fields such as data science. To tackle this
problem, a number of tools have been developed. One of these tools and the one we will be using for this class
is the conda package manager built into Anaconda. We will see that it easily allows us to install different
packages while it automatically deals with any dependency conflicts.
10 Exercise 3
1. Download and install Anaconda for your operating system from https://www.anaconda.com/products/individual.
If you are on Windows, you should see an Anaconda powershell prompt appear in your start menu.
Click on that to open it, we will be making use of it throughout the course.
11 Putting it all together
Now that you have installed all the tools needed we will run through an example of what your workflow for
these labs will look like. You will need to download some files from canvas.
12 Exercise 4
1. Create a new folder named lab01 YOURNAME.
2. Open a terminal on your computer. If you are on Windows, this should be done using the Anaconda
power shell. On Linux or a Mac, this can be done in VScode by navigating to the menu bar the
top where it says Terminal and selecting new terminal or by simply opening a seperate terminal on
your system by doing a search for terminal. In the terminal it should say (base) followed by your
username on the computer. This indicates that conda is working properly. Using the cd command in
the terminal, navigate to the folder you created at the previous step.
3. Using the cd command in the terminal navigate to the folder you created at step (a). If you’re unsure
of how to do this either ask me or quickly read through the tutorial at
https://www.geeksforgeeks.org/cd-command-in-linux-with-examples/
4. Create a new folder in your directory named code. Download the file lab01.py from the code directory
on the Canvas website.
5. Looking at the file lab01.py, describe in your own words what the file does.
4
6. Lastly, in the terminal move to the code directory and run lab01.py with the command python
lab1.py. Record the output in your summary file.
13 References
Below are some links and book titles if you would like to learn more. Nothing is required, however if you
have no programming experience I recommend trying to work through a bit of the beginner’s tutorial.
• Python beginners tutorial – https://python.land/python-tutorial
• In-depth discussion of Python linters and code quality – https://realpython.com/python-code-quality/
• Introductory Python book – Dive Into Python 3 https://diveintopython3.net/
• Intermediate Python book – Effective Python: 90 Specific Ways to Write Better Python
• Intermediate Python book: Kong, Siauw, Bayen, “Python Programming and Numerical Methods”
• Intermediate Python book: Hill, “Learning Scientific Programming with Python”
5

