Join Barron Stone for an in-depth discussion in this video Add items to dictionaries, part of Programming Foundations: Real-World Examples.
- A moment ago, I wanted to call Amanda,…to invite her over,…but when I went to look up her phone number…in my Rolodex,…it wasn't there.…I guess I never added it.…Fortunately, Olivia has Amanda's phone number.…- Here you go.…- Thanks.…Now I need to add a new card to my Rolodex…for Amanda.…I'll take a new Rolodex card,…and write Amanda's name on the top,…and then her phone number…on the bottom.…Five five five,…nine seven five four.…
Now we'll use my simple alphabetical hashing function…to figure out where to put this card.…Amanda starts with the letter A,…so that's her index,…and I'll store her card…in the A section.…Next time I need to look up Amanda's number,…I can just flip to the A's,…and find it right away.…Adding Amanda to the Python rolodex…is just as easy.…I have the script start_08_02_rolodex…from the exercise files open,…which defines my original rolodex.…Amanda is not currently in the rolodex dictionary.…
I'll run the script and switch over…to the interactive shell.…Now, if I try to find Amanda in my rolodex,…Python will throw an error,…
- Reusing functions
- Local vs. global variables
- Creating and naming custom objects
- Class inheritance
- Modules and packages
- Multidimensional lists and tuples
- Queues and stacks
- Creating and combining sets
- Storing data in dictionaries
- If/else and switch statements
- For vs. while loops
- Error handling
- Polling and event-driven programming
Skill Level Beginner
Programming Foundations: Design Patternswith Elisabeth Robson2h 19m Intermediate
3. Class Inheritance
4. Modules and Packages
5. Lists and Tuples
6. Queues and Stacks
9. Conditional Execution
11. Error Handling
12. Polling and Event-Driven Programming
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.