nerdexam
GIAC

GPYC · Question #32

Review the following code: a = "123" b = "456" if ("1" in a) ^ ("4" in b): print("red") elif ("2" in a): print("blue") elif ("7" in b): print("yellow") What is the output of this code?

Sign in or unlock GPYC to reveal the answer and full explanation for question #32. The question stem and answer options stay visible for context.

Python Fundamentals & Command Line Tools

Question

Review the following code: a = "123" b = "456" if ("1" in a) ^ ("4" in b): print("red") elif ("2" in a): print("blue") elif ("7" in b): print("yellow") What is the output of this code?

Options

  • Ablue
  • Bred blue
  • Cred blue yellow
  • Dred

Unlock GPYC to see the answer

You've previewed enough free GPYC questions. Unlock GPYC for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Topics

#XOR operator#boolean logic#conditional statements#string membership
Full GPYC Practice