A document from MCS 260 Fall 2021, instructor Emily Dumas. You can also get the notebook file.

MCS 260 Fall 2021 Homework 2

  • Course instructor: Emily Dumas


This is the first homework where you'll write Python code, so the instructions are detailed and long. The actual problems are brief.


This homework assignment must be submitted in Gradescope by 10am CST on Wednesday, September 8, 2021.


This homework assignment is about the topics of worksheet 2, i.e. variables, the built-in types int, float, and string, and the use of booleans and conditionals.


No collaboration is permitted, and you may only access resources (books, online, etc.) listed below.

Resources you may consult

The course materials you may refer to for this homework are:

Expected to be most useful:

Allowed and possibly useful, but not the most relevant:

Point distribution

This homework assignment has 2 problems, numbered #2 and #3. Each problem is worth 4 points.

Because of the way Gradescope works, there will also be a problem 1 worth 0 points.

What to do if you're stuck

Ask your instructor or TA a question by email, in office hours, or on discord.

How to submit

This is a Gradescope programming assignment, meaning that Gradescope will expect you to upload your .py files. You need to upload both programs to Gradescope every time you submit. For advice on how to do that, see the section "Help submitting" below.

More advice

At the very end of this document there's some advice about how to work on these problems that duplicates things discussed in Lab 1, Worksheet 1, etc., but which might be helpful.

1. There's no problem 1

In Gradescope, problem 1 is used to report the result of autograder testing. In this homework, the autograder will ONLY give you advice (warn you of syntax issues etc.) but it won't actually assign any points. Everyone will get a full score (0 out of 0) on problem 1.

2. Bumblebee detector

Write a program hwk2prob2.py that waits for the user to type one line of text.

If the user types Bumblebee (capital B) followed by the Enter key, the program should print BUMBLEBEE DETECTED. Otherwise, it should print NO BUMBLEBEE.

Sample usage (first line is always what the user typed):

  • Bumblebee
  • Feral raccoon holding an improvised spear
  • This line of text has Bumblebee in it but is not just that word by itself

3. Exponent calculator

Write a program hwk2prob3.py that asks the user for a base $b$ and exponent $x$ (both of them floats) and which then prints the value of $b^x$ (i.e. $b$ raised to the power $x$). You don't need to do any checking to make sure the input is valid.

The interface should look like this (two examples shown):

  • Base: 2.5
    Exponent: 8
    (Here, 2.5 and 8 are values typed by the user.)
  • Base: 64
    Exponent: 0.5
    (Here, 64 and 0.5 are values typed by the user.)

Help and advice (optional)

Help submitting

IMPORTANT: Don't submit a program until you've tried it locally (on the computer you use to write programs) and you think it works.

This assignment requires you to upload 2 files every time you submit. Students sometimes find the Gradescope interface for multiple file uploads a little confusing, and end up submitting just one file. Here are detailed instructions:

  • Find "Homework 2" in Gradescope and click on it to submit.

  • This should open a window asking you to upload files, looking a bit like this: image of upload dialog box

  • Either drag both files onto the dotted box (e.g. from the explorer), or click on the dotted box to browse and select one file.

  • If you dragged both files into the dotted box, skip ahead to the last step.

  • If you browsed to select one file, you should now you should see a window looking like this: image of upload dialog box after uploading one file

  • To select a second file, click the link "Browse", which is marked with an arrow in the image above. It's not a button; it is a link in the middle of the dialog box.

  • Finally, when all your files appear in the window, click the large green "Upload" button.

Help on the basics of making and running programs

Below is a summary of some things from worksheet 1 and the first couple of lectures about how to write and run Python programs. These are instructions for Windows. If you try to determine the corresponding steps for Mac of Linux and have trouble, let me know.

  1. Create a folder to store your work.

  2. Open Visual Studio Code and create a new file (hwk2prob2.py). Save it in the folder you just created.

  3. Open Windows Powershell

  4. In Powershell, move to the folder with the new file. The easiest way to do that is to go back to Visual Studio Code, right-click the filename tab, and select "Copy Path". Go back to Visual Studio Code and paste the result. It will look something like this:

    C:\Users\ddumas\Desktop\MCS 260\Homework 2\hwk2prob2.py

    Edit that to a "cd" command that changes directory to the folder by adding cd and a space at the beginning, putting quotes around the path, and removing the "hwk2prob2.py" filename:

    cd "C:\Users\ddumas\Desktop\MCS 260\Homework 2\"

    This is a command you only need to run once. Afterward, your Powershell will be opened in the correct folder and you can run the programs as many times as you need to.

  5. Run the script hwk2prob2.py by entering this command in Powershell:

    python3 hwk2prob2.py

    Assuming that file is empty, you should either get a Powershell prompt back again immediately or you'll see an error. If you see an error, it probably means you are not in the correct folder.

  6. Now, write some code in hwk2prob2.py. When you think it will work, move on to...

  7. Run the script hwk2prob2.py again and test whether it works. Go back to step 6 if needed.

  8. Create, write, and test hwk2prob3.py.

Revision history

  • 2021-09-02 Initial publication
  • 2021-09-05 Add clarification about containment vs equality in problem 2