Friday, May 29, 2015

GISProgramming: Module 2 - Python Fundamentals Part 1

     This week we looked at the basic building blocks of Python. Specifically, we combined variables, strings, functions, and methods to write simple code. The script, if successful, prints a given last name and the result of the number of letters in a last name times three (expressed as an integer).
     I think my first instinct was to panic about writing code on my own, albeit simple code. I then remembered what we learned the previous week regarding a logical way to tackle programming. That is, defining the information given , sorting out the goals of the program, and thinking about what tasks will help in achieving the aims of the program. Also, I realized that this program wasn't so bad. In fact, as I looked over what needed to be done the wheels in my head were already turning with how to go about writing this program.
     This may not be efficient in the future but I wrote pseudocode on paper first. I then tried out portions of the code to test them in the Python window of ArcMap. Once I felt like I had it down I composed the final script in PythonWin. You can see a screen shot below showing the result of my script.

This is a screenshot of the result of the program composed for this exercise.
The program prints my last name and the integer value of the number of characters in my last name times three. 
     This was a simple program to write but it is exciting to write code and have it work. I do not mind these ego boosting baby steps. I cannot wait to feel the sense of accomplishment that will come with having finished an entire semester of programming.

No comments:

Post a Comment