How To Get Started: Python Programming Labs

So if you’re ready to get started “coding the matrix” here’s what you should do first:

  • Spend a few minutes skimming through the course overview, and spend 20 minutes watching Professor Klein’s 2-part Course Introduction videos.
  • Go to the course syllabus and jump down to¬†Week 0. There are a handful of video lectures introducing¬†some of the math, but before that get started with the two programming labs right away.
  • To do the programming labs, you’ll need to get set up with Python–in particular Python 3.3.2. ¬†This may already by installed on the computer you’re using (you can check by typing “python -V” or “python3 -V” at the command line). My machine only had an older version, so I had to download and install Python 3.3.2, which was easy enough. ¬†You’ll also need to use a text editor to create and edit Python scripts. See this “Software Environment” page for more instructions.
  • The first two programming labs–the Python Lab and the Inverse Index Lab–are designed to get you up to speed on Python, and in particular on some aspects of the language that will be used later in the course to implement linear algebra concepts. Follow the instructions on each page: download and unzip the zip files, and put the resulting files in a “matrix” directory on your computer.

I suggest you have (at least) 3 windows open as you work through the programming assignments:

  1. The pdf file for the assignment, which goes through the material and contains the programming tasks for the assignment. As you read through this, experiment with python commands inside..
  2. A terminal window running the Python “REPL” (the “read-eval-print-loop”, which you enter by running “python3” at the command line–make sure you’re in your “matrix” directory when you do so). As you work through each programming task and are satisfied that you’ve written code that carries out the task, copy and paste that code into..
  3. The template¬†file .py¬†provided for each assignment (¬†python_lab.py¬† for the Python lab), i.e., have that file open in a text editor. ¬†You submit your code–and immediately find out whether you’re completed the tasks correctly–as follows: “submit your solution by opening a console window, navigating using¬†cd¬†to the¬†matrix¬†folder, and entering the command¬†python3 submit_python_lab.py. You will need a one-time password to submit this assignment. It’s located¬†on this page.” ¬†Moreover, “You can use the submit command to submit solutions for as many tasks as you like at one time. Enter the numbers of the tasks (called parts), separated by commas. You can also enter a range of numbers such as¬†3-10.”

In addition to the instructions on each assignment page, see also this short video tutorial on “How to submit assignments.”

What I’ve found useful is to do complete just one or two tasks and then submit them by running the submit script, so as to get immediate feedback about whether I’ve completed those tasks correctly, before moving on through the lab. That way you can be sure you understand each concept before moving on to the next one–plus you also get the immediate satisfaction of seeing your score grow on your Assignments page.

So go ahead and jump in to some Python. Depending on how much programming experience you have (and especially if you have any exposure to Python), the first Python Lab should go fairly quickly.

Even if you’re a programming newbie, the lab should be doable. It ramps up from very basic concepts (arithmetic operators and expressions, strings) through various Python data structures (sets, lists, tuples, dictionaries). The key concept is creating new data structures via what are called comprehensions. ¬†(If you’re interested in programming languages, such comprehensions are one way in which Python incorporates aspects of functional programming.)

Here are a few additional Python resources that might be useful:

This entry was posted in Python. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *