COMPUTER SCIENCE CAFÉ
  • WORKBOOKS
  • BLOCKY GAMES
  • GCSE
    • CAMBRIDGE GCSE
  • IB
  • A LEVEL
  • LEARN TO CODE
  • ROBOTICS ENGINEERING
  • MORE
    • CLASS PROJECTS
    • Classroom Discussions
    • Useful Links
    • SUBSCRIBE
    • ABOUT US
    • CONTACT US
    • PRIVACY POLICY
  • WORKBOOKS
  • BLOCKY GAMES
  • GCSE
    • CAMBRIDGE GCSE
  • IB
  • A LEVEL
  • LEARN TO CODE
  • ROBOTICS ENGINEERING
  • MORE
    • CLASS PROJECTS
    • Classroom Discussions
    • Useful Links
    • SUBSCRIBE
    • ABOUT US
    • CONTACT US
    • PRIVACY POLICY
CODING CHALLENGES | DEBUGGING AND TRACING
Enjoy the journey of learning to code, explore and be creative
ON THIS PAGE
CHALLENGE 1 | IDENTIFY THE ERROR TYPES
CHALLENGE 2 | EVEN NUMBERS SYNTAX ERROR
CHALLENGE 3 | CALCULATE THE AVERAGE RUNTIME ERROR
CHALLENGE 4 | CALCULATE THE SQUARE RUNTIME ERROR
Picture
ALSO IN THIS TOPIC
LEVEL 1 | GETTING STARTED
 LEVEL 2 | VARIABLES AND USER INTERACTION
LEVEL 3 | DATATYPES AND OPERATORS
 LEVEL 4 | IF STATEMENTS
 LEVEL 5 | LOOPS
 ​LEVEL 6 | ARRAYS / LISTS
LEVEL 7 | FUNCTIONS
 ​LEVEL 8 | ALGORITHM DESIGN
LEVEL 9 | OOP
 ​LEVEL 10 | EXTERNAL DATA HANDLING
TURTLE CHALLENGES
YOU ARE HERE | DEBUGGING AND TRACING​
CHALLENGE SOLUTIONS
Picture
SUBSCRIBE FOR SAMPLE SOLUTIONS
Picture
CHALLENGE 1 | IDENTIFY THE ERROR TYPES
1: For the code below give the error type and explain the error.
def 
foo():
    print(bar)
foo()

2: For the code below give the error type and explain the error.
def add(a, b): 
    return a + b
print(add(2, '3'))

3: For the code below give the error type and explain the error.
d = {'a': 1, 'b': 2}
print(d['c'])

4: For the code below give the error type and explain the error.
s = 'string'
print(s.undefined_attribute)

5: For the code below give the error type and explain the error.
l = [1, 2, 3] 
​
print(l[3])
Picture
CHALLENGE 2 | EVEN NUMBERS SYNTAX ERROR
TASK
The following code is meant to take a list of numbers and return the sum of all even numbers in the list. However, there is an error in the code. Your task is to find the error, identify the issue, and correct it to make the code work as intended.
  • PYTHON
  • JAVASCRIPT
  • JAVA
  • PSEUDOCODE
<
>

    

    

    

    
Picture
CHALLENGE 3 | CALCULATE THE AVERAGE RUNTIME ERROR
TASK
The following code is meant to take a list of numbers and return the average of all numbers in the list. However, there is a runtime error in the code. Your task is to find the error, identify the issue, and correct it to make the code work as intended.
  • PYTHON
  • JAVASCRIPT
  • JAVA
  • PSEUDOCODE
<
>
Code Editor

    

    

    

    
Picture
CHALLENGE 4 | CALCULATE THE SQUARE RUNTIME ERROR
TASK
The following code is meant to take a user-inputted number and calculate the square of that number. However, there is a potential runtime error in the code that can be triggered by certain user inputs. Your task is to find the error, identify the issue, and correct it to make the code work as intended, regardless of the user input.
  • PYTHON
  • JAVASCRIPT
  • JAVA
  • PSEUDOCODE
<
>

    

    

    

    
Picture
Picture
NAVIGATION
LEVEL 1 | GETTING STARTED
LEVEL 2 | VARIABLES AND USER INTERACTION
LEVEL 3 | DATATYPES AND OPERATORS
LEVEL 4 | IF STATEMENTS
LEVEL 5 | LOOPS
​LEVEL 6 | ARRAYS / LISTS
LEVEL 7 | FUNCTIONS
LEVEL 8 | ALGORITHM DESIGN
LEVEL 9 | OOP
LEVEL 10 | EXTERNAL DATA HANDLING
TURTLE CHALLENGES
DEBUGGING AND TRACING​
CHALLENGE SOLUTIONS
Picture
SUGGESTIONS
We would love to hear from you
SUBSCRIBE 
To enjoy more benefits
We hope you find this site useful. If you notice any errors or would like to contribute material then please contact us.