Why we use double ==sign instead of single = sign. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson

Why we use double ==sign instead of single = sign.

side1 = int(input()) side2 = int(input()) side3 = int(input()) if side3**2==(side1**2)+(side2**2): print("Right-angled") else: print("Not right-angled")

3rd Mar 2021, 6:37 AM
Ali Tarique
Ali Tarique - avatar
3 Answers
+ 4
https://www.sololearn.com/discuss/1084542/?ref=app = is called assignment operator which assign a value example: a = 10, here we assign value 10 to variable a == is to check if equals, if a == b it means to check if a is equal to b As this is a duplicate question, please use search bar before posting your question https://www.sololearn.com/discuss/918660/?ref=app For reference: https://www.sololearn.com/learn/JavaScript/1132/
3rd Mar 2021, 6:41 AM
Sharique Khan
Sharique Khan - avatar
+ 1
Ali Tarique Simple answer single = sign use to assign value like a = 2 double == sign use to check equality like 2==2 And also in some languages there is triple === sign which is use to check equality as well object type. For example 2 === '2' which is return false because 2 is int value and '2' is char value so value can be same but type is different.
3rd Mar 2021, 7:18 AM
A͢J - avatar
+ 1
single equal sign is used to set value while double equal sign is used to compare values a = 10 #a is 10 a = 12 #a is 12 now 3 == 4 #false because 3 is not equal to 4 a == 12 #true because a is equal to 12
3rd Mar 2021, 12:22 PM
Nothing - avatar