دوره Python Data Structures ، فصل 5 : Chapter Nine- Dictionaries
دربارهی این فصل:
The Python dictionary is one of its most powerful data structures. Instead of representing values in a linear list, dictionaries store data as key / value pairs. Using key / value pairs gives us a simple in-memory "database" in a single Python variable.
این دوره شامل 7 فصل زیر است:
And between lists and dictionaries you pretty much get the two most important and most basic data structures, not just in Python, but in any programming language. And in most languages like Perl or PHP, the associative array is, again, most people's favorite data structure because you can do so many things with it. And like I said, these concepts of dictionaries has many different names in many languages, like HashMaps in Java or Property Bags in C#, or Associative Arrays in Perl or PHP, but they basically are the same thing.
This turns out to be a problem that humans are really not very good at it, especially if I was going to give you a million words instead of just 16 or 12 or whatever I gave you. And it's really common for histograms or any other word counting, various other things, any kind of frequency. But after the tenth time you'll just be putting this line of code in and you say oh, this is our little histogram trick.
So if we look through it again, we make a dictionary, we take this line of text and we put it into this variable, then we split it into words. This was the key, this is the value, and we're going to run this loop three times because there's three things in the dictionary and we're going to hit each of the key-value pairs. At this point in the code, inside counts we have a complete histogram of every word on every line of that file.
So I've saved that one and I'm going to also take this clown text, I'll use this to make my life simple, so I have a real short thing that I can show you how it works. So the key thing to this dictionary is we're going to make a counter, and we're going to use w, the word absorb, elegant, whatever, and we're going to use that as the index. We do this so much with dictionaries that there is an easy mechanism to do this, that combines these four lines into a single kind of contraction.
Hi there, this is Chuck, I'm coming to you right now in the continuing reality show that is Internet History, Technology and Security. I work at Queued Off, in the Netherlands as a programmer, and I really love doing things, Internet History and Technology class at Coursera. And I need to get some sleep and recover from jet lag, but Philippines is gonna be cool I think cuz it was an invitation that came out of the Coursera class.
And today's a really muddy day so I'm probably gonna fall down a couple times. I wanna come in last place, because I don't want anybody spraying mud at my face. So that's the end of doctor Chuck goes motocross racing.
مشارکت کنندگان در این صفحه
تا کنون فردی در بازسازی این صفحه مشارکت نداشته است.
🖊 شما نیز میتوانید برای مشارکت در ترجمهی این صفحه یا اصلاح متن انگلیسی، به این لینک مراجعه بفرمایید.