CME 193: Introduction to Scientific PythonCourse description: This short course runs for the first three weeks of the quarter and is offered each quarter during the academic year. It is recommended for students who want to use Python in math, science, or engineering courses and for students who want to learn the basics of Python programming. The goal of the short course is to familiarize students with Python’s tools for scientific computing. Lectures will be interactive with a focus on learning by example, and assignments will be application-driven. No prior programming experience is needed. Topics covered include control flow, basic data structures, File I/O, and an introduction to NumPy/SciPy.
Times: Tu / Th 3:45PM - 5:35PM; April 4 - April 18
- Austin Benson (arbenson AT stanford DOT edu)
- Dan Frank (danfrank AT stanford DOT edu)
We will be using Piazza for course communication. The course page is here.
VirtualBox that has all of the tools needed for the class. The VM uses Linux Debian 6.0.7 and has the following tools installed: NumPy, SciPy, matplotlib, and IPython. The username is cme193 and the password is 193cme. The root password is toor. To get started:
- Download and unzip the VM appliance: cme193-debian-6.0.7.ovf.zip (1.9 GB).
- Download VirtualBox.
- Start VirtualBox and select File --> Import Appliance
- Select cme193-debian-6.0.7.ovf for the appliance.
An autograder will be distributed with some of the homework. The autograder is there so you can tell if your work is correct. Gaming the autograder by hard-coding the answers it is expecting is a violation of the Stanford Honor Code.
You are encouraged to collaborate with others on the homework assignments. However, you must write up your own solutions. You may not copy each others' code.
- April 4: Lecture 1: Introduction to Computing with Python [slides] [code in slides] [exercises and solutions] Reading:
- How to start the Python Interpreter: [Windows] [Mac] [Linux] [Directly online].
- Python arithmetic, comparison operators, assignment operators, logical operators, operator precedence, if statements, if/else statements, and while loops.
- Lexical analysis: 2.1.1-2.1.3, 2.1.5-2.1.9, 2.3.1. This section of the Python docs contains vocabulary from Programming Language theory, so do not worry if you do not understand everything. However, the examples on indentation and logical lines are useful.
- Myths about Indentation
- Running a python script: Here is a video with instructions for using Notepad on Windows to execute Python programs. If you like Eclipse, you can use PyDev. Here is a Stack Overflow discussion on Python IDEs.
- April 9: Lecture 2: Data Structures [slides] [code in slides] [exercises and solutions] Videos:
- April 11: Lecture 3: File I/O, Object-oriented Python, and Introduction to NumPy [slides] [code in slides] [exercises and solutions] Reading:
- Input and Output: 7.1, 7.1.1, 7.2, 7.2.2
- Reading and writing files
- Classes: Intro, 9.3.1-9.3.4, 9.4, 9.5, 9.6, 9.7, 9.9
- Building and installing NumPy
- NumPy for MATLAB users
- April 16: Lecture 4: NumPy and SciPy [slides] [code in slides] [exercises and solutions] Reading:
- April 18: Lecture 5: Data Visualization [slides] [code in slides] [exercises] Reading:
- Homework 0: [pdf]. Not Due.
- Homework 1: [pdf] [starter code]. Due Tuesday, April 9.
- Homework 2: [pdf] [starter code]. Due Thursday, April 11.
- Homework 3: [pdf] [starter code]. Due Tuesday, April 16.
- Homework 4: [pdf]. Due Tuesday, April 23. Note: we do not meet for class on this day.
- Homework 5: [pdf]. Due Thursday, May 2 (extra credit).
- tutorialspoint Python tutorial
- An Informal Introduction to Python
- The Python Tutorial
- CS 9H, UC-Berkeley self-paced Python course
© 2012 Austin Benson
Template design by Andreas Viklund