+ 2

( = ) and ( == ) in Python

What is the difference between = and == in Python?

30th Jul 2020, 1:16 PM
Noud Al Mansouri
Noud Al Mansouri - avatar
6 odpowiedzi
+ 5
Divya Mohan , === is not a valid operator in python.
30th Jul 2020, 2:22 PM
Lothar
Lothar - avatar
+ 4
= is assignment operater, a=b assigns the value b to the variable a for example f=10 assigns the value 10 to the variable f .it binds the object 10 to variable f. But == is a binary operator which compares it's operands and return whether they are equal or not . For example 5==5 returns true 6==5 returns false
30th Jul 2020, 1:20 PM
Rajneesh Singh
Rajneesh Singh - avatar
+ 4
= is assignment operator.(assign value to var ) == is comparision operator for value (not date type) of variables.
30th Jul 2020, 2:00 PM
Divya Mohan
Divya Mohan - avatar
+ 4
= is for assigning variable. == Is for comparing purpose.
30th Jul 2020, 2:46 PM
shubham kumar
shubham kumar - avatar
+ 1
I'm really sorry I have jst completed js.
30th Jul 2020, 2:25 PM
Divya Mohan
Divya Mohan - avatar
+ 1
cat = 99 or mouse = input(). it gives a value to a variable. if x * 2 == y: or cats == cats[::-1] what == does is compare 2 values in regards to the surrounding code
31st Jul 2020, 2:04 AM
Roland Priske
Roland Priske - avatar