< Back

Activity 4

Debugging

Writing code that has errors in it is surprisingly easy to do. More often than not, your initial try at writing a solution to code is going to have some errors in them. The process of finding and eliminating these errors is called debugging. While this process seems pretty daunting, it can be an incredibly rewarding experience when you finally find your bugs.

#File:   places.py
#Author: Scotty Smith

1: 1s_place = 2
2: 10s_place = 4
3: whole_value = 10s_place * 10 + 1s_place
4: print(whole_value)
  1. Which types errors appear in the above python program? Circle the errors in the program.
  2. Assume any Syntax and Runtime errors present are fixed. What would the print statement on line 4 print?
#File:   whole_number.py
#Author: Scotty Smith

1: whole_number = 1337
2: first_digit = whole_number // 1
3: second_digit = whole_number // 10
4: third_digit = whole_number // 100
5: fourth_digit = whole_number // 1000
6: print(first_digit, second_digit, third_digit, fourth_digit)
  1. Which types of errors appear in this new program? Circle the errors in the program.

  2. Assume any Syntax and Runtime errors present are fixed. What would the print statement on line 6 print?

  3. Draw a reference diagram for the whole_number.py program above.