Let’s Learn Python!

posted in: Programming 0

Python Logo

Unbeknownst to me ’till recently, Google provides an excellent (and free) introductory class for learning Python, which you can find right here. I found the link via Reddit and decided that after a solid week of reaping the benefits of Steam’s holiday sale, this was a perfect excuse to get back to programming.

Python is a high level, dynamically-typed, interpreted language that is well documented, open source, supported on almost all operating systems, and perfect for rapid prototyping or development of small applications (though it certainly isn’t limited to just those).

If, like myself, you’re primarily familiar with programming languages in the C family (or any of the many other languages with C-esque syntax), Python code may look rather strange upon first glance. Take the following “Hello World!” example :

[python] def main():
displayText = 1 # Integer / boolean variable
if displayText:
print “Hello World!” # Print string
else:
return displayText # Return a value
[/python]

C programmers will immediately notice that:

  • The example function doesn’t specify a return type.
  • There is no explicit declaration of variable types.
  • There are no curly braces to separate blocks of code.
  • There are no parenthesis for conditional statements such as if.
  • There are no semi-colons to delimit end of lines.

Python relies on white space (and colons) to indicate blocks of code. Good programmers always indent their code whether it’s required or not, so the creators of Python exploited this fact and simplified Python’s syntax to actually make use of all that beautiful tabbing we’re so used to putting in our code.

This is all explained very clearly by Nick Parlante in Google’s Python class, which contains seven videos along with related reading materials and exercises. You can find links to everything (plus instructions on setting up Python) here. The first video in the series is also embedded below:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.