Bitwise Operations and Bit Shifts Dry Run in PYTHON

Bitwise Operations and Bit Shifts is an interactive PYTHON dry run visualizer from the Operators programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.

This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.

Bitwise Operations and Bit Shifts Program Code

# a = 5 (0101 in binary), b = 3 (0011 in binary)
a, b = 5, 3

# Bitwise AND (&)
print("a & b =", a & b)  # 0101 & 0011 -> 0001 (1)

# Bitwise OR (|)
print("a | b =", a | b)  # 0101 | 0011 -> 0111 (7)

# Bitwise XOR (^)
print("a ^ b =", a ^ b)  # 0101 ^ 0011 -> 0110 (6)

# Left Shift (<<) - multiplies by 2
print("a << 1 =", a << 1) # 0101 << 1 -> 1010 (10)

# Right Shift (>>) - integer divides by 2
print("a >> 1 =", a >> 1) # 0101 >> 1 -> 0010 (2)

View the complete Operators programs page.

Program Console Bitwise Operations and Bit Shifts Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.