Saturday, October 1, 2011

Slithering through day 2

Going through Chapter 2 right now for Python and nothing's completely out of the ordinary for me regarding Python. String concatenation's straight forward with the + sign.

Some new concepts did pop up though:
  • '\' is not only an escape character but can be used at the end of any statement so that you can extend a statement to several lines 
  • Using the multiply symbol (*) and # with a statement repeats the statement # time
  • Using triple quotes can save multiple print statements and special characters as it takes whatever you put between the """ verbatim.
  • To have two consecutive print statements on the same line you can suppress it by putting a comma at the end of the first print statement.

I got to create a Greeter program and learned how to use a variable. Let's just say I took some liberty to changing the version which was in the book:
The rest of the chapter covered using entered data as numbers instead of strings using the int() function. Then also knowing when to use + and , when concatenating strings vs. ints. Got through this chapter pretty quickly as the examples I didn't feel like I need to completely do, but just get the gist of. I was able to do the couple pieces of code above just to get a feel of how to do it.

Python is starting to feel pretty powerful with just these simple examples above. Next time I get to learn about branching, while loops, and program planning! Oh joy! <Insert sarcasm here> (I kid, I am having a fun time learning.)

No comments:

Post a Comment