September 2018

Python Programming Fundamentals teaser image
This post is a beginner Python developer resourse dump, and also loosely follows the content of Programming Foundations: Fundamentals on Lynda.com except in Python instead of JavaScript. I only recently discovered that one of our many perks as Aggies is access to Lynda.com's video library, when Dr. Jasperson recommended it for ISTM 615 Business Database Systems. Did you stumble on to this post when you're not an Aggie yet? Don't fret, mosey on over to grad.tamu.edu/academics/program-directory or for more information read about our offerings. I was a distance education student myself working full time, and I highly recommend for anyone in a similar situation.

This post was inspired by Hadley Wickham's notion that "Context-switching is expensive." I have found that statement painfully true from my own experiences as well. To quote from his book, R for Data Science,
You will get better faster if you dive deep, rather than spreading yourself thinly over many topics.
Programming Foundations: Fundamentals, chooses to use JavaScript in its examples. I understand how it would be difficult for a beginner to context switch from JavaScript to Python (once the semester starts). I figured since I am learning Python as well, why not document what I've learned as I go? So here goes. Please note that I am loosely following the videos and this is a learning experience for me as well.

To start, I know that not everyone here is going to be in ISTM 615 or an Analytics major. So here are some free, highly recommended Python resources if you just want to learn Python:
  • Python's documentation - an up to date and freely available resource. The secret to success in any technology field? Read the manual! The documentation is almost always the most current and accurate source of information.
  • Al Sweigart's Creative Commons books, most notably Automate the Boring Stuff with Python is recommended often.
  • One of these days I'll do a comparison between his selection.
  • Welp. I take that back. Learn Python the Hard Way USED to be free. Luckily for us we have library access to the full version of the book.
  • While it's not exactly Python, I have seen edx.org's CS50's Introduction to Computer Science highly recommended on the internet among beginner programmers. My favorite thing about the course is it appears to be updated yearly.
Before We Begin: The purpose of this post is supplement, not replace the Programming Foundations course, so the code snippets probably won't mean anything to you out of context. Please follow along with Programming Foundations: Fundamentals if you are going to continue. To run the code snippets, press the green "Run" button to see the code in action. If you open the snippet in repl.it, you can edit and run them to your heart's content. If anyone sees something that they think could be done better or if anyone has other favorite Python learning resources please share in the comments below!
 

Chapter 2: Core Programming Syntax

Reference: https://docs.python.org/3/library/functions.html#input
 

Chapter 3: Variables and Data Types

Reference: https://docs.python.org/3/tutorial/introduction.html
 

Chapter 4: Writing Conditional Code

Reference: https://docs.python.org/3/tutorial/controlflow.html

Chapter 5: Modular Code

Reference: https://docs.python.org/3/tutorial/controlflow.html#defining-functions

Chapter 6: Iteration: Writing Loops

Reference: https://docs.python.org/3/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops

Chapter 7: More About Strings

Reference: https://docs.python.org/3/tutorial/introduction.html#strings
Regular Expressions: https://developers.google.com/edu/python/regular-expressions

Chapter 8: Collections

Reference: https://docs.python.org/3/tutorial/datastructures.html
See Also: https://docs.python.org/3/library/array.html

Chapter 9: Style Guidelines

Reference: https://www.python.org/dev/peps/pep-0008/
We already talked about Pythonic code. PEP 8 is currently accepted style guide. Brace style is a hotly debated topic and IMO it just depends on your personal preference. Usually a good text editor or IDE will minimize confusion and maximize readability despite your personal preferences.

Chapter 10: Input and Output

Reference: https://docs.python.org/3/tutorial/inputoutput.html
JavaScript is more commonly used than Python in web development (and my preferred scripting language for web dev as well). Nothing to add for the web development section. I'm going to skip this section as well since repl.it is a cloud IDE.

Chapter 11: Into to Debugging

Tracing and commenting are certainly useful. But debug mode and unit tests are so involved that they are their own topic (and even career). I don't know which IDE we will be using in class yet, so no point in elaborating too far. I enjoy Visual Studio Code a lot but it seems like Jupyter Notebook is more widely used in the data science field.

Chapter 12: Into Object Oriented Languages

Reference: https://docs.python.org/3/tutorial/classes.html

Chapter 13 & 14 Advanced Topics

As mentioned in the course, when done well C is incredibly useful for efficient memory management. One of SAS's greatest advantages is its ability to handle big data and large data sets. I recently discovered that SAS is written in C, which would explain its speed advantage over its competitors.
In 1985, SAS was rewritten in the C programming language. - https://en.wikipedia.org/wiki/SAS_(software)

As another example to illustrate these last two lectures, Hadley Wickam, prolific author of wideley used R libraries, published freely available books Advanced R and R Packages. Both books cover techniques that connect R and C++. His libraries (my favorite is a package collection called tidyverse) is incredibly efficient.

To highlight the importance of packages, R will choke/freeze/take forever on large data sets but teams of programmers are constantly working on R to make it better. Matt Dowle et all's library package data.table package reads large files in a fraction of the time using the fread() function.

You may wonder why I'm not using SAS even though I love it so much. SAS is expensive, closed source software that my current employer doesn't own. Regarding concerns that open source R and Python will overtake SAS in popularity... You heard yourself in the video series established languages like Fortran and Cobol are still widely used despite their waning popularity. I anticipate the same will hold true for SAS. SAS has been the industry leader for decades and other languages will have a lot of catching up to do both in infrastructure and maturity. SAS's power and complexity is one of the reasons why it is still the industry standard and a valuable skill to have. Regardless, one can never have too much knowledge. Even experienced SAS programmers will sometimes go to R for certain tasks, and it is beneficial to know the basics of all three of these languages.

Quick learning resource honorable mentions (paid resources), Muarch's Python Programming is oftenly highly recommended as a great Python resource, and it's unfortunately not in TAMU's library. Learn to Code the Hard Way's recently released C programming book has the description Learn to think like the computer hates you, because it does." Which is simply hilarious. You'd understand if you've ever worked with C. I'm notoriously bad at finishing all the programming books I horde but if I ever get around to them I'll definitely write about it.

I hope this post was helpful! I'm also a Python newbie so feedback is appreciated from anyone more experienced.

---
Jennifer Cai
Jennifer is a Masters student in the College of Science's Analytics program.

Related Content

Explore Grad Aggieland

News

Texas A&M 2024 Three Minute Thesis (3MT®) Finals: Graduate Students Compete in Annual Research Presentation Competition

Eight doctoral students and three master’s students had top scores at the Three Minute Thesis (3MT®) preliminary competition on October 24 and 25 and will move on to compete in the finals on November 12. At stake is $4,000 in prize money in master’s and doctoral divisions and, for the overall winner, the opportunity to represent Texas A&M at the Southeast Regional 3MT competition in March 2025.

View All News
Blog

Miniature Dreams, Miniature Deaths: Life on the Academic Job Market

I am currently on the academic job market, slowly filling out applications for jobs all across the country. Every single time that I apply to a job, I fall in love with the school and the place before I hit submit. My mind wanders and I begin to daydream about what my life would look like in these places, and I have hope that my application will stand out and help make my daydream a reality. That is why, every single time that I do not get an email back my heart breaks just a little.

View All Blogs
Defense Announcement

Science Communication at Nonprofit Organizations

View All Defense
Announcements