- [Teacher] Let's wrap up our discussion on comprehensions…by taking a look at how you can use comprehensions…to work with sets of values.…So, we've already seen how to do them…with lists and dictionaries,…and now we're going to take a look at sets.…And recall, sets in Python are used…to contain unique values.…So that is each value in a given set can occur only once.…So here in VS Code in my comprehensions folder…I'll open up setcomp_start.…And similar to our previous example,…I have a list of Celsius temperature readings here,…and what I want my code to do…is convert the Celsius temperatures into Fahrenheit ones,…but only keep each unique temperature reading.…
So in other words,…I want to weed out any duplicate temperatures.…In doing this with a set comprehension…is pretty straight forward.…So what I'm gonna do here for illustration purposes…is solve the problem with both a list…and a set comprehension, so you can see the difference.…So, first what I'll do is…build the comprehension for the list,…and I'll call that ftemps1.…
- Truth value testing
- Template strings
- Advanced Python functions
- Advanced collections
- Advanced classes and objects
- Python comprehensions: list, dictionary, and set
Skill Level Advanced
1. Python Language Features
2. Built-In Functions
3. Advanced Python Functions
4. Advanced Collections
5. Advanced Classes and Objects
6. Using Logging
7. Python Comprehensions
- 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.