Module Two Python Fundamentals

 Here we are in Module 2 of GIS programming and for most I believe this would just be the start of stepping into the shallow end of the pool. However, for me I felt as if I dove into the deep end. Luckily there are many recourses for learning and understanding Python. In this module we covered methods and functions, if-elif-else statements, for/while loops, variable and list assignments.

Some of the learning outcomes of this module include: To be able to run a python script using notebook in ArcGIS Pro, including comments in the script, the ability to save the Python code as a script and create loops and conditional statements.

We were tasked with writing code and editing a section of an already completed section of the code. the code we were creating was broken into four different steps. The start of the code was printing our last name from a created list. Which wasn't too bad, then we moved onto step two fixing errors within a prewritten code for a dice game. This was challenging for me, I was stuck on this step for a good amount of time. I was using both notebook in ArcGIS Pro and IDLE to check my work. I knew what was wrong but struggled with how to properly fix it. It really came down to me rereading chapter four many, many times for it to click. My fellow classmates were a huge help with providing some hints of where to focus on in the book Python scripting for ArcGIS Pro. I definitely felt as if I was drowning, but through the help of others and persistence I was able to stay afloat. Then came step three, I'm feeling a little more confidant and then down I started to go again. With this step I really had to rely on the internet, thankfully there is so much out there to help you have a better understanding of how to work with Python. In step three we needed to create a loop that adds 20 random numbers between zero (0) and then (10) to a list. We did have the help of a template that we were following to guide us through the step needed to create this section of coding. One of the major learning points I received from this was spellcheck, spellcheck, spellcheck. Remembering that Python is case sensitive, forgetting to complete your statements is a big no, no. You need to make sure your statement placement is in correct order. Make sure there are no unwanted spaces. All these little things can cost you a lot of time and headache. Finally, the last step and somehow, I am still afloat one might say I might even be dogpaddle at this point. In this step we needed to create a loop that removes a chosen integer from the list previously generated. In this section of the coding, we needed to use an if-else statement followed with a while loop and remove method. I have to say taking each step at a time and then running it to check for errors before moving on is very helpful. If you write everything first and run it and then you end up with several errors it is much harder to pinpoint the errors and correct them. I found that the book was very helpful throughout this whole process. If I needed a little more clarity I would look up YouTube videos to explain it further. I have shared the outcome of the final script and a flowchart of the process below.



Comments

Popular Posts