Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GEOG 315, Lecture 3

alan.kasprak
September 13, 2021

GEOG 315, Lecture 3

alan.kasprak

September 13, 2021
Tweet

More Decks by alan.kasprak

Other Decks in Education

Transcript

  1. GEOG 315: GIS Programming and Web Mapping Lecture 3 –

    Errors For Today…a relatively short lecture Interpreting Error Messages Common Errors, and What to Do About Them
  2. Your code will absolutely generate errors! When it does… 1.

    Don’t freak out 2. Don’t mindlessly start changing random things and hoping something works 3. Learn to listen to what Python is telling you
  3. Your code will absolutely generate errors! When it does… 1.

    Don’t freak out 2. Don’t mindlessly start changing random things and hoping something works 3. Learn to listen to what Python is telling you Start reading here!
  4. Your code will absolutely generate errors! When it does… 1.

    Don’t freak out 2. Don’t mindlessly start changing random things and hoping something works 3. Learn to listen to what Python is telling you Start reading here! Sometimes, you’ll get the exact spot where an error occurred
  5. Your code will absolutely generate errors! When it does… 1.

    Don’t freak out 2. Don’t mindlessly start changing random things and hoping something works 3. Learn to listen to what Python is telling you Start reading here! Sometimes, you’ll get the exact spot where an error occurred You’ll always get the line number
  6. Six Common Error Types 1. Syntax Errors (and their annoying

    related friend, Indentation Errors) 2. Name Errors 3. FileNotFound Errors 4. Type Errors 5. Index Errors 6. Import Errors
  7. Common Error Type #1: Syntax Errors This is the most

    common type of error you’ll encounter! It happens when Python sees code that it doesn’t “understand” Fortunately, they’re the easiest errors to fix.
  8. Common Error Type #1: Syntax Errors This is the most

    common type of error you’ll encounter! It happens when Python sees code that it doesn’t “understand” Fortunately, they’re the easiest errors to fix.
  9. Common Error Type #1: Syntax Errors This is the most

    common type of error you’ll encounter! It happens when Python sees code that it doesn’t “understand” Fortunately, they’re the easiest errors to fix.
  10. Common Error Type #1: Syntax Errors This is the most

    common type of error you’ll encounter! It happens when Python sees code that it doesn’t “understand” Fortunately, they’re the easiest errors to fix.
  11. Common Error Type #1: Syntax Errors This is the most

    common type of error you’ll encounter! It happens when Python sees code that it doesn’t “understand” Fortunately, they’re the easiest errors to fix.
  12. Common Error Type #1: Syntax Errors This is the most

    common type of error you’ll encounter! It happens when Python sees code that it doesn’t “understand” Fortunately, they’re the easiest errors to fix.
  13. Common Error Type #1a: Indentation Errors For as “forgiving” as

    Python is as a programming language, it has no patience for bad indentation This will become extremely important beginning next week with loops.
  14. Common Error Type #1a: Indentation Errors For as “forgiving” as

    Python is as a programming language, it has no patience for bad indentation This will become extremely important beginning next week with loops.
  15. Common Error Type #2: Name Errors Occurs when a name

    (a variable or function name) is used that Python does not know about.
  16. Common Error Type #2: Name Errors Occurs when a name

    (a variable or function name) is used that Python does not know about.
  17. Common Error Type #2: Name Errors Occurs when a name

    (a variable or function name) is used that Python does not know about.
  18. Common Error Type #3: FileNotFound Errors One of two things

    has happened: 1. You’re referencing a file path that doesn’t exist (i.e., you’ve got a typo) 2. You’ve misplaced a file and it’s not where you think it is Case 1: you’ve got a typo Case 2: no typos, but there’s actually no folder called “test_folder”
  19. Common Error Type #4: Type Errors You’re trying to apply

    a function to a value… but that function won’t work on that particular value type.
  20. Common Error Type #4: Type Errors You’re trying to apply

    a function to a value… but that function won’t work on that particular value type.
  21. Common Error Type #4: Type Errors You’re trying to apply

    a function to a value… but that function won’t work on that particular value type.
  22. One Exceedingly Annoying Instance of Type Errors ‘Object not callable’

    errors This cell sets up the VARIABLE called list This cell sets up the VARIABLE called list (but notice that list is in green)
  23. One Exceedingly Annoying Instance of Type Errors ‘Object not callable’

    errors Then I run this cell, which calls the FUNCTION list() to make a list of fruits This cell sets up the VARIABLE called list (but notice that list is in green)
  24. One Exceedingly Annoying Instance of Type Errors ‘Object not callable’

    errors This cell sets up the VARIABLE called list …and Python doesn’t know the difference Then I try this cell, which calls the FUNCTION list() to make a list of fruits This cell sets up the VARIABLE called list (but notice that list is in green)
  25. Tricky Concepts from Last Week 1. ‘Object not callable’ errors

    Don’t use function names for your variables Python will let you do this, and it can be dangerous. This cell sets up the VARIABLE called list produce This cell calls the FUNCTION list()to make a list
  26. Common Error Type #5: Index Errors Your code is attempting

    to access a location within a list or string that’s out of range.
  27. Common Error Type #6: Import Errors This one’s pretty simple,

    you’re trying to import a module that doesn’t exist.
  28. Common Error Type #6: Import Errors This one’s pretty simple,

    you’re trying to import a module that doesn’t exist. Typo in module name
  29. Common Error Type #6: Import Errors This one’s pretty simple,

    you’re trying to import a module that doesn’t exist. Typo in module name Are you off campus? Are you not connected to VPN?
  30. Public Service Announcement #2 Comment your code! These two scripts

    produce the same error But one is much easier to understand than the other …and will get you more credit.
  31. Lab #3: What to Expect 1. Two Jupyter Notebooks 2.

    Three Homework Problems 3. Three StackOverflow Posts Turn these in as a single .zip file (“week-3-jupyter-YourInitials.zip”) Turn these in as a single .zip file (“week-3-homework-YourInitials.zip”) Next week’s lecture is the most important of the class! If things don’t make sense this week, ask me! – because things are about to pick up in a hurry. There will be no new material this week! We’ll reinforce basic Python to make sure everyone is on the same page before things ramp up next week.