Wednesday, May 31, 2017

GIS Programming (GIS5103): Module 2

In this week's module, we learned the first part of Python Fundamentals which covered the basic uses of Python syntax that included assigning string variables, using methods and functions to manipulate strings and lists and performing basic math function with Python. The image above is the screenshot of the end result of the script that I created that print my last name and a number that equal to three times the number of letters in my last name. 


I wrote out the line of command on pen and paper so I could manipulate the physical and copy the line of code into the computer.  I began with the stringName command which was stringName = “Tara Ashley Scranton”. I followed this code with stringName.split(“ “) and this created the listName. I needed to have my last name printed so I used this line of code (lastName = listName[-1]) which brought up Scranton. To create the number value to my last name, I counted the letters in my last name and multiply it by three. Code was written as so:
lastNameLen = 8
tripleLastName = lastNameLen * 3
 



No comments:

Post a Comment