It's easy to mix and match data structures in Python because everything is a first-class object. Any element of a collection may be any object that meets the criteria for the containing type.
- [Instructor] In Python, everything is an object…and variables store references to objects.…This means that it's possible…to store anything in a data structure.…Here in Komodo, I've opened a working copy…of mixed.py from chapter eight of the exercise files.…And you notice here in my main function,…I have a rather complicated set of stuff.…I have r is a range,…l is a list,…and that list includes integers, strings,…a dictionary, and all kinds of stuff.…
T is a tuple, which again, includes strings…and a None value in the middle of it.…S is a set,…d is a dictionary.…And then I have this mixed…which is a list of all of these different structures.…And then I have this display function,…which I'll show you in a minute…which will display the mixed.…And I'm just going to run it right now…and you can see down here, here's…all our different elements.…So first is the list, and you remember the list has…one, two, and it's got a dictionary in the middle of it.…
Then is the range.…Then I have the set.…And so that's all of the characters in the set.…
- Python anatomy
- Types and values
- Conditionals and operators
- Building loops
- Defining functions
- Python data structures: lists, tuples, sets, and more
- Creating classes
- Handling exceptions
- Working with strings
- File input/output (I/O)
- Creating modules
- Integrating a database with Python db-api
Skill Level Intermediate
Python: Programming Efficientlywith Michele Vallisneri2h 15m Intermediate
2. Language Overview
3. Types and Values
8. Structured Data
11. String Objects
12. File I/O
13. Built-in Functions
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
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.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.