Working with Dictionaries
Dictionaries store data as key-value pairs, like a real dictionary where you look up a word (key) to find its definition (value). They're perfect for financial data where you want to associate values with meaningful labels.
Creating Dictionaries
Accessing Dictionary Values
Use keys to retrieve values:
Modifying Dictionaries
Useful Dictionary Methods
Nested Dictionaries
Dictionaries can contain other dictionaries - perfect for portfolios:
Looping Through Dictionaries
Practice: Create a Stock Dictionary
Practice: Calculate Gain/Loss
Key Takeaways
- Dictionaries store data as
{key: value}pairs - Access values with
dict['key']ordict.get('key') - Use
.get()with a default value to avoid errors - Add/update values with
dict['key'] = value - Delete with
del dict['key'] - Loop with
for key, value in dict.items() - Dictionaries can be nested for complex data structures
- Perfect for storing labeled financial data
Next, we'll put it all together and build your first financial calculator!
Up next · Lesson 7 of 26
Your First Financial Calculator
2 min read
6 of 26 lessons done

Ask Byte about this lesson
A private chat about this lesson. Byte has read the whole lesson, answers in seconds, and shows the section each answer comes from. Ask follow-ups in any language.
Questions & Answers
Public questions about this lesson. The AI Tutor answers right away in your language, the FreeAcademy team checks answers, and every learner can read them.

