This week, we explored the relationship between Python's
interpreted nature, its design philosophy, and how simple visual tools like
flowcharts can support clear and effective programming.
Interpreted Nature of Python
Unlike compiled languages such as C++, Python is interpreted,
meaning it runs source code directly without needing to be converted into a
separate executable file (Zandbergen 2024). Code is executed line by line,
which makes Python especially useful for writing, testing, and debugging in
small increments. This flexibility supports a more experimental, hands-on
approach to learning how to code.
The Zen of Python
The Zen of Python by Tim Peters offers guidelines for
writing clean, readable code. While I may not fully embrace phrases like “Namespaces
are one honking great idea”, I do appreciate the overall message: code
should be simple, concise, and easy to understand.
As an archaeologist working in a field filled with
complexity and ambiguity, I often rely on clear language to explain nuanced
results. If I can’t make my interpretations understandable, I haven’t done my
job. This same value applies to scripting: even when the process is complex,
the script should be readable to others.
Thinking Algorithmically with Flowcharts
To practice algorithmic thinking, I created a flowchart to
convert 3 radians to degrees using the formula:: degrees = radians * 180 / pi
(Figure 1).
Figure 1
It begins with a Start symbol, assigns the value 3 to
the radians variable, the value of pi, and then performs the calculation degrees = radians *
180 / pi. The result is then printed using an output symbol, and the flow
stops with an End. I used standard flowchart symbols: ovals for
start/end, rectangles for assigning vales and processing, a parallelogram for output. This simple
visualization mirrors Python’s top-to-bottom execution and reinforces the
importance of sequential logic. The code itself was simple and clear,
conforming to the guidelines of the Zen of Python.
I tested the calculation in ArcGIS Notebook (Figure 2). At first, I ran
into a syntax error due to a missing set of parentheses in the print function.
It was a helpful reminder that Notebooks are excellent for catching errors
quickly and providing feedback. Once corrected, the output was accurate: 171.88733853923566.
Figure 2
This module reinforced the value of Python's interpreted environment for testing and refining code, and the usefulness of simple visual tools like flowcharts in early-stage programming.
No comments:
Post a Comment