Posts

Showing posts from May, 2023

GIS Programming Module 2 – Python Fundamentals

Image
  Module 2 assignment covered some of the fundamentals of Python. This included learning about the different Python data types, working with string variables, understanding loops and conditional statements, and iterating through variables.   The screenshot below shows the output of the script written for the assignment. Step 1 was to create a variable to hold my full name separated by spaces, split the variable using the spaces, and then print my last name using the index -1. The index -1 is the last item in the list which was my last name. Step 2 was to fix two errors in the code that was provided. The code uses a list of the first names of players and calculates the number of characters in players’ name. Each player rolls a dice which is randomly selected from a list of integers from 0 to 2 times the number of characters in the name. Players win if the dice is greater than the number of characters, tie if they are equal, and lose if the dice is less than the number of character

GIS Programming Module 1 – Python Environments & Flowcharts

Image
Module 1 examines “The Zen of Python” which is a poem by Tim Peters a software engineer. This poem can be seen by typing “import this” into any Python interpreter and describes what it means to write Python code. “The Zen of Python” is the principals or guidelines on how programmers should write code. These principles suggest to me that we should write code in a way that is easy to read and understand, even though the code may be complicated. I see this as writing code that is modular where the complexity can be broken down into smaller functions that do a specific task. Complexity can also be handled by simplifying the code, by finding ways to reduce the number of lines it takes to accomplish the same task. We should follow these principles not only for others who might later need to interpret the code, but for ourselves to help us in debugging and future alterations. It is up to the programmer to write code that provides the required functionality, but they should make a conscious ef