5.1.1 Creating Dictionaries & Key Hashability

Unit: Unit 5: Dictionaries and Sets • Interactive Practice

Quick Answer & Summary:

Interactive Python programming tutorial and practice in your browser.

Interactive Challenge (Run Live in Browser):

# Create dictionaries using {} literal and dict() constructor
user_profile = {
    "username": "alex_dev",
    "email": "alex@example.com",
    "reputation": 450,
    "is_active": True
}

empty_dict = {}
built_dict = dict(name="Jordan", role="Admin", level=5)

print("User Profile:", user_profile)
print("Empty Dict:", empty_dict)
print("Built Dict:", built_dict)
print("Total keys in profile:", len(user_profile))
Open in Live Interactive Python Sandbox →