Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 18 Online
OpenStudy (anonymous):

Problem Set 5: Wordgames Attached are my answers. Please note that I "upgraded" the code so that it works with Python 3.2. I did not test them on 2.7.x. One notable change is the raw_input function.

OpenStudy (anonymous):

Hope this helps.

OpenStudy (anonymous):

don't forget to close an open file object before leaving a function (load+words) here is another way to do is_valid_word, samething but different: http://dpaste.com/729354/

OpenStudy (anonymous):

bwCA can you please expand on the "close an open file object before leaving a function". As from returns from functions I tend to prefer one return function at the end which I why use flag variables. I tend to be a strong believer in defensive programming and want to protect against having an exit point that's not covered. In Visual Studio the IDE automatically checks to ensure that all exit points return the expected data type. I miss that option in Python.

OpenStudy (anonymous):

bwCA you look like an old timer in Python. How long have you been hacking at this language? I would like to eventually move on to Android development with this language (simple stuff - mainly calling soap methods on a server). I'd appreciate your thoughts on the matter.

OpenStudy (anonymous):

i started the course some time ago but didn't finish the last few lectures. I like to hang out here because it helps me learn by answering questions and seeing how other people approach problems. I really like Python. I've become interested in functional programming and am starting to learn Scheme. the open function returns a file object. you should close file objects if you are done with them and not rely on 'garbage collection' - i don't really know why but have read many things that say that - 'They' even added an idiom to python that will ensure it gets closed, so it must have been causing some amount of havoc. that idiom is: with open(file) as f: do stuff when the with is exited, the file gets closed here is one related post on another forum http://stackoverflow.com/questions/1834556/does-a-file-object-automatically-close-when-its-reference-count-hits-zero

OpenStudy (anonymous):

Prefessionally today I work with a DBMS called Cache. It's great ansestor was a language called MUMPS. Cache is an object oriented database with its own scripting language that incorporates a number of OO functions. Most of my programming carrier has been in the financial/automotive industry. I'm familiar with the with clause in languages such as Pascal and C#. I didn't know Python had it though. Google have a few hours on Python. Have you seen any of them?

OpenStudy (anonymous):

I didn't understand - Google has a few hours of Python?

OpenStudy (anonymous):

They have a tutorial spanning a few hours on Python programming (I was using short circuit statements :-) @ http://code.google.com/edu/languages/google-python-class/

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!