Sunday, December 13, 2009

Chapter 8 Exercises

  • Chapter 8's case study seems interesting and I'm looking forward to completing an assignment that has practical application
  • The second problem in the assignments asks what the counter variable is, the word "counter" is misleading

Friday, December 4, 2009

Chapter 7 Exercises

Chapter 7 Exercises published at http://docs.google.com/View?id=d5d8bxk_70f8tk4dd9
  • Chapter 7 is a difficult chapter because it is hard to absorb all the material. The new exercises should help.
  • After the first four problems, I started to understand the chapter better and I got through the rest smoothly. The functions took some time but after many trial and errors I got them all to work successfully.

Friday, November 20, 2009

Chapter 6 Exercises

Chapter 6 Exercises at http://docs.google.com/View?id=d5d8bxk_68gcrhscdz
  • Chapter 6 was a very difficult chapter. It was the most time consuming so far, as well as the most thought provoking. The chapter was a hard one to read, and that only foreshadowed the diffilculty of the exercises.
  • Numbers 1, 2, and 4 I got through with ease. 4 was fun because it involved learning about triangular numbers and using a formula to produce an output.
  • Numbers 5-9 were all very mathematical. Each one involved many trials and errors to complete. 5 and 9 I couldn't complete without asking for help. 8 was my favorite problem because after thinking for about 45 minutes I finally figured it out and gave me something to be proud of.

Friday, October 30, 2009

Chapter 5 Exercises

Chapter 5 Exercises at http://docs.google.com/View?id=d5d8bxk_67htqczwck
  • As I get further on in the book, the more fun the exercises are. In Chapter 5 to complete the exercises you really need to think and problem solve in order to make sure the programs pass the doctests. These problems all involved a systematic testing and failing process in order to achieve the solution. I expected to fail, but in the failure I could pinpoint the problem and correct it. These problems also required the use of the return function and I learned how it could be used with boolean functions so that the use of if and else statements don't need to be used.
  • the slope, intercept, Fahrenheit to Celsius and vice-versa functions all require the use of equations and formulas to complete the exercises.
  • The intercept problem was especially fun because it involved relating the point-slope and slope-intercept forms in order to get the equation for the y-intercept.
  • The Fahrenheit-Celsius problems were also fun because they involved the use of the int and round functions.

Wednesday, October 21, 2009

Chapter 4 Exercises

Chapter 4 Exercises are published at http://docs.google.com/View?id=d5d8bxk_61f6tqkndq

  • The third problem seemed a bit pointless at first, but it was good to show how logical operators work.
  • Problem number 4 involved evaluation of boolean expressions and logical operators to complete and after some trouble I finally completed the rules of "and" and "or" operators and found the problem to be one of the best for reinforcing the chapter through the process of actually doing.
  • Problem 6 was redundant in that if you could do the first part the second part was no different and there seemed no point in doing them both.
  • Number 8 was also a good example of how conditional statements work, another good look at boolean expressions, and also a good look at the flow of execution.
  • Number 9 was a good problem on learning how to use GASP and the process of translating the house around the screen by parameterizing the original draw_house() definition took some time to get.



Monday, October 5, 2009

Chapter 3 Assignments

3.8.1

def new_line():

print


def three_lines():

new_line()

new_line()

new_line()


def nine_lines():

three_lines()

three_lines()

three_lines()


def clear_screen():

nine_lines()

nine_lines()

three_lines()

three_lines()

new_line()

clear_screen()

3.8.2

clear_screen()


def new_line():

print


def three_lines():

new_line()

new_line()

new_line()


def nine_lines():

three_lines()

three_lines()

three_lines()


def clear_screen():

nine_lines()

nine_lines()

three_lines()

three_lines()

new_line()


Traceback (most recent call last):

File "tryme3_2.py", line 3, in <module>

clear_screen()

NameError: name 'clear_screen' is not defined

  • Function calls must come after a function definition. If not, the function will be undefined.

3.8.3
def three_lines():

new_line()

new_line()

new_line()


def new_line():

print


def nine_lines():

three_lines()

three_lines()

three_lines()

def clear_screen():

nine_lines()

nine_lines()

three_lines()

three_lines()

new_line()


clear_screen()

  • This still works because the function definitions all come before the call that incorporates all the definitions regardless of order.

def three_lines():
new_line()
new_line()
new_line()

three_lines()

def new_line():
print

Traceback (most recent call last):
File "/home/louis/bin/exercise3.8.3", line 8, in <module>
three_lines()
File "/home/louis/bin/exercise3.8.3", line 4, in three_lines
new_line()
NameError: global name 'new_line' is not defined

  • This does not work because the function three_lines() requires the function new_line() which is not defined until after the function call of three_lines

3.8.4
def cat_n_times(s, n):
print s*n

>>> from import_test import*
>>> cat_n_times("Cats have nine lives. ", 9)
Cats have nine lives. Cats have nine lives. Cats have nine lives. Cats have nine lives. Cats have nine lives. Cats have nine lives. Cats have nine lives. Cats have nine lives. Cats have nine lives.

Tuesday, September 29, 2009

I have just finished the first two chapters of How to Think Like a Computer Scientist and I am very impressed out how comprehensible Python is. The madlib assignment was fun and I look forward to creating more useful and complex programs.

Monday, September 21, 2009

Im learning python and i will be publishing a few of my assignments and general thoughts about my progress in my studies