



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Examples of common programming errors in jython and explains how to identify and fix them. Errors include name errors, syntax errors, type errors, logical errors, and out-of-bounds errors. Each example includes the broken code, the error message, and instructions for fixing the error.
Typology: Assignments
1 / 7
This page cannot be seen from the preview
Don't miss anything!




A) A local or global name could not be found *Check to make sure you have defined all variables before they are used. B) Your code is not legal Jython. *Look for syntax errors, like indentations, missing parentheses and colons, and equal signs that are either needed or unneeded (if statements and setting variables, = vs. ==). C) An attempt was made to call a function with a parameter of an invalid type. *Remember what needs to be input into each function. pickAFile() makePicture(picture) getRed(pixel) setRed(pixel, redamount) getColor(pixel) setColor(pixel, color) return picture distance(color, color) makeColor(red, green, blue) D) It’s a logical error. (It runs but doesn’t do what you intended it to do) *Common ones are returns inside a loop, no returns, prints instead of returns; trace to see what the function does. E) It’s an out-of-bounds error. *Does the range start with 0 for a pixel? Pixels start at 1,1. Are the numbers too big for the picture or canvas? Then it would have no pixel there.
f = pickAFile() picture = makePicture(f) makeSnazzy(picture) Oh no! It gives you an error! What error did you get? A) A local or global name could not be found B) Your code is not legal Jython. C) An attempt was made to call a function with a parameter of an invalid type. D) It’s a logical error. (It runs but doesn’t do what you intended it to do) E) It’s an out-of-bounds error. Scratch out the broken line and fix it
f = pickAFile() picture = makePicture(f) makeSnazzy(picture) Oh no! It gives you an error! What error did you get? A) A local or global name could not be found B) Your code is not legal Jython. C) An attempt was made to call a function with a parameter of an invalid type. D) It’s a logical error. (It runs but doesn’t do what you intended it to do) E) It’s an out-of-bounds error. Scratch out the broken line and fix it
f = pickAFile() picture = makePicture(f) makeSnazzy(picture) Oh no! It gives you an error! What error did you get? A) A local or global name could not be found B) Your code is not legal Jython. C) The parameter for a function called is incorrect. D) It’s a logical error. (It runs but doesn’t do what you intended it to do) E) It’s an out-of-bounds error. Scratch out the broken line and fix it
f = pickAFile() picture = makePicture(f) makeSnazzy(picture) Oh no! It gives you an error! What error did you get? A) A local or global name could not be found B) Your code is not legal Jython. C) The parameter for a function called is incorrect. D) It’s a logical error. (It runs but doesn’t do what you intended it to do) E) It’s an out-of-bounds error. Scratch out the broken line and fix it
f = pickAFile() picture = makePicture(f) makeSnazzy(picture) Oh no! It gives you an error! What error did you get? A) A local or global name could not be found B) Your code is not legal Jython. C) The parameter for a function called is incorrect. D) It’s a logical error. (It runs but doesn’t do what you intended it to do) E) It’s an out-of-bounds error. Scratch out the broken line and fix it
f = pickAFile() picture = makePicture(f) makeSnazzy(picture) Oh no! It gives you an error! What error did you get? A) A local or global name could not be found B) Your code is not legal Jython. C) The parameter for a function called is incorrect. D) It’s a logical error. (It runs but doesn’t do what you intended it to do) E) It’s an out-of-bounds error.
Scratch out the broken line and fix it
f = pickAFile() picture = makePicture(f) makeSnazzy(picture) Oh no! It gives you an error! What error did you get? A) A local or global name could not be found B) Your code is not legal Jython. C) The parameter for a function called is incorrect. D) It’s a logical error. (It runs but doesn’t do what you intended it to do) E) It’s an out-of-bounds error. Scratch out the broken line and fix it ANSWERS: 1. D 2. B 3. C 4. A 5. E 6. A 7. B 8. D 9. C 10. B 11. D