Skip to main content
🔒 Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial →
← CoursesSenior Deep-DivesModule 6 · FAANG-2026 deep divesenum.IntFlag — bitwise composition and the `in` operatorpredict117 / 161
+150 XP
Task
📝 **Task:** Predict the exact output. \`Permission\` has READ=1, WRITE=2, EXECUTE=4, DELETE=8 (auto-assigned powers of 2). Trace through union, \`in\` checks, subtract-via-\`& ~\`, and iteration. 📋 Implement the function above. Tests run automatically. 💡 **Hint:** Re-read the theory if you get stuck.
Predict the output

Read the code carefully

from enum import IntFlag, auto


class Permission(IntFlag):
    READ = auto()
    WRITE = auto()
    EXECUTE = auto()
    DELETE = auto()


p = Permission.READ | Permission.WRITE
print(int(p))
print(Permission.READ in p)
print(Permission.EXECUTE in p)

q = p & ~Permission.READ
print(int(q))

combined = Permission.READ | Permission.EXECUTE | Permission.DELETE
print(int(combined))
print([int(m) for m in combined])

What will the program print? Write here:

💬 Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…