Monday, July 13, 2009

PP: AItCSUP: Chapter 2

In the second chapter of the book, the Pythoning begins. The idea of the book is to give ongoing information about computer programming throughout, but the programming itself begins here.

The chapter started off by explaining, on a broad level, the macro of how a computer works: on the most basic level is the hardware, which materially the machine is. Next, the operating system is that which directly interacts with the hardware; all that is above the OS needs to go through it, or operate using it, to do anything with the hardware. The OS and the various other entities above it that do things are all programs, but the book outlined how the OS is the only one that calls the shots (has direct access to the hardware).

Next, the chapter went into some math. The math here wasn't extremely complicated (BEDMAS, modulo, rounding, integers and floating point numbers), but the information was more about how Python dealt with the numbers than how a person would, presented on a sheet. For instance, Python before 3.0 (apparently the later versions of 2 are still used more) will round down (take the floor value) of integer division. On the other hand, it will divide floating point values as closely as it can (it will also always convert integer values to floating point values when the two are in the same expression; I'm guessing that integer values are only used when it's strictly certain that the rest or the real numbers aren't needed). After that, it went into using variables on top of the math, and then how Python treats variables (again, not quite as one is supposed to use them generally). A short interlude with basic error messages came (there was one before too), and then the book got into functions.

I was pretty interested with this part. It took all of the previous math information, with variables, and then added defining and using functions to it. At this point, one might not right much of a program yet, but they (I) could make a list of variables and functions at this point; I was OK with not knowing how to right an even mildly sophisticated program after the first chapter, but I was glad the learning curve wasn't very wrathful (maybe I want a straightforward learning experience... sue me). The chapter finished with a few paragraphs on style (there are myriad forms, and the books advice was to use some kind of procedure with a few broad tips; however, if people argue that there is one style out there to rule them all, then hound them for actual proof). Finally, there was a summary of the chapter (which I didn't read before writing this-- honestly!), and a section with exercises. The chapter's title was 'Hello, Python!', and in the way of Python's own developers, they made sure to include well known lines from cultures of varying popularity almost wherever there was a code demo with words. More on the book later, which is hopefully sooner; I was supposed to update this daily, but I doubt that's a pattern I'll settle into (maybe my dad meant that I was supposed to at least add to a post daily, which sounds manageable).

No comments: