33.7k views
0 votes
In Python, ‘=’ is different from ‘==’.

Explain when you would use ‘=’:

Explain when you would use ‘==’:

1 Answer

2 votes

Answer:

In Python and many other programming languages, a single equal mark is used to assign a value to a variable, whereas two consecutive equal marks is used to check whether 2 expressions give the same value .

= is an assignment operator

== is an equality operator

x=10

y=20

z=20

(x==y) is False because we assigned different values to x and y.

(y==z) is True because we assign equal values to y and z.

User Linzy
by
7.5k points

No related questions found