Monday, January 5, 2009

Scripting Saves Students

So I don't know if anyone really knows, but I am in love with scripting languages. I don't know why. However, I do believe it is partially due to the fact that the first programming language I ever messed around with was Python, which is so clear, so easy, so simple, and so powerful. It makes for some useful scripts.

Well, I just ran a tiny tiny tiny script for myself a few moments ago. I figured I'd post it up here just for fun. It's really not complex... It is a total of two lines.

Essentially, I'm working on some Algebra 2 homework, and we're doing factoring of cubes and using the differences/sums of cubes. However, I don't have any of the roots memorized. So everytime I get 343 I have to try and figure out what the cubed root of that particular number is. (Substitute whatever cubed number you want).

So, to use as a reference and to save time, I wrote myself a tiny script and ran it in my Python interpreter up on the Linux-Box.

here's the contents of my source file (very simple)


for i in range (1,21):
print "%d cubed = %d" % (i, i*i*i)


So that is my tiny script. But it is a very handy reference for this homework. And isn't the point of effective coding to make short, easily understandable/maintainable code that does what you need? I believe I hit proverbial nail on the head.

Also, I am very happy to finally have posted a bit of code on my web log that is in fact about code. It is slightly amusing. Of course I have written a fair amount of HTML code. All the links and different text formatting was created by hand by me in the process of posting.

So thank you for reading, and now I depart. Midterm examinations are upon us, and I fear I need a refresher of some more Algebra.

No comments:

Post a Comment