Python Data Structures #1: Dictionary Object

Поділитися
Вставка
  • Опубліковано 6 лис 2024

КОМЕНТАРІ • 31

  • @JayMaverick
    @JayMaverick 4 роки тому +5

    Store an instance of a class in a dictionary value - just blew my mind with the possibilities. Thanks for this video!

  • @BrianFaure1
    @BrianFaure1  7 років тому +4

    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

  • @robn8656
    @robn8656 6 років тому +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  6 років тому +1

      👌👌 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 5 років тому

      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 роки тому +1

      @@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

  • @MrDFJohnson
    @MrDFJohnson 4 роки тому +3

    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!

  • @equestrianranch1
    @equestrianranch1 5 років тому +3

    Great videos, but why still in python 2? Support ends in 2020

  • @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 8 місяців тому

      I don't think so. The set can be created using set() constructor only.

  • @Lexaire
    @Lexaire 4 роки тому +1

    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!

  • @Nikhil-io3nf
    @Nikhil-io3nf 5 років тому

    Awesome Explanation , would be glad to have videos on Graphs.......

  • @yihanwang1691
    @yihanwang1691 6 років тому

    Really love your way of explaining things! Please update more videos。 found your channels so helpful!

  • @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! 🙏

  • @happymalyo_
    @happymalyo_ Рік тому

    Great Vidéos !!!!

  • @王玮-f6f
    @王玮-f6f 6 років тому +4

    This video is awesome! You are doing a good job!

  • @nojozol1816
    @nojozol1816 2 роки тому

    I want to see more please

  • @philtoa334
    @philtoa334 3 роки тому

    Nice.

  • @sasidharnaidu4507
    @sasidharnaidu4507 8 місяців тому

    Dictionary has been made an Ordered collection since Python 3.7

  • @ShivamGupta-wv7qs
    @ShivamGupta-wv7qs 7 років тому +1

    Can u tell me in which software you are writing

    • @BrianFaure1
      @BrianFaure1  7 років тому +2

      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.

  • @livingstongraphics
    @livingstongraphics 4 роки тому

    Cool

  • @MrHanSoL0
    @MrHanSoL0 5 років тому +2

    In the words of my little 8yr old nephew.. "Dude You're like the greatest and sh..t... Like #1 and stuff..."

  • @peterbartos6665
    @peterbartos6665 6 років тому +1

    Excellent videos, thank you very much!

  • @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