Home > other >  Python is a small white asked a question
Python is a small white asked a question

Time:10-11

Line 5 why you can write?
As can be equal to two types do not?

CodePudding user response:

Floating-point and integer comparison, "==" and "is", you can know about the difference between the two, eg: 10, a=b=10.0, a is b results to false, the result is a==b is true,

There are int (100.5)=100,

CodePudding user response:

reference 1st floor nangongxiaobai response:
floating-point and integer comparison, "==" and "is", you can know about the difference between the two, eg: 10, a=b=10.0, a is b results to false, the result is a==b is true,

Int (100.5)=100,
so==can be?

CodePudding user response:

Judgment is equal to judgment

CodePudding user response:

refer to the second floor weixin_45926493 response:
Quote: refer to 1st floor nangongxiaobai response:
floating-point and integer comparison, "==" and "is", you can know about the difference between the two, eg: 10, a=b=10.0, a is b results to false, the result is a==b is true,

Int (100.5)=100,
so==can be?

yes

CodePudding user response:

refer to the second floor weixin_45926493 response:
Quote: refer to 1st floor nangongxiaobai response:
floating-point and integer comparison, "==" and "is", you can know about the difference between the two, eg: 10, a=b=10.0, a is b results to false, the result is a==b is true,

Int (100.5)=100,
so==can be?

Write quite beautiful, is a 'younger sister

CodePudding user response:

reference zxc_wolf reply: 3/f
equal judgment can be judged
and STR () is that ok? For example, y/4==STR (y/4)

CodePudding user response:

reference 5 floor nangongxiaobai reply:
Quote: refer to the second floor weixin_45926493 response:

Quote: refer to 1st floor nangongxiaobai response:
floating-point and integer comparison, "==" and "is", you can know about the difference between the two, eg: 10, a=b=10.0, a is b results to false, the result is a==b is true,

Int (100.5)=100,
so==can be?

Write quite beautiful, is a 'sister?
HHHH is a girl but not of w

CodePudding user response:

reference 4 floor nangongxiaobai response:
Quote: refer to the second floor weixin_45926493 response:

Quote: refer to 1st floor nangongxiaobai response:
floating-point and integer comparison, "==" and "is", you can know about the difference between the two, eg: 10, a=b=10.0, a is b results to false, the result is a==b is true,

Int (100.5)=100,
so==can be?

Yes
good thank you

CodePudding user response:

100.0 numerical comparison, equal to, of course, must be equal to 100 (==), is is the same, no matter in what ways are the same,

CodePudding user response:

bubble pepper shredded meat, 9/f, reference response:
numerical comparison, equal to, of course, must be equal to 100 (==), 100.0 is the same, no matter in what ways are the same,
good thank you

CodePudding user response:

refer to 6th floor weixin_45926493 response:
Quote: refer to the third floor zxc_wolf response:
equal judgment can be judged
and STR () is that ok? For example, y/4==STR (y/4)

No, one is the numerical value is a string, completely different,

CodePudding user response:

11 references nangongxiaobai response:
Quote: refer to the sixth floor weixin_45926493 response:

Quote: refer to the third floor zxc_wolf response:
equal judgment can be judged
and STR () is that ok? For example, y/4==STR (y/4)

No, one is the numerical value is a string, completely different,
yeah yeah thanks ~

CodePudding user response:

In Python can use floating-point and integer with the==comparison, but it is not recommended to do this,
== especially two floating-point Numbers is equal to, is can lead to incorrect results, any programming language to figure out whether two floating point Numbers are equal,
With the absolute value of the difference between the two floating point Numbers is less than the number of arbitrary minimum, if think approximately equal,


Don't use/for leap years, the best is to use %

CodePudding user response:

yellow elder brother Python training reference 13 floor response:
in Python can use floating-point and integer with the==comparison, but it is not recommended to do this,
== especially two floating-point Numbers is equal to, is can lead to incorrect results, any programming language to figure out whether two floating point Numbers are equal,
With the absolute value of the difference between the two floating point Numbers is less than the number of arbitrary minimum, if think approximately equal,


Don't use/for leap years, the best is to use %
good thank you!
  • Related