Display all keys of dictionary Dry Run in PYTHON

Display all keys of dictionary is an interactive PYTHON dry run visualizer from the Dict 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.

Display all keys of dictionary Program Code

# Display all keys in dictionary
employee = {
    "id": 101,
    "name": "Sarah",
    "department": "IT",
    "salary": 75000,
    "location": "Remote"
}
print("Dictionary:", employee)

# Method 1: Using keys() method
keys_view = employee.keys()
print(f"\nUsing keys(): {keys_view}")
print(f"Type: {type(keys_view)}")

# Method 2: Convert to list
keys_list = list(employee.keys())
print(f"As list: {keys_list}")

# Method 3: Iterate and print
print("\nKeys one by one:")
for key in employee:
    print(f"  {key}")

# Method 4: Using sorted to get ordered keys
sorted_keys = sorted(employee.keys())
print(f"\nSorted keys: {sorted_keys}")

View the complete Dict programs page.

Program Console Display all keys of dictionary Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.