Create bytes (immutable) Dry Run in PYTHON

Create bytes (immutable) is an interactive PYTHON dry run visualizer from the Bytes 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.

Create bytes (immutable) Program Code

# bytes – immutable sequence of bytes
b1 = b"hello"                     # literal
b2 = bytes([72, 101, 108, 108, 111])  # from list
b3 = bytes("world", "utf-8")      # from string
b4 = bytes(5)                     # zero-filled (5 bytes)

print("b1:", b1, "type:", type(b1))
print("b2:", b2)
print("b3:", b3)
print("b4 (5 zero bytes):", b4)
print("len(b1):", len(b1))
# b1[0] = 99  #  TypeError: 'bytes' object does not support item assignment

View the complete Bytes programs page.

Program Console Create bytes (immutable) Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.