What I Learned In Python This Week #1: First Impressions

My goal with the “What I Learned” series of posts is to give a rough overview of my skill progression in programming various languages (currently Python) that I can use both for personal edification and for a benchmark of my progress. (And yes, this post is more like “this month” than “this week”, but that’s what I get for coming up with ideas too late 😛 .)

Tools I Used:

  • Geany
    • Geany is a really nice text editor focused around Python development (kind of a mini-IDE).
  • IDLE
    • I haven’t used it much, but so far IDLE seems to be nicer than a plain Python shell because of highlighting and a potentially useful (but ugly) GUI interface. Probably has many cooler features that I will explore later.
  • Python shell / bash shell
    • I use the Python shell to use Python interactively (you know, like testing the print “Hello, World!” command to see how it works) and I use bash to execute my scripts.

Accomplishments:

  • Hello, World! (hello.py, hello.v1-1.py)
    • Hello, World! is my first program, and an exercise in using the print and raw_input functions of Python.
  • Date Translator (date.py, date.v1-1.py)
    • Date Translator is my second program, and is an exercise in more complex processing techniques by converting strings/integers and using lists.
  • A slightly better understanding of Python 😉

Functions/Concepts I Learned:

  • print, Strings, and Integers
    • The print function is linked (in my mind) with strings and integers because it is used to print strings and/or integers on your computer’s screen.
    • Strings are, well, strings of data. They can be text, special characters, numbers, command characters, or even a string made of other strings. Strings are the bread and butter of programming because of their versatility and usefulness for holding/representing data. You can use str, repr, and `` (backticks) to convert data to a string.
    • Integers are numbers. You can use basic math operators (+, -, /, and *) in Python by default, and you can load the math or cmath modules (more on modules later) to do more complex operations with integers. You can use int to convert numerical data in a string to an integer.
  • Variables
    • Variables are extremely powerful tools. They are somewhat like desktop links to a program or document in that they do not mean anything by themselves, but they refer to something else. This means their use is only limited by your imagination (and your precision in typing skills after n cups of coffee late at night 🙄 ).
  • input and raw_input
    • Get input from your user! Mostly raw_input is better because input acts like the user is at a Python shell and interprets their input like a Python statement, whereas raw_input just converts their input into a string.
  • Lists
    • Lists are basically sequences of data. You can use them to store preconfigured data or user input. I’ve yet to get a handle on them entirely, so that’s all I’m definitely sure of so far 😳 .
  • Algorithms/Programs
    • For the purposes of the small programs I’ve written so far, these are basically the same. An algorithm is the method/steps you use to solve a given problem; a program is a particular implementation in code of one or more algorithms.

I’ve both learned a lot and not much at the same time. These are basic concepts to computer programming, and are therefore very powerful tools, but I haven’t learned much about how to put them together to write programs much bigger than a few dozen lines… yet.

Right now I feel a lot like when I’m learning the alphabet for a foreign language: I’m learning basic, super-essential things, but it’s kinda boring to slog through them at first and (seemingly) not very useful because I don’t yet know the specific vocabulary, grammar, semantics, context, etc. which would let me know how to practically apply them. Oh well, soldier on!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s