CS 111
Fall 2016
Introduction to Computer Science
Lab01: Python basics
During this lab, you will work with the following programs.
- strings0.py -- getting started with input, output, and character strings
- arithmetic.py -- working with numbers
- decisions.py -- if statements
- strings1.py -- string indexing and slicing
- strings2.py -- iteration over a string
- lists.py -- an introduction to Python lists
There are lots of ways to explore sample programs like these, but here's a recommended procedure. For each sample program:
- Download the program to your working directory by right-clicking on the link and choosing "Save Link As" or whatever similar option your browser gives you.
- Open the sample program in a text editor (TextWrangler is a particularly good choice).
- Read the program with your partner. Discuss what you think the program will do.
- Run the program (by typing, for example,
python3 strings0.py
in the Terminal window). See if your predictions about the program were true. If not, try to figure out why not. - Try to answer the questions in the program's comments. You may want to test your answers by making changes to the program in your text editor, saving the changes, and running the program again. Play around with the program until you feel comfortable with all its operations. Ask questions.
- Move on to the next program.