Question Detail

COS 102 If staments Objective Question

Question

In Python, what is the crucial difference between the operators = and ==?
Options
A <code>=</code> is for comparison, <code>==</code> is for assignment.
B <code>=</code> is for logical 'AND', <code>==</code> is for logical 'OR'.
C <code>=</code> is for assignment, <code>==</code> is for comparison.
Correct Answer
D They are interchangeable and perform the same function.
Correct Answer

Option C is the correct answer.

Detailed Explanation

Page 14, 'Mistake #1: = vs ==', explicitly states: '= is for Assignment (giving a value).', and '== is for Comparison (checking a value).'

Hint

One operator gives a value to a variable, the other checks if two values are the same.

Question Info