Friday, February 09, 2007


I decided to go ahead and do Python versions of the programming assignments. I updated the ATM and Text Manipulation assignments to include Python versions. This is my first programming with Python. It seems pretty clean so far. Obviously it is similar to Ruby. It seems a little more procedural (lots of standard functions like ord(), len(), str()) whereas Ruby tries very hard to be object oriented. I think it is possible to be more OO with Python and more procedural with Ruby, but I'm not good enough at either to do so!

Python includes it's own IDE, IDLE. It seems pretty nice. I'm not sure how well it would work on a large project with many Python scripts/classes. I've been using Eclipse for Java and Ruby, and using Visual Studio for C# and C++. For easy things like these assignments, Eclipse is definitely the biggest pain to use...


Carlo Oliveira said...

Just for fun, here is a "one liners" version of the text assignment:
print "Upper: " + text.upper()
print "Lower: " + text.lower()
print "Vowel Count: %d"% sum(1 for letter in text if letter in 'aeiou')
print "Consonant Count: %d"% sum(1 for letter in text if letter not in 'aeiou')
print "Reverse: " + text[::-1]

Unknown said...

Very cool. There are one liners, are pretty close, for each language actually. I think each language have the upper/lower methods on their string objects, for example. I didn't think the use of these methods would teach a new student.

I do like the text[::-1] for Python. I was not aware of this feature. I like your vowel/consonant count solutions, too. I thought about using a closure for this, but again I don't think I would expect that of a beginner student.