Trying to learn Python; is this book incorrect?

In summary, the book is titled "The Python Book: The ultimate guide to coding with Python" and it is apparently written for 2.x. However, I was not able to get it to work properly. I'm going to try some other online resources before resorting to using the book.
  • #1
jkoster09
15
0
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.
 
Technology news on Phys.org
  • #2
jkoster09 said:
hello_list.apppend("this")
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.
 
  • #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.
 
  • #4
jkoster09 said:
hello_list.apppend("this")
It looks like they appended an extra 'p' on "append". Was this how it was in the book?
 
  • #5
Mark44 said:
It looks like they appended an extra 'p' on "append". Was this how it was in the book?
No, that was my fault. I'm going to stick to sleep depravity as my excuse for that obvious slip up.
 
  • #6
jkoster09 said:
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.
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.
 
  • #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.
 
  • #8
jkoster09 said:
the book is simply titled "The Python Book: The ultimate guide to coding with Python".
Who's the author? I can't find anything with that title on amazon.com.
 
  • #9
https://www.imagineshop.co.uk/the-python-book.html
 
Last edited by a moderator:
  • #10
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.
 
  • #11
jkoster09 said:
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.

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.
 

Related to Trying to learn Python; is this book incorrect?

Q: Is this book suitable for beginners?

A: This depends on the book in question. Some books may be more suited for beginners, while others may be geared towards more experienced programmers. It's important to research the book and read reviews to determine if it's appropriate for your skill level.

Q: How do I know if the book contains accurate information?

A: Again, this depends on the book. It's always a good idea to cross-reference information with other sources, such as online tutorials or documentation, to ensure accuracy. You can also seek out reviews from other readers to get an idea of the book's reliability.

Q: What if I encounter errors while following the book's instructions?

A: It's not uncommon to encounter errors while learning a new programming language. If you encounter errors while following the book, try troubleshooting by checking for typos or missing code, consulting online resources, or seeking help from a more experienced programmer.

Q: Are there any other resources I should use in addition to this book?

A: While books can be a great resource for learning Python, it's also beneficial to supplement your learning with other resources, such as online tutorials, practice exercises, and community forums. This can help reinforce your understanding and provide additional support when needed.

Q: How long will it take me to learn Python using this book?

A: The time it takes to learn Python using a book will vary for each individual. It depends on factors such as your previous experience with programming, the complexity of the book's content, and the amount of time you dedicate to practicing and studying. It's important to be patient and to focus on understanding the material rather than rushing through it.

Similar threads

Replies
6
Views
797
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
3
Views
389
  • Programming and Computer Science
Replies
7
Views
618
  • Programming and Computer Science
2
Replies
43
Views
2K
  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
2
Replies
43
Views
3K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
3
Views
758
Back
Top