CS 111
Fall 2018

Lab 1: Getting started

Task 0: Review lab policies


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:

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.


When working on a machine in EMA 304 or EMA 302, 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:


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. (On the lab machines, Notepad is available by clicking on the Windows icon and going to the Windows Accessories folder.)


The text files that you submit for this course must be plain-text files. More information about what this means is available here. Please read the information on that page carefully before you proceed.

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

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

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

    weeks = days // 7
    print('that is approximately', weeks, 'weeks')

    Put your answers to the following questions in your lab1task3.txt file:

    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?

    Don’t forget to save your answers. (On a Mac, you may need to use the Make Plain Text command in the Format menu before saving the file.)

  3. Copy and paste the following lines of buggy code into your lab1task2.py file from Task 2, after all of the existing lines of the program:

    print('Go Terriers!")
    print('pi is approximately' (22 / 7)

    Make sure that you add the lines to the lab1task2.py file and not to the Python Shell.

  4. Save the changes to the program using Ctrl-S. Then try to run it using F5. What happens?

  5. 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 Scratch

First, start up Scratch:

The following exercises should help you to become more comfortable working in the Scratch environment, as well as developing simple algorithms to solve problems. Don’t hesitate to ask a staff member if you have a question.

  1. Create a program that works as follows: When the green flag is pressed, the cat should move 50 steps forward, say “Hello!” for one second, and move 50 back to where it started, then turn 90 degrees clockwise. This sequence should be repeated four times, so that the cat ends up where it began when the program is finished.

    Save this program as lab1task4-1 using the File->Save menu option.

  2. Start a new program using the File->New menu option. The new program should generate a random number and ask the user to guess it.

    The program should work as follows: When the green flag is pressed, a random number should be generated between 1 and 10. You should use a variable to store the random number, which you can select using the pick random operator from the Operators category. (After you create the variable, make sure you uncheck the box next to the variable’s name. This will make sure it doesn’t appear on the stage — we wouldn’t want the user to see the secret number!)

    Once the random number is selected, the cat should say, “I’m thinking of a number...” and ask the user for a guess. If the guess is correct, the cat should say, “You win!” Otherwise, the cat should say, “You lose!”.

    Save this program as lab1task4-2 using the File->Save menu option.

  3. Use the File->Save As menu option to save a copy of your program for the previous exercise, saving it as lab1task4-3.

    Modify the program so that the user is given three guesses.

    • After a correct guess, the cat should say, “You win!” as before, and it should stop asking for guesses.

    • After a wrong guess, the cat should say, “Too high!” if the guess is greater than the random number or “Too low!” if the guess is less than the random number.

    • If the user does not guess the number after three attempts, the cat should say, “You lose!”.

    One way to stop asking for guesses after a correct guess is to use the stop all or stop script command, both or which are available in the Control category. These commands will stop the program, and thus no further guesses will be requested. However, this approach isn’t ideal, because either stop command will also erase the final “You win!” message.

    If time permits, see if you can devise an alternative approach to stopping the guessing that does not use stop all or stop script. Hint: Consider using another variable!

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.