-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use == instead of 'is' for comparing number #4
Comments
Very interesting, thank you very much. I will make the change in the current notebooks, and keep this in mind in the coming ones. Thanks a lot! :) |
I realised 'is' was still in place. So I checked above issue, having no problem with higher numbers, unless I assigned numbers using a = 257 and b =257, which the notebook doesn't do (maybe it did before). Adding this comment for benefit of others... Anyone interested in the reasons can find why on stackoverflow. https://stackoverflow.com/questions/306313/is-operator-behaves-unexpectedly-with-integers @mikkokotila thanks for the book, going to use it in a math lesson tomorrow |
Hi,
In this notebook: https://github.com/mikkokotila/jupyter4kids/blob/master/notebooks/numerical-computing-is-fun-2.ipynb you use the 'is' keyword to compare numbers.
This should be avoided, because Python's semantic does not guarantee that '1 is 1'. In fact, in the CPython implementation, this is only True for integers lower or equal to 256:
The text was updated successfully, but these errors were encountered: