CS 111: Introduction to Computer Science

Lab: some Python basics

Goal

What to do?

Today, we'll work with these three programs:

For each program in the list above:

  1. 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.
  2. Open the sample program in BBEdit or any text editor of your choice.
  3. Read the program with your partner. Discuss what you think the program will do.
  4. Run the program (by typing, for example, python3 strings0.py at the command line. See if your predictions about the program were true. If not, try to figure out why not.
  5. 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.
  6. Move on to the next program.

That's it!

Nothing to hand in. But it's important to study the ideas in these programs seriously and get your questions answered one way or another, because we're going to building on these ideas over the next several weeks.