During the
second week of the GIS programming module, specifically in Exercise 2, we
focused on the foundational elements of the Python programming language. This
included working with various data types such as numbers, strings, variables,
and lists. We explored the use of functions, methods, and modules, and learned
how to save our code as scripts. Additionally, we practiced writing conditional
statements and employing loop structures.
Furthermore, we gained practical experience in executing a geoprocessing tool from the notebook that interacts with a layer in ArcGIS Pro. We also learned the process of incorporating existing code into the ArcGIS Pro Notebook by copying and pasting the code into a notebook cell.
This week’s lab assignment comprises four distinct steps.
In the first step, the task involves assigning my full name as a string to a variable. Subsequently, the full name should be split into individual components, resulting in a list of names. Finally, indexing techniques will be employed to extract and print my last name.
The second step involves working with a prewritten code that generates a list of players participating in the dice game. Upon importing the random module and executing the code, I encountered an initial error TypeError: can only concatenate str (not "int") to str. To fix this error I added str to word (dice). After rectifying this issue and running the code again, I identified a second error, which required changing a capital 'X' to a lowercase 'x'. After addressing these errors, the code executed successfully.
In the third step, a loop must be created to generate and add 20 random numbers, each ranging from zero to ten, into a list. Finally, the fourth step requires the implementation of a loop designed to remove a specified integer from the previously generated list and print the updated list.
Results from running the code:
In conclusion, completing the Lab for module 2 proved to be quite challenging, utilizing IDLE to compile the code in a separate script window was more efficient compared to ArcGIS Notebook and its cell functionality
No comments:
Post a Comment