Тёмный

Python Data Structures #1: Dictionary Object 

Brian Faure
Подписаться 13 тыс.
Просмотров 57 тыс.
50% 1

In this video, we will begin by discussing the basics of the built-in dictionary class then work our way towards the performance benefits of using a dictionary over a list object.
If you're interested in Python GUI development check out my video series starting with: • Python GUI Development... .
Some dictionary documentation...
docs.python.org/2/library/std...
docs.python.org/2/tutorial/da...
In computer science, an associative array, map, symbol table, or dictionary is an abstract data type composed of a collection of (key, value) pairs, such that each possible key appears at most once in the collection.
Operations associated with this data type allow:
- the addition of a pair to the collection
- the removal of a pair from the collection
- the modification of an existing pair
- the lookup of a value associated with a particular key

Опубликовано:

 

10 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 31   
@JayMaverick
@JayMaverick 3 года назад
Store an instance of a class in a dictionary value - just blew my mind with the possibilities. Thanks for this video!
@yihanwang1691
@yihanwang1691 5 лет назад
Really love your way of explaining things! Please update more videos。 found your channels so helpful!
@user-ku1fv8gd4s
@user-ku1fv8gd4s 6 лет назад
This video is awesome! You are doing a good job!
@Nikhil-io3nf
@Nikhil-io3nf 4 года назад
Awesome Explanation , would be glad to have videos on Graphs.......
@robn8656
@robn8656 5 лет назад
Thank You! This is exactly what I was looking for. Every video has been a tutorial on python fundamentals. Which was great when I was using django or building a game with the pygame module. Now that I'm trying to practice leetcode, I want to blow my brains out on the first "easy" question. This was exactly what I needed. I don't even know what a binary tree is and I've been learning for a year.
@BrianFaure1
@BrianFaure1 5 лет назад
👌👌 Thanks for watching Allen. Good luck on working through leetcode! Also feel free to send me a message or email if you get stuck anywhere I'd be happy to help.
@thismakesnosense4815
@thismakesnosense4815 4 года назад
ah the good old find two numbers which add up to a sum
@porkzilla1
@porkzilla1 2 года назад
This is currently me. Please tell me it got easier.
@robn8656
@robn8656 2 года назад
@@porkzilla1 It did get easier. I work for a home building supply company now. Today I built a calendar that allows our production guys to track orders in a central location for all employees to view. Excel spreadsheets weren't cutting it because they're flat databases (not connected or structured). The backend of the calendar uses mysql and the front end is just a website with a calendar using php, html and ajax responses (they update in real time, you don't have to reload. Like scrolling facebook). It might sound hard, but that's all relative. It was actually pretty easy for me now. I never once had a leet code like question on any of my interviews. But I would do it anyways. I remember this problem. It took me 2 weeks to solve it but it deepened my understanding of programming languages. Also, for what it's worth, I got my CCNA cert and put that on my resume too. Other than that, I was self taught. No bachelor's degree.
@porkzilla1
@porkzilla1 2 года назад
@@robn8656 I’m currently doing a little better on those questions. I’m slowly Dissecting some answers other users have to learn a little more. I don’t know if I’m on the right path, but I’m told I just need to stay consistent
@gauravmufc1
@gauravmufc1 3 года назад
Thanks for clearing the difference in comlexity between list and dictionary
@Lexaire
@Lexaire 4 года назад
Great video! You could improve your code slightly by using dict.get(line, 0) instead of filling the dictionary with zeros. I'd love to see a video on Big O notation if you're looking for ideas!
@happymalyo_
@happymalyo_ Год назад
Great Vidéos !!!!
@BrianFaure1
@BrianFaure1 7 лет назад
Two things... (1) If you'd like to delete an entry in the dictionary (say we have key 'k' mapping to value 'val' in dictionary 'dict') you can simply call "del dict[k]". This will remove the key and the associated value from the dictionary. (2) Don't think I mentioned it in the video but this applies to Python 2.7. Python 3+ should have fairly similar syntax, this is the documentation for it if you would like to read more: docs.python.org/3/tutorial/datastructures.html
@peterbartos6665
@peterbartos6665 6 лет назад
Excellent videos, thank you very much!
@MrDFJohnson
@MrDFJohnson 4 года назад
No wonder the dictionary output isn't working for me as displayed in his video. Looking at his console information closely, I see he is using Python 2.7 while I am using python 3.7. But so far, good video. THX!
@philtoa334
@philtoa334 3 года назад
Nice.
@livingstongraphics
@livingstongraphics 3 года назад
Cool
@nojozol1816
@nojozol1816 2 года назад
I want to see more please
@YorkshireSpud
@YorkshireSpud Год назад
Worth mentioning that `d = {}` could actually become a `set` if you're not careful. Some suggest using the constructer object instead. E.g. `d = dict(my_key="my_value")`
@sasidharnaidu4507
@sasidharnaidu4507 5 месяцев назад
I don't think so. The set can be created using set() constructor only.
@sasidharnaidu4507
@sasidharnaidu4507 5 месяцев назад
Dictionary has been made an Ordered collection since Python 3.7
@equestrianranch1
@equestrianranch1 5 лет назад
Great videos, but why still in python 2? Support ends in 2020
@MrHanSoL0
@MrHanSoL0 4 года назад
In the words of my little 8yr old nephew.. "Dude You're like the greatest and sh..t... Like #1 and stuff..."
@burakhanaksoy
@burakhanaksoy 3 года назад
Nice video! Love the real life example but I have a question. Isn't accessing an element in list O(1) ? So when we do class_counts[class_names.index(line)] += 1, we actually do it in O(1), right? Because we increase the element by index, we are not searching for an element. In this case, why would using dictionary be faster? After all, dictionary operation is O(1) too.
@burakhanaksoy
@burakhanaksoy 3 года назад
Watching the part at 12:25 once again, I realize using index function in a list changes the scene. It'll search for each line in the list which is O(n) I believe. That's what makes dictionary faster. Thank you! 🙏
@ShivamGupta-wv7qs
@ShivamGupta-wv7qs 6 лет назад
Can u tell me in which software you are writing
@BrianFaure1
@BrianFaure1 6 лет назад
Python 2.7 is the coding language. I'm using the free version of Sublime Text 3 as the coding editor. For the command prompt I'm using the built-in Ubuntu 16 terminal which comes stock with the Python 2.7 interpreter.
@filiphron3147
@filiphron3147 4 года назад
I took the librety to decorate the functions to measure the time. Also if anyone wonder how to implement with python3 gist.github.com/Naruto0/55c9c53d2bc11972ccfa0ff80808ce78
Далее
Python Data Structures #2: Linked List
18:54
Просмотров 420 тыс.
This Is Why Python Data Classes Are Awesome
22:19
Просмотров 799 тыс.
Девушки и еда
00:52
Просмотров 1 млн
Modern Python logging
21:32
Просмотров 172 тыс.
The Clever Way to Count Tanks - Numberphile
16:45
Просмотров 850 тыс.
25 Nooby Pandas Coding Mistakes You Should NEVER make.
11:30
A.I. ‐ Humanity's Final Invention?
18:30
Просмотров 3,3 млн
Pydantic Tutorial • Solving Python's Biggest Problem
11:07
Rust and RAII Memory Management - Computerphile
24:22
Просмотров 223 тыс.