What is the difference between '=' and '==' operators | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What is the difference between '=' and '==' operators

9th Dec 2021, 2:40 PM
Sameeksha Yadav
Sameeksha Yadav - avatar
24 Answers
+ 25
Sameeksha Yadav Single equal (=) is used to assign value Double equal (==) is used to compare 2 values which will return true or false
9th Dec 2021, 2:44 PM
A͢J
A͢J - avatar
+ 6
The triple equals operator (===) returns true if both operands are of the same type and contain the same value. If comparing different types for equality, the result is false.
9th Dec 2021, 3:38 PM
SoloProg
SoloProg - avatar
+ 4
= is an assignment operator which is used to assign a value to any identifier whereas == is a logical operator used to compare the values.
10th Dec 2021, 6:04 PM
Kajal Pandey
Kajal Pandey - avatar
+ 3
SoloProg the question is about Python. Is there a version of Python that recognizes === operator?
9th Dec 2021, 9:40 PM
Brian
Brian - avatar
+ 3
Brian , I was taking about Javascript & other lanaguages just to let you know there is a triple equal sign.
10th Dec 2021, 2:01 PM
SoloProg
SoloProg - avatar
+ 2
= operator is for assigning value and == operator is for comparison of two values not there addresses
10th Dec 2021, 3:06 AM
Abhinandan
+ 2
Assignment operator (=) is used to assign values. Comparison operator (==) is used to compare and returns 0 if false else 1.
10th Dec 2021, 7:19 PM
Abhishek Pandey
Abhishek Pandey - avatar
+ 2
"=" is used for variables but "==" is mostly used for comparison operators
10th Dec 2021, 7:30 PM
elly paul
elly paul - avatar
+ 2
= says, for example, a is assigned to b. b being a value(integer, float, string etc.) and a being the variable. a is set or assigned to the value b. But == falls more to the equality or inequality groups of comparisons meaning it returns True or False.
10th Dec 2021, 9:01 PM
Pius Motai
Pius Motai - avatar
+ 2
== it compares two elements or two strings.it compares .if it is true then executes the block (=) It is an assignment operator. For a=2.it assigns a value to a . b=a then b value also 2
11th Dec 2021, 1:45 AM
Voonna Gowri Ganesh
Voonna Gowri Ganesh - avatar
+ 2
There's a subtle difference between the Python identity operator ( is ) and the equality operator ( == ). ... The == operator compares the value or equality of two objects, whereas the Python is operator checks whether two variables point to the same object in memory.
11th Dec 2021, 7:53 AM
Elliot Alderson (Mridul Pandey)
Elliot Alderson (Mridul Pandey) - avatar
+ 2
You can also do the Python for Beginners tutorial
11th Dec 2021, 11:40 AM
Sonic
Sonic - avatar
+ 1
Single equal to(=) is used to assign value eg. a = 5; Double equal to (==) is used to compare 2 values which will return true or false eg. a == 10;(Think in mathematics terms so a = 10, but in programming language we use == to compare) Does a = 10 is true or false because == is generally used for comparing the 2 values it will help in logical programs
10th Dec 2021, 8:36 PM
Raviranjan Kumar
Raviranjan Kumar - avatar
+ 1
For example... A = b means A assign the value. A==b means A equal to B.
11th Dec 2021, 3:21 AM
Shaikh Jahangir Alam
Shaikh Jahangir Alam - avatar
+ 1
For Purposes of ASSIGNMENT a value to variable we use =,and for comparing two variables we use ==
11th Dec 2021, 3:57 AM
Vivek Suthar
Vivek Suthar - avatar
+ 1
#equal(=) used to assign value to variable. name="Sameeksha" # double equal (==) used to compare variable #if name is "sameeksha" then print "Yes" #if u change name value output will change to "No" if name=="Sameeksha": print("Yes") else: print("No") #result :Yes ################ #here variable value changed name="Solo Learn" if name=="Sameeksha": print("Yes") else: print("No") #result:No
11th Dec 2021, 7:04 AM
Ravi V
Ravi V - avatar
+ 1
= means Ur assigning a value And == Means Ur checking whether they are equal or not eg.. a=10 b=20 c=a+b if c==30 print("yes") else print("no) output if yes as a+b=10+20=30
11th Dec 2021, 11:28 AM
Sonali Kala
Sonali Kala - avatar
0
Consider x=1 Print(x) You'll get output as 1 Wherein for double equal to (==) it compares the two values If a==b: The output gives false And if both values are same it gives True and it applies same for both numericals and alphabets.
11th Dec 2021, 7:42 AM
YELISETTY ACHYUTH ATHREYA
YELISETTY ACHYUTH ATHREYA - avatar
0
(1) (=) the single equal sign is called assignment operator in programming and its function is to assign a value to a variable in order to store the value into a particular variable.......for example name = "Muhammad" the assignment operator that appeared in between name and the value("Muhammad") is telling to compiler store the value("Muhammad") into the variable name. (2) (==) the double equal sign is called equal operator in programming and its function is to compare two value, if the both value are equal it will output true otherwise false.....for example a = 10 b = 20 if a == b: print("True") else: print("False") Output: False Because a and b are not equal, if they're equal the code will output True.
11th Dec 2021, 10:48 AM
Muhammad Abdulmalik
Muhammad Abdulmalik - avatar
11th Dec 2021, 11:44 AM
Abdullo Baxritdinov
Abdullo Baxritdinov - avatar