Warmup Part 1

Part A: Debugging Practice

For this week’s debugging practice, you’ll consider some function-related bugs that you’re likely to encounter at some point as programmers. Solve each problem by first thinking on your own for a few minutes, then discussing what you figured out with your partner.

You’re going to be debugging three calculator programs today. They were written by someone who didn’t seem to realize that you could just do basic calculations in the console. Instead, each of the three programs runs a while loop, which asks the user whether they want to multiply, exponentiate, or quit. Multiplying should ask for two numbers, say, x and y, and print their product. Exponentiating should ask for two numbers, a base and an exponent, and raise the base to the power of the exponent. Unfortunately, none of the three programs, calc1.py, calc2.py, or calc3.py execute both tasks successfully.

For each program, decide on some test cases, and run the program on those test cases. You should make sure to try both multiplication and exponentiation (though both aren’t necessarily broken), and make sure that your test results are different when the inputs are switched. You are only expected to work with positive integers. See if you can figure out what the bugs are in each program and how to fix them. Better yet, try to understand what the person who wrote the code might have been confused about. Write your explanations for each program in WARMUP.md.

ReadMe

The while loop for each program is correctly implemented; you should be looking for bugs with the functions and their usage.

Reminder

Be sure to commit and push your changes after you debug each function and add your notes to WARMUP.md!