Monday, October 26, 2009

To be noted...

how to organise your program...
  • use 4 spaces for indentation
  • imports should go at the top of the file
  • separate function definitions with two blank lines
  • keep function definitions together
  • keep top level statements, including function calls, together at the bottom of the program
rules of "and" and "or" operators...
  • all values are true: 
    and returns last value
    or returns first value
    • false and true values: 
    and returns the first false value
    or returns the first true value
    • all values are false:
    and returns first value
    or returns last value

    Quarter Goal

    I didn't really set a specific goal at the beginning of the quarter because I didn't really know what to expect from the book we're reading. My goal was just to get as far as I could. In that aspect, I think I've done pretty well. I've finished chapters 1 through 4 and should be done with chapter 5 by the end of the week. Based on my experiences from this quarter I think I'll be able to complete chapters 6 through 12 by the end of next quarter.

    Tuesday, October 20, 2009

    Exercise 4

    These are the chapter 4 exercises http://docs.google.com/View?id=dgc44sfk_67dvd5fxf6, I had some fun positioning the houses, but I couldn't paste it into the document. So I'll just paste it here

    Skills...I think I'll experiment some more and add some stuff. I'll post that later :)

    Tuesday, October 6, 2009

    Ch. 3 Ex.

    This is the Chapter 3 exercises, they were pretty straight forward
    http://docs.google.com/View?id=dgc44sfk_63dwjrs7hr

    Friday, October 2, 2009

    More about Function Definitions, Parameters, etc

    Rather than
    def cat_twice(part1, part2):
    cat = part1 + part2
    print_twice(cat)
    It makes more sense, to me, to write
    def y_twice(a, b):
    y = a + b
    print_twice(y)

    This defines y as a + b, because it is the function is indented it's a local variable and only works within y_twice. Parameters also only work within their set function. Because y is defined as a + b, print_twice(y) is the same as print_twice(a + b). This could make writing code much more efficient.


    Function Definitions

    Function definitions are really hard to understand just from the book. I didn't get the whole "bruce" thing. I think I get it now, though.
    A function definition is like a variable for a function. For ex/
    if you type
    def print_twice(x):
    print x, x

    then
    print_twice('dog')

    it will print
    dog dog

    The statement (print_twice) is a variable for the function (print x, x). The parameters(x) are variables that change the result of the function depending on what you enter into the parenthesis. ('dog') prints dog, dog if I type ('cat') it prints cat, cat.

    That's how I would explain function definitions at least.