Question Detail

COS 102 If staments Objective Question

Question

Which of the following is highlighted as a 'Key Takeaway' regarding the `==` and `=` operators in Python?
Options
A `==` assigns a value, `=` compares.
B `==` and `=` are interchangeable for both assignment and comparison.
C `==` compares, `=` assigns.
Correct Answer
D Neither `==` nor `=` should be used in `if` statements.
Correct Answer

Option C is the correct answer.

Detailed Explanation

Page 20, 'Key Takeaways' slide, explicitly states: '== compares, = assigns.' This distinction is also detailed as 'Mistake #1' on page 14.

Hint

Refer to the 'Key Takeaways' section or the 'Mistake #1' slide to recall the roles of these two operators.

Question Info