CS 111
Summer 2 2018

Problem Set 2 FAQ

Problem Set 2 FAQ

If you don’t see your question here, post it on Piazza or come to office hours! See the links in the navigation bar for both of those options.

General questions

  1. Do our functions need to have the exact names that you have specified in the assignment? What about the variables for the inputs?

    Your functions must have the exact names that we have specified, or we won’t be able to test them. Note in particular that the case of the letters matters, and that some of the function names have one or more underscore characters (e.g., begins_with).

    For the variables specified for the inputs, you could in theory use different names, as long as they are still as descriptive as the original ones. However, when there are multiple inputs, you must keep the inputs in the same order that we specified in the assignment, or we won’t be able to test your function.

  2. I read about or have used some Python functions we have not discussed in lecture. Can I use them in the homework?

    No. You should solve the problems in the homework using only constructs that we have discussed in lecture or that you have seen in the textbook. There are, of course, many different ways to accomplish the homework assignments, but we construct the assignments so that you can solve them using the tools that we have learned about in class.

    As a reminder, you are prohibited from consulting with external sites such as Stack Overflow about the homework assignments.

  3. Do we need to use recursion on this assignment?

    No. None of the functions that we’re asking you to write for this assignment require recursion. If you wrote one or more of them using recursion, that’s okay, too, but doing so is not required.

  4. I think I’m done with the assignment. Are there any things I should check before I submit?

    1. Be sure all of your functions return values instead of printing them.
    2. Include a docstring in all of your functions.
    3. Be sure to run your code after you add your docstrings to ensure that it still runs. If it doesn’t, you may have introduced problems involving the indentation of your docstrings.

Problem 1

  1. When I test my slope function, I get a return value of -0.0 for certain test cases when the slope should be 0. Is this acceptable?

    Yes. In Python, if you divide 0 by a negative number using the / operator, the result is -0.0. You don’t need to worry if your slope function returns -0.0 for cases in which the slope is 0.