Friday, December 18, 2009
Homework
I spent a lot of time this week working on the count function in the ch. 7 exercises, so I still have some problems to do. I'll try to work on them over the weekend. From now on I will try to avoid this by spending only a certain amount of time on a single exercise. If I get stuck I'll ask for help rather than continue to work on my own. I hope that this will increase my efficiency in the following chapters.
Monday, December 7, 2009
Suggestions: Chapter Summaries
I think it would be a good idea to put a chapter summary before each chapter. It would help us know what to expect as well as make it easier for us to go back and review it. I also think it would be easier for me to understand the new codes if there was an example of the output it would produce, especially for things like...
b
a
n
a
n
a
index = 0 while index < len(fruit): letter = fruit[index] print letter index += 1...you explain what the output is, but it's difficult to understand without a visual picture of what it's supposed to do. It would be more clear if you showed
index = 0
while index < len(fruit):
letter = fruit[index]
print letter
index += 1
b
a
n
a
n
a
Thursday, November 19, 2009
Finally finished
I finally finished chapter six. The exercises in Ch. 6 were really hard for me. Hopefully I'my just not used to thinking with computer programming and will get better with time and practice.
Friday, November 13, 2009
???
I wrote this for the num_even_digits function
count = 0
while n:
n = n/10
if n % 2 == 0:
count = count + 1
return count
but whenever I doctest it, it says
File "ch06draft.py", line 7, in __main__.num_even_digits
Failed example:
num_even_digits(1357)
Expected:
0
Got:
1
why?
count = 0
while n:
n = n/10
if n % 2 == 0:
count = count + 1
return count
but whenever I doctest it, it says
File "ch06draft.py", line 7, in __main__.num_even_digits
Failed example:
num_even_digits(1357)
Expected:
0
Got:
1
why?
Friday, November 6, 2009
Monday, November 2, 2009
interesting...
after playing around with the sequence(n) function from ch. 6,
I found that sequence(5/9) creates an infinite loop of zeros. I just thought that was interesting...
I found that sequence(5/9) creates an infinite loop of zeros. I just thought that was interesting...
Sunday, November 1, 2009
What I've learned so far
Everything I've learned so far has been completely new to me, I've learned:
- the basics of how to use vim and python.
- about values, variables, types, statements, expressions, and the various operators and basic functions.
- about function definitions, parameters, and arguments.
- about boolean values and expressions and functions and logical operators.
- about the "if", "else", and "elif" operators and conditionals.
- the difference between "print" and "return".
- about converting types and the very basics of using GASP.
- about developing programs and program composition.
- about boolean functions and function types.
- (and finally) about using triple quotes and doctesting.
1st Quarter Experience
I didn't really know what to expect from How to Think Like a Computer Scientist, but I have been a little surprised by what I've learned so far. With every knew chapter I see the relationship between what we've learned in the earlier ones. It all fits together very nicely, but I still don't really know where we're going. I've got the first puzzle pieces fitted together, but I don't know what the big picture looks like yet.
Ch. 5 Exercises
These are the ch.5 exercises, http://docs.google.com/View?id=dgc44sfk_74hhjrf3d4
It took me awhile to write the function def for f2c, but that was mostly b/c I didn't quite understand how to use the "round" function. I also came across a few errors that I had no explanation for, but I found that they were mostly syntax errors. Hopefully, overtime I will become more accustomed to spotting syntax errors and eventually be able avoid then entirely.
It took me awhile to write the function def for f2c, but that was mostly b/c I didn't quite understand how to use the "round" function. I also came across a few errors that I had no explanation for, but I found that they were mostly syntax errors. Hopefully, overtime I will become more accustomed to spotting syntax errors and eventually be able avoid then entirely.
Monday, October 26, 2009
To be noted...
how to organise your program...
or returns first value
or returns the first true value
or returns last value
- 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
- all values are true:
or returns first value
- false and true values:
or returns the first true value
- all values are false:
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 :)
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
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.
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.
Wednesday, September 30, 2009
Chapter 2 Exercises
This is the link to my google.doc. Chapter 2 Ex. Making the Madlib was the hardest exercise. But once I understood what I had to do it was alot easier.
Tuesday, September 22, 2009
experimenting with assignment statements
>>> hello
'hello'
>>> whoru
'I am Ted'
>>> whatrudoinginmycomp
'nothing'
>>> seriously
'NOTHING!'
>>> really
'really'
>>> souarentsendingsecretmessagestomybrain
'ummmm'
>>> seeiknewit
'darn'
>>> getout
'no'
>>> NOW
'fine, sheesh'
>>> good
'silence'
'hello'
>>> whoru
'I am Ted'
>>> whatrudoinginmycomp
'nothing'
>>> seriously
'NOTHING!'
>>> really
'really'
>>> souarentsendingsecretmessagestomybrain
'ummmm'
>>> seeiknewit
'darn'
>>> getout
'no'
>>> NOW
'fine, sheesh'
>>> good
'silence'
imp
and | as | assert | break | class | continue |
def | del | elif | else | except | exec |
finally | for | from | global | if | import |
in | is | lambda | not | or | pass |
raise | return | try | while | with | |
yield |
Subscribe to:
Posts (Atom)