Program to demonstrate left shift and right shift Dry Run in PYTHON

Program to demonstrate left shift and right shift is an interactive PYTHON dry run visualizer from the Io 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.

Program to demonstrate left shift and right shift Program Code

# Demonstrating shift operators
num = int(input("Enter a number: "))

print(f"\nOriginal: {num} (Binary: {bin(num)})")
print(f"Left shift by 1: {num << 1} (Multiply by 2)")
print(f"Left shift by 2: {num << 2} (Multiply by 4)")
print(f"Right shift by 1: {num >> 1} (Divide by 2)")
print(f"Right shift by 2: {num >> 2} (Divide by 4)")

View the complete Io programs page.

Program Console Program to demonstrate left shift and right shift Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.