+ 2
why print(7=7.0)have error
print(7>=7.0)is true
6 Respuestas
+ 5
In computer programing, the "=" ( equal sign ) is an operator for affectation, when in mathematical world it is an operator for equality.
So, the equivalent operator for equality in code is "==" ( double equal sign )... and in certains langage is added the concept of "strict equality" ( "===" -- triple equal sign ), because object models and variables concept needs to be more precise in certains cases ( if I have 2 objects of a same family, ie: 2 vehicules, one car and one boat, I can tell there are equals if I consider the fact that they are two vehicules, or that there aren't, considering car and boat different )
+ 1
They are different types. If no quotations are added the program is going to assume you are using a variable or an integer. If you want a simple string printed, use the quotes. But python isn't going to be able to make two objects/variables interact if they are a different type.
+ 1
Read the hint given "don't confuse assignment (one equal sign) with comparison (two equal signs).
See, python recognises 7 as integer and 7.0 as float.
By using assignment ie one equal sign, you're telling it to assign the value of an integer with that of a float.
See the logic?
Try your best. You can do it :)
0
try print(7 == 7.0)
0
print (7==7.0) will give true
- 5
try print ("7=7.0")