QuestionQ53Verified/Computer Programming and Python FundamentalsCopy linkReport a problemAsk AstroTutorSave questionWhat is the output of the following code snippet? A0 0B1 1C0 1D1 0Show AnswerAnswerExplanationThe ^ operator performs bitwise XOR. Starting with a = 1 and b = 0, a = a ^ b sets a to 1 ^ 0 = 1. The next assignment, b = a ^ b, sets b to 1 ^ 0 = 1. The fifth line assigns to b again, setting b to 1 ^ 1 = 0, while a remains 1. Therefore print(a, b) outputs 1 0, which is option D.Learn morePython Language Reference — Binary bitwise operationsPython built-in functions — printShow comments0Show commentsCommunity DiscussionNo comments yet. Be the first to start the discussion!
Community Discussion