Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Trying to learn Python; is this book incorrect?

  1. Dec 31, 2015 #1
    I had a brief stint with Python a year or two ago, and after I learned of the Raspberry Pi I knew I should try to learn again. I purchased this book, knowing full well that the online resources would be sufficient, and some of the code doesn't seem to work.

    hello_str = "Hello World"

    hello_bool = True

    hello_truple = (21, 32)

    hello_list = ("Hello,","this","is","a","list")

    hello_list = list()
    hello_list.append("Hello,")
    hello_list.apppend("this")
    hello_list.append("is")
    hello_list.append("a")
    hello_list.append("list")

    hello_dict = {"first_name":"*My First Name*",
    "last_name":"*My Last Name",
    "eye_color":"*My Eye Color*"}
    print(hello_list[4])
    hello_list[4]+="!"

    This is the code copied verbatim from the book. It gets an error at the part with multiple append commands, but even when I comment that out it also hangs on the final line. What am I missing here? If it's any help, the book is simply titled "The Python Book: The ultimate guide to coding with Python". It says it's written for 2.x, but I tried 3 just to be sure. No luck.
     
  2. jcsd
  3. Dec 31, 2015 #2
    Well this looks like the source of the error. Works fine for me with this fixed.
    An important part of coding is learning how to debug - so its good to learn how to interpret the error messages that the interpreter throws at you.
     
  4. Dec 31, 2015 #3
    Thanks, that helped me fix it. I didn't even notice that it wasn't the first append that it hung up on, or else I might have fixed it myself. Thank you.
     
  5. Dec 31, 2015 #4

    Mark44

    Staff: Mentor

    It looks like they appended an extra 'p' on "append". Was this how it was in the book?
     
  6. Dec 31, 2015 #5
    No, that was my fault. I'm going to stick to sleep depravity as my excuse for that obvious slip up.
     
  7. Dec 31, 2015 #6

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    From what I can tell, that is not a good book. How did you find it? Just because there are lots of free (but illegal) downloads for that book does not mean it is good. From what I've seen, if the first google page on searching the title of a book comprises almost entirely links to various torrent sites, run away. It's not a good book.

    Python is an open source language, and as such, you can find lots and lots of free (and legal) tutorials on how to program in python. As a starter, I suggest you go to the source, python.org. For python2, look to https://docs.python.org/2/tutorial, and for python3, https://docs.python.org/3/tutorial. They're both free, they're both very good, and they're both legal.
     
  8. Dec 31, 2015 #7
    I bought it at a local bookstore, so it is completely legal. And I recognize that there are many free and probably better online resources, but I have a need for the physical thing that I can't explain. I'll use it to some extent, but I'll almost certainly resort to these online sources soon, just not yet.
     
  9. Dec 31, 2015 #8

    jtbell

    User Avatar

    Staff: Mentor

    Who's the author? I can't find anything with that title on amazon.com.
     
  10. Dec 31, 2015 #9
    https://www.imagineshop.co.uk/the-python-book.html [Broken]
     
    Last edited by a moderator: May 7, 2017
  11. Dec 31, 2015 #10

    jtbell

    User Avatar

    Staff: Mentor

    Aha, it's a "bookazine", not a "real book." I've seen this sort of thing in the magazine section of my "local" Barnes & Noble. They may even carry Imagine Publishing's bookazines; I've seen other UK publications there.
     
  12. Dec 31, 2015 #11

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    That is something I totally understand. To me, there's just something magical about words on paper that words on a computer screen cannot yet replicate. If you wish, you can highlight those words on paper with a yellow marker in the blink of an eye. You can do that with a computerized book,but not in a blink of an eye. You can flip from page 1 to page 101 in the blink of an eye with a book on paper; good luck with that with a computerized book.

    Done wrongly, that computer-based facsimile is just that, a facsimile. Done correctly, a computer-based version of a book or journal paper is anything but a facsimile of a paper copy. Good luck searching a paper copy for a keyword. It's cinch with a properly done computerized version. That's but one of the magical features of computerized papers.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Trying to learn Python; is this book incorrect?
  1. Learn Python? (Replies: 14)

  2. Book on Python (Replies: 2)

  3. Learning python and C# (Replies: 14)

Loading...