Questions for problem solving

Reading a function

  1. Where are the inputs (or arguments or parameters) to the function?

  2. Can you see any clue as to what type of value the function takes as arguments?

  3. Where is the output (or return value) of the function?

  4. Can you see any clue as to what type of value is being returned?

  5. If a variable is returned, where is it first defined?

  6. If a variable is returned, where is it updated after it is first defined?

  7. Where are the function arguments used inside the body of the function and how are they used?

  8. What other variables are declared inside the function; where and how are they used?

  9. Can you see any other clues as to what the function is doing?

  10. If you call the function with some test values, what is returned and what does that tell you about the function's purpose and the types of its arguments and return value?

  11. Can you think of a real-worl use for this function?

Writing a function

  1. Can you put into your own words, what this function is supposed to be doing?

  2. If a function outline is provided, can you describe what each part of the outline is doing;

  3. What is a sensible name for this function?

  4. What type of value does this function return?

  5. What arguments does this function need to produce a meaningful output?

  6. Have the arguments got sensible names?

  7. What methods could you apply to the arguments to get the required output?

  8. How could you break this problem down into smaller parts?

  9. If tests are provided, what happens when you run the tests and can you explain what each of the test results mean?

  10. If tests are provided, could you amend the return value to pass the first test?

  11. And subsequent tests?

  12. If you are getting error messages when running the code, what are the eror messages telling you?

Last updated