Homework 1: Math and Variables

Due: Monday, September 8

Remember that homework is not formally assessed. However, any problems turned in by the due date will be checked and feedback provided.

If you need to retake the associated module quiz, you must have the homework completed and checked by your instructor before you retake the quiz.

For each exercise you should do the following:

  1. Predict: First, complete the exercise without using the Python interpreter.

  2. Check: Run the code in a Kaggle notebook. Does the actual output agree with what you wrote down in step 1?

  3. Evaluate: If your answer in step 1 was different than the actual output, keep experimenting with it, consult an online reference, ask a friend or TA or professor, etc. until you can explain why the code works the way it does and what your misunderstanding(s) were in part 1.

Some of the exercises use variables. Assume the variables have been initialized as follows:

x = 7
y = 3

Exercises:

  1. 4 * 3
  2. 7 / 2
  3. 0 / 7
  4. 7 / 0
  5. 10 - y * 2
  6. 4 + x + 18 / y
  7. 2 * (y + 4) + x
  8. y**3 + x**2

Your solution should be hand-written (or typed) and contain the following:

  • For each line of code above, write down your original prediction.
  • If your check (step 2) matched, put a check mark. Otherwise, put an X.
  • If you wrote an X, then write a brief sentence explaining what you got wrong initially and why the code produces the answer it does.