Quoting from http://docs.python.org/2/library/stdtypes.html#numeric-types-int-float-long-complex

Python totally supports combined arithmetic: once a binary arithmetic operator has actually operands of various numeric types, the operand through the “narrower” kind is widened to that of the other, where plain integer is narrow than lengthy integer is narrower than floating suggest is narrower 보다 complex.

You are watching: 100**0.5

So, 10 is widened come 10.0. Thats why 10 == 10.0


Because that"s the method Python defines equality because that floats and integers. If the float to represent a totality number, it"s equal to the integer representing the same number (and also has the exact same hash code). Keep in mind that Java does something to comparable effect (even though == can not be overloaded by classes in Java). 10.0 == 10 is true because == with mixed (numeric) disagreements performs binary numeric promotion which transforms the int 10 into the floating suggest number 10.0.

u have the right to use

== is the equality comparison.

is means is same instance. It evaluate to true if the variables ~ above either next of the operator point to the exact same object and false otherwise.


Python automatically form converts throughout comparisons if feasible and judicious to carry out so.


Thanks because that contributing solution to stack Overflow!

Please be sure to answer the question. Administer details and share her research!

But avoid

Asking for help, clarification, or responding to other answers.Making statements based upon opinion; back them increase with references or an individual experience.

See more: Which Of The Following Statements Is Accurate, Problem Set #6 Flashcards

To discover more, view our tips on writing great answers.

write-up Your answer Discard

By clicking “Post her Answer”, girlfriend agree come our regards to service, privacy policy and also cookie plan

Not the prize you're looking for? Browse various other questions tagged python or ask your very own question.

site design / logo © 2021 ridge Exchange Inc; user contributions license is granted under cc by-sa. Rev2021.10.22.40548

your privacy

By clicking “Accept every cookies”, you agree ridge Exchange have the right to store cookies on your device and disclose information in accordance with our Cookie Policy.