Thursday, August 27, 2009

Exercise 1.11: Question 2

Start a Python shell. Type 1 + 2 and then hit return. Python evaluates this expression, prints the result, and then prints another prompt. * is the multiplication operator, and ** is theexponentiation operator. Experiment by entering different expressions and recording what is printed by the Python interpreter. What happens if you use the / operator? Are the results what you expect? Explain.

Having done this a few times before I had a pretty good idea what would happen. I suppose the idea is to first of all teach how a coder can use the interactive prompt to test things out, experiment, and just play. Secondly it leads to a few revelations about how math works in Python, specifically what happens when you divide integers as opposed to floats. Info below:

Exercise 1.11: Question 1

Write an English sentence with understandable semantics but incorrect syntax. Write another sentence which has correct syntax but has semantic errors.

Syntax error: !@I&can&has&cheeseburger?#%

Semantic error: Purple instant cheese insane.


And so it begins....

I've coded to some extent for a long time. A little Perl in 9th and 10th grade (1998 or so), Visual Basic junior year of high school, then Visual C++ in a senior year programming class. College saw quite a bit of coding, but to be honest I never had projects I really wanted to complete, and so things never stuck. At this point I can read code, even put together a few basic procedural scripts, but I've never felt like I could truly call myself a developer.

Picking up on language syntax isn't really the problem. For the most part I find the hardest time are deciding how to design and build my applications. I find most of my time is spent going "do I need class variables or should I just push this to the database?" or re-factoring code I thought was working just fine. I feel it's safe to consider myself a "programmer" but not really a "developer". I have plenty of ideas for code, I can imagine big pieces of it in my head, but I find even basic design decisions can perplex me. I realize part of this is a lack of experience, and part of it is a lack of education, but either way they're problems I'd like to correct.

I'm out to change that. For the past few years most of the code I've written has been Python. It's the language I have my head wrapped around the best, so it seems like a natural place to begin as I improve my development skills. I have a number of ideas, but my first one is going through the How to Think Like A Computer Scientist: Learning with Python v2 workbook. Lots of it should be a review, but some of it should be helpful. At the very least there's plenty of examples. My goal is to use this blog, go through the exercises and chapters, and post the results. We'll see where I go from there, but it's a start. First chapter is done (reading wise) and I'm gonna follow this post with the answers. Enjoy, post questions, pick on me, whatever.