Computer Science, asked by samarsingh75, 7 months ago

what is the difference between the following statements is a= 10 and a == 10 ​

Answers

Answered by pagareriddhi70
27

Answer:

a=10' is used to assign the value of 10 in 'a' variable whereas 'a==10' compare the value of 'a' variable with 10. Explanation: In "a=10", a is a variable that is initialized by 10 value because in any programming language "=" stands for assignment operator which is used to assign the value for any variable.

Explanation:

Answered by Anonymous
76

"=" is an assigning operator. You can assign a value to a variable using "=" operator.

Example in Python:

a = 10

Print(a)           // 10 will be printed

_________________________

"==" is an equality operator. It returns the boolean value to a particular condition.

Suppose you have declared the value for a = 10, then you can use a== 10 to check whether it is true or false.

As it is true, It will return "True". But if a==12, then it will return "False".

Example in Python:

a = 10

//  We assigned the value for a = 10. We can now edit the value, add the new value or delete the value.

a == 10         // True

a == 14         // False

_________________________

  • The most last value assigned to a variable is considered only.
  • We can add new value to variable using shortcut +=
  • To subtract: -= To Multiply: *= and To divide /=
  • To assign a string to an integer, we must first convert the string into an integer using "int".
  • Vice versa with integers and string.
  • We can later change the name of variable by simply declaring another variable=first declared variable. (eg: a=b).
Similar questions