Building My Toolkit is a series in which I explore my learning of various tech and data tools. Ultimately, my goal is to incorporate these skillsets in my role as a student affairs practitioner. Each week, I discuss the progress I’ve made with a particular tool, currently the Python programming language.
The last week or so has been a really exciting time in my fledgling programming career. The programming problems that I’ve been working on out of the Python Crash Course have become noticeably more complex, offering many possibilities for how to tackle a given program. I’m particularly excited that I got to tackle if statements this week, as they are a great supplement to for loops. In addition, they let me know that tackling while loops isn’t too far off on the horizon.
If statements are pretty straightforward — they instruct a computer program to execute a command if a certain condition is met. The below code snipped illustrates a rather simple usage of an if statement.
for student in student_list:
if student_age
print("This student is underage!")
else:
print(student_name)
The above snippet would loop through a list of students and print the name of each statement. The use of the if statement here directs the program to let me know if a student is underage. This is a simplistic snapshot of some of the backend logic with Maxient, Advocate, and other conduct management software programs.
Another example of if statements working behind the scenes is the condition feature in Excel. As higher education administrators, we practically live in a world of spreadsheet at times — or so it feels. A simple if statement helps on the backend of Excel to check whether certain cases are true.
I could also use pseudocode — a high-level outline of a computer program or algorithm to show what the programming logic for a simple conditional formatting might look like.
# Pseudocode that outlines the logic for a basic conditional formatting # operation in Excel Loop through each cell selected by the user Loop through each cell selected by the user For each cell: if the cell == null # Meaning that the cell does not contain any value Change the cell shade to light red else: Change the cell shading to light green
In my studies from the past week, I also explored dictionary data structures, which are used to connect related pieces of information. For example, I could create a dictionary of student development theorists and connect the theorists’ name to their respective theory as follows:
theorists = {
'schlossberg': 'transition theory',
'kohlberg': 'moral development',
'chickering': 'seven vectors',
'sanford': 'challenge and support',
}
At their core, dictionaries are composed of key-value pairs. Essentially a key-value pair is jargon for two pieces of data that are connected. The above example is a dictionary called ‘theorists’ and contains a total of four key-value pairs. Each pair of data is conjoined with a colon, with single quotes used to set off each piece of data. Dictionaries are nifty in that their functionality can be scaled up in a number of ways. For instance, we could use a list to associate a number of theoretical ideas with a particular theorist. Let’s revisit Schlossberg’s transition theory. Instead of having one value associated with the key ‘schlossberg’, we could associate the four S’s of her theory with the same key.
'schlossberg': ['situation', 'self', 'support', 'strategies']
I could go on down the rabbit hole of possibilities with dictionaries, but I think I’ll stop there. It’s exciting to be getting to a part of my programming journey where there are more nuanced decisions to be made about how I approach a given task. I think my next post in this series will be a real treat! I hope you’ll join me as I look at some more programming logic, building some nifty programming blocks, and how to take user input right from the keyboard.
Thanks for reading,
Joe
Are you interested in giving programming a try for yourself? Check out this link for a brief Ruby tutorial. Ruby is a high-level programming language that is similar to Python. Let me know if you got the chance to check it out!
Let’s connect on Twitter @joe_diodato.