Thursday, January 20, 2011

Jan 20

Alright today I'm gonna review the first few chapters that I have done on the How to Think Like a Computer Scientist site, i'll do a quick read through then add my exercises to this.
 Chapter 1 Exercises:
#1: print "hello, how are you"
print "Hello, how are you?"
#2: When I add the / into an equation, it causes the equation to divide. Like for example: 2 + 2 will equal 4, but when u substitute + for / you'll get 1 instead of 4. This is caused by the problem changing from a addition problem to a division problem.
#3: more examples of errors are:
2 3 invalid syntax
3***2 invalid syntax
ill stop at two examples because I've come to notice that all the numbers that I apply to python without accurate equation symbols will end in a invalid syntax error.
#4: When I added the " " into print "hello" I got the same results as I did for when I put in print 'hello'. I got hello without any quotation marks.
#5: no question for this one
#6: This one is to make a test1.py file
OK well that wraps up chapter 1.
Chapter 2 Exercises:
#1: When I code: print n = 7, I get a syntax error saying that its a invalid syntax. When I apply print 7 + 5 I get a end result of 12. I also had to print 5.2, "this", 4 - 2, "that", 5/2.0 and got 5.2, this, 2, that, and 2.5. I noticed that even though, without adding quotations to like 7+5 to get 7+5 as a end result instead of getting 12. I could also instead of putting print 7 + 5, I could simply just put in 7 + 5 to get the end result of 12.
#2: n = "All work and no play "
p = "makes Jack a dull boy."
n + p = "All work and no play makes Jack a dull boy."
#3: To make 6 * 1 - 2 equal -6 then 4, u add parenthesis where 6*(1-2) so that after 2 is taken from 1 you get -1. Then -1 * 6 will equal -6.
#4: When I add a comma in front of n + P from question #2, I get a syntax error. Python response by saying that the comma is a invalid syntax.
Um due to time, ill continue this next class from question #5. 

1 comment:

  1. Excellent! Does this all make sense to you? Don't hesitate to post any questions you have.

    ReplyDelete