In this video, learn how to use the permutation and combination methods from Python's itertools module to create different sets of data. Kathryn will review the differences between permutations and combinations, and explain why they are helpful in some coding situations.
- [Narrator] We can also calculate permutations…and combinations in Python using the itertools module.…So starting with permutations, a permutation is a way…in which a set or number of things…can be ordered or arranged.…Permutations take all the items given…and reorder them in different ways.…So here we have one, two, and three.…We can order them as one, two, three,…one, three, two,…three, two, one, et cetera.…So why is this helpful?…Let's go back to the code and try an example.…Say we have a variable called election and so we have…election equals, and we're going to make it…equal a dictionary.…
We are going to have one and…it's going to be associated with Barb.…We're going to have two and…it's going to be associated with Karen…and then we're going to have three,…and it's going to be associated with Erin.…So for an election we'd want to know what are the possible…outcomes for that given election.…And so we'll need to import itertools for this…because we're going to use the permutations method…inside of itertools.…
- Working with logical and comparison operators
- Getting a list of numbers with the range() and list() functions
- Using mathematical functions such as round(), abs(), and pow()
- Calculating a given input's length
- Importing and using the math module
- Reading a user's command-line arguments
- Getting the current time
- Formatting dates and times with datetime
- Creating a timer
- Using urllib to get content from the Internet
- Using the JSON module to decode content
Skill Level Intermediate
Learning the Standard PHP Librarywith David Powers3h 24m Intermediate
1. Python: What's Built-In?
2. Python: Math
3. Python: Input/Output
4. Python: Date & Time, HTML Parsing, and HTTP
- 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.