Practice mode Python

What is the output of the following Python code? a = ; b = ; c = a; print(a == b, a is b, a is c)

Correct answer C. True False True

Explanation

The == operator compares values, so two separate lists with the same items are equal. The is operator compares identity: a and b are two distinct list objects created by separate list displays, so a is b is False. c = a binds a second name to the same object, so a is c is True.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.