CS 111
Spring 2018

Old version

This is the CS 111 site as it appeared on May 10, 2018.

Lab 1: Getting started

FLR 267

If your lab meets in FLR 267, you should begin by following the instructions found here.

Task 0: Review lab policies

Note

You cannot get credit for completing the lab tasks at home and coming to lab only to sign the attendance sheet.

Task 1: Introduce Piazza

Piazza is an educational social network designed to facilitate communication between students, teaching assistants, and instructors. If you haven’t set up an account yet, do that now. If you have set up an account, go ahead and log in. In either case, you should use the Piazza link in the navigation bar of the course website.

There are some helpful features of Piazza that we would like to emphasize:

Task 2: Explore IDLE

First, start the IDLE program. If you are using one of the PCs in the teaching lab, you can start IDLE by clicking on the Start menu, clicking All Programs, finding the folder Python 3.5, and clicking IDLE (Python GUI) from that folder.

If you are using your own computer, you should have installed some version of Python 3 as part of Lab 0. If you need help locating the IDLE program on your own computer, ask one of the teaching staff members to help you.

Let’s review the basics of using IDLE. The easiest way to do so is to download a Python file, open it in IDLE, and then run it in IDLE.

Note

When working on a machine in the lab, you should save all of your work on the Z: drive. This is a special directory maintained by the computer science department which is accessible from any computer to which you are logged on using your CS account (either in the teaching lab or in the undergraduate lab). If you do not save your work to the Z: drive, you will not be able to access your work again after you log out!

To make it easier to manage the browser (the guide to the lab), the text editor (where you are developing a program), and the Python Shell (where Python runs and displays results) on your computer, we recommend resizing and rearranging the windows in the following way:

IDLE

This allows you to make the best use of all three windows simultaneously.

Task 3: Understand and debug Python code

Open up a text editor (Notepad or TextEdit) and create a text file named lab1task3.txt. Put all answers that you write for this task in this file.

Let’s take another look at the program from Task 2.

  1. What types of statements are included in this program?

  2. In what order are the statements executed?

  3. Explain in detail what happens when the following two statements are executed:

    course = course + 1
    print('maybe you will take CS', course, 'next semester')
    
  4. Consider the following two lines of the program:

    weeks = days // 7
    print('that is approximately', weeks, 'weeks')
    
    1. What is the difference between weeks and 'weeks'?

    2. Why does the program print 5 weeks instead of 6 or 5.7142857...?

    3. How could we make the program print a more precise result for the number of weeks?

  5. Copy and paste the following lines into the program, after all of the existing lines:

    print()
    print('Go Terriers!")
    print('pi is approximately' (22 / 7)
    
  6. Save the changes to the program using Ctrl-S. Then try to run it using F5. What happens?

  7. The new lines include several bugs. See if you can find and fix them. Feel free to ask the TF or CA if you need help.

Task 4: Practice with Picobot

Open up a text editor (Notepad or TextEdit) and create a text file named lab1task4.txt. Put all answers that you write for this task in this file.

  1. Open the Picobot simulator, and replace the default program with the following program:

    0 ***x -> S 0
    0 ***S -> X 1
    1 **x* -> W 1
    1 **W* -> X 1
    
  2. Press the button labeled Enter rules for Picobot.

  3. Do not press Go! Rather, press the Step button repeatedly. As you do so, watch what happens to Picobot, as well as to the values shown in the State and Surroundings boxes that appear below the control buttons.

    As you do so, come up with answers to the following questions, and add them to your lab1task4.txt file:

    1. When does the State change from 0 to 1? Why does this make sense?

    2. What happens if you continue pressing Step after the State changes to 1?

    3. When does Picobot stop moving completely, even if you keep pressing Step?

    4. What does this program do in general? (You may want to try re-running it a few times by pressing Reset and then either Step or Go.)

  4. Let’s say that we want to modify the previous program so that Picobot will: (1) perform the same initial motions as before, and (2) continue moving until it reaches the upper-left corner of the room.

    Your classmate suggests adding the following rule after the existing ones:

    1 x*W* -> N 1
    

    However, the resulting program is not valid for two reasons:

    • There is a repeat rule.
    • Picobot will not actually make it to the upper-left corner.

    Add this new rule after the existing ones and click Enter rules for Picobot. Read the error in the Messages pane. Why is this error occurring – in other words, what is a repeat rule? Add your answer to your lab1task4.txt file.

    Fix the program so that it is valid (so that there are no repeat rules) and has the desired behavior. Copy the final program into your lab1task4.txt file.

  5. Write a Picobot program that makes Picobot trace a border around the edge of the map (it should look like a gray border inside of the blue border, perhaps with some additional gray lines). Once you get it working, copy the program into your lab1task4.txt file.

Task 5: Submit your work

You should use Apollo to submit the following files:

Make sure to use these exact file names, or Apollo will not accept your files. If Apollo reports that a file does not have the correct name, you should rename the file using the name listed in the assignment or on the Apollo upload page.

Don’t worry if you didn’t finish all of the tasks. You should just submit whatever work you were able to complete during lab.

Here are the steps:

  1. Login to Apollo, using the link in the left-hand navigation bar. You will need to use your Kerberos user name and password.
  2. Check to see that your BU username is at the top of the Apollo page. If it isn’t, click the Log out button and login again.
  3. Find the appropriate lab section on the main page and click Upload files.
  4. For each file that you want to submit, find the matching upload section for the file. Make sure that you use the right section for each file. You may upload any number of files at a time.
  5. Click the Upload button at the bottom of the page.
  6. Review the upload results. If Apollo reports any issues, return to the upload page by clicking the link at the top of the results page, and try the upload again, per Apollo’s advice.
  7. Once all of your files have been successfully uploaded, return to the upload page by clicking the link at the top of the results page. The upload page will show you when you uploaded each file, and it will give you a way to view or download the uploaded file. Click on the link for each file so that you can ensure that you submitted the correct file.