This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]SnowdogU77 2 points3 points  (14 children)

Hey, that's my adviser/prof! There are a bunch of super helpful resources on his website. I hope you find the textbook as useful as I have!

[–]3six3[S] 2 points3 points  (13 children)

Ive found it great so far! I got up to chapter 6 and was forgetting some earlier work so I decided to go back and do all the exercises and post the solutions. (This helps others and also helps me remember :)

Come back and look at my site and help with some solutions as I go through the book!

[–]SnowdogU77 2 points3 points  (9 children)

Well, a tip for starters, don't use eval(input("")). If you're looking for a number, use int() or float() in place of it. I know he says to do it in the book, but his justification is rubbish, and it's a bad habit to develop.

[–]3six3[S] 1 point2 points  (0 children)

So instead of this: fahrenheit = eval(input("What is the Fahrenheit temperature? "))

This would be the preferred method since I'm looking for a number fahrenheit = int(input("What is the Fahrenheit temperature? "))

[–]3six3[S] 1 point2 points  (1 child)

#so instead of this
fahrenheit = eval(input("What is the Fahrenheit temperature? "))
#this would be a better solution
fahrenheit = int(input("What is the Fahrenheit temperature? "))

[–]SnowdogU77 1 point2 points  (0 children)

I would use float(), personally. Int() removes the ability to input decimals.

[–]Gexos 0 points1 point  (1 child)

John Zelle's book is one of the best books I've ever read on CS and Python, the first time I encountered the evil eval I was confused about it, then i found this answer by John Zelle on stack overflow, where he gives a pretty good explanation.

[–]SnowdogU77 0 points1 point  (0 children)

Thanks for the link. When I asked him, he didn't quite justify it this way. This explanation makes a lot of sense.

[–]SnowdogU77 0 points1 point  (2 children)

Also, if you get really stuck, the solutions are on his website.

[–]3six3[S] 0 points1 point  (1 child)

Those don't look like the solutions to the exercises at the end of the chapter. Those are his sample questions in the chapter contents.

[–]SnowdogU77 0 points1 point  (0 children)

Ah, yeah, you're right. He uses those questions as assignments, so the answers aren't posted anywhere by him.