Python quiz with answers – what will be output?

The correct option is A) True True.

When you create a list in Python, it creates a new object in memory. When you assign that list to another variable, you essentially reference the same object in memory. This means that both a and b refer to the same list object.

The is operator checks if two operands refer to the same object in memory. In this case, a is b is True because both a and b refer to the same list object.

The == operator checks if two operands have the same value. In this case, a == b is True because both a and b contain the same list values.

This table summarizes the results:

ExpressionResult
a is bTrue
a == bTrue

More Quizzes