Posts

Showing posts from May, 2023

Handling Debugging in Python

Image
  This week has left me feeling much more confident in my ability to code. We learned about common error messages and how to handle them through a process called debugging. We were given three pre-made scripts and were tasked with finding and debugging the errors.  The first script included simple syntax errors, which are errors in the convention of the coding language. These commonly include misspellings, incorrect upper or lowercase usage, missing punctuation, or incorrect indentation. Below is a screenshot of the script output after correcting for syntax. The next script was much more challenging. There were multiple syntax errors but, after these were corrected, the script returned with an exception error. Exception errors occur when the script is able to run correctly but something "unexpected" happens. These can be caused by empty feature classes, incorrect work environments, or strange user input. Exception errors can be "trapped" with try-except statements.

The Fundamentals of Python

Image
We slithered right into Python this week by creating our own code (or "script") that incorporated many of the basic elements of coding. Through the use of lists, methods, and loops, we created a script that printed out the following: The first line is the output of selectively picking an element from an index (a numbered list), which in this case was our full name. We had Python select only the last element in the list and print the output. Next, we had to inspect a given piece of code and had to identify and correct the errors to produce a dice game.  Lastly, we were tasked with a multitask script. It had to first generate a randomly populated list of 20 integers between the numbers 0 and 10. Then it had to identify the number of times a selected integer was found within the list, print this information, and recreate the list without the chosen number. This was definitely the most challenging aspect of the module as it incorporated every skill learned this week. Structuring

Introduction to Python

Image
As an introduction to Python, which is a computing language that is embedded in ArcGIS Pro, we were tasked with creating a flow chart and pseudocode for converting radians into degrees. Flowcharts are a visual method of planning, which is an especially important process to complete before delving into complicated code. Flowchart created in iodraw.com The aim of this exercise was to introduce us to calling up IDLE and ArcGIS Notebooks. IDLE looks like the stereotypical coding interface with its intimating emptiness and blocky text; whereas Notebooks is nearly the opposite with its bright, white interface, menu options, and bubbly outlining. Both programs act as language interpreters for the Python coding language, converting user commands into binary which is then read and executed by the computer processing system.