+ 2
Difference between (!=,==,=)?
7 Respostas
+ 2
Is (=) is used with integers
+ 9
!= (Not equals to) is used as check inequality, i.e., if given operands are not same then it will return True, else False
Ex: 5 != 6
Returns True
______________________________________
== (Equals to) is used as check equality, i.e., if given operands are same then it will return True, else False
Ex: 5 == 6
Returns False
______________________________________
= (Assignment operator) is used to insert values in variables.
Ex: name = "Zlytherin"
Now the variable `name` contains "Zlytherin" as its value
+ 7
= (in fact, all three of them) can be used with any data type (integers, string, boolean etc.)
+ 3
'! =' two values are not equal to each other
'==' compare two values
'=' assign value to another variable
+ 2
= adds a name sticker to a value.
x = 5
y = 7
print(x, y)
output: 5 7
== means 'equals' and != 'not equals'.
1 == 2 is False
1 != 2 is True.
+ 2
other than "==" and "=", you may also be confused with "==" and "is"
"==" means their values (and also types) are the same, and "is" means they're exactly the same thing(or address in memory).
The reason for integers can use "is" in most cases is because python stores each integer at a specific place in memory, and that's why they all point to the same address.
+ 1
! =- > no equal to (conditional operater)
== equal to operater( conditional operater)
= assessment operator