Question #214

What is the output of the code snippet below?
a = True
print(('A', 'B')[a == False])

Here ('A', 'B') is a tuple. The a == False is an expression that is evaluated as boolean. In Python 3 True and False are keywords and will always be equal to either 1 or 0. So the result will be A. (w3schools.com/python/python_booleans.asp)


Comment on Disqus:

Comment on Twitter:

Question difficulty: 🔵🔵🔵🔵🔵


Similar questions: