Python Tutorial for Beginners 5: Dictionaries - Working with Key-Value Pairs

preview_player
Показать описание
In this Python Beginner Tutorial, we will begin learning about dictionaries. Dictionaries allow us to work with key-value pairs in Python. We will go over dictionary methods, how to add and remove values, and also how to loop through the key-value pairs. Let's get started.

The code from this video can be found at:

Watch the full Python Beginner Series here:

✅ Support My Channel Through Patreon:

✅ Become a Channel Member:

✅ One-Time Contribution Through PayPal:

✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey's Public Amazon Wishlist

✅ Equipment I Use and Books I Recommend:

▶️ You Can Find Me On:

#Python
Рекомендации по теме
Комментарии
Автор

0:07 – Terminology
0:14 – Key/Value pairs definition
0:37 - First example (Student using a dictionary)
0:45 – { }, Dict notation, curly braces,
0:50 – adding elements
1:32 – [ ] Square bracket access of the dict
2:04 – Dict items can be many things, they’re not bound to one “type”
2:14 – Keys can be any immutable data type
2:24 – Example of an Integer being the key
2:44 – Accessing a key that does not exist
3:00 – Alternative to “throwing an error” if a key does not exist
3:05 – Sometimes you will want to return None or a default value if key does not exist
3:09 - .get( ) access of the dict
3:30 – accessing a key that does not exist with the .get method as opposed to [ ] square bracket access
3:40 – Specifying a default value for keys that do not exist
4:01 – Adding a new entry to dictionary
4:30 – Changing/updating values via key access
5:02 – Changing/updating values via .update() method
5:21 - .update() takes in a dict as an argument
5:57 – Deleting a specific key and its value
6:01 – Option 1 for deleting a key and value: del keyword
6:26 – Option 2 for removing a key and value: .pop() method
6:30 – Remember the .pop() method not only removes the item put pops it off or returns it to you
6:35 – Therefore you can recover the popped item with a variable assignment
7:07 – How to loop through all the keys and values
7:13 – Finding out the number of keys in dict with len() function
7:30 – Print all keys with .keys() method
7:39 – Print all values with .values() method
7:47 – Print both keys and values with .items() method
8:07 – Looping is slightly different then lists because dicts are concerned with pairs (Key : Value)
8:33 – How to loop through keys AND values

cannon
Автор

I'm applying for Masters in Data Science and I just want to say that by following your videos, I will be able to develop a strong base and maybe would be able to fulfil my dreams in a long run all the contribution goes to you Mr Corey Schafer I'm thankful to God that I found your channel.

satyampriyadarshi
Автор

You are absolutely a lifesaver! My compsci prof is really smart, but absolutely terrible at explaining things efficiently. I understand more about dictionaries now after your 10-minute video than I previously did after my 3-hour lecture. Thank you so much, I will definitely be subscribing and donating to your patreon in the future! (once covid is over and I have a job again ):)

kysk
Автор

I was struggling to learn Python.Even I took a course to learn Python.But I will Thumbs UP to you for explaining all the topic in such a easy.Your videos are the best.With each video, I am gaining confidence.

sfsc
Автор

You literally explained lists and dictionaries in the simplest terms possible. Thank you so much, I don’t know why professors cannot be like this. You literally gave me more of a clear understanding with the logic and the syntax behind creating dictionary lists with keys and values, as opposed to how my professor does it. Thanks so much. I subscribed. Looking forward to more tutorials.

Vintagetube
Автор

Corey has the best Python tutorial in my 3 years of trying about everything

raymondtan
Автор

I already took a graduate course for intro level Python-- and your videos are honestly better! chugging through the beginner videos as a refresher and I cannot wait to jump into the more advanced topics. I feel so lucky for finding such a great resource-- and it was easy, your videos are so widely reccomended! Thank you for developing such an great and accessible course.

xxPingPangPow
Автор

+ Methods : 3:00

.get(<key>)

del dictname[<key>]
.pop(<key>)
len()
.keys()
.values()
.items()

+ Looping : 8:10

for key, value in students.items()

shreyaschavhan
Автор

The 9 minutes of this tutorial is far better than the 1 hour tutorial I learned from Udemy . Thanks, Corey

AnkitSharma-umml
Автор

BEST TUTORIAL glad I found it recommending it to all my friends in college

yadneshkhode
Автор

Mr. Schafer, I've never felt so close to learning these concepts after spending so many Python courses... I will be donating for sure.

mahshidpooladvand
Автор

What a Legend! Someone going out of his way just to make knowledge available to others... that is Special. Congratulations Corey, these videos are awesome !

goncalosd
Автор

Just wanted to say you are awesome. Thanks for the videos.

AmDsusFmajAm
Автор

Finally someone who explains this stuff in a much simpler and less confusing way. Thank you so much!

valeriatapia
Автор

These tutorials are some of the best that I have seen out and cover a wide assortment of topics from Beginner to Advanced. Great Work Man!

alecwilliams
Автор

Finally, I a feeling confident about programming, I have been trying from so many months just to learn the concepts I have given so many attempts before this as well. Just to memorize the concepts all the time. However, back in the time I found that stuff really difficult to remember. Now with these videos, I can learn how to code and it is really easy to memorize the concepts as well, the way you explain things, it is really awesome, I really appreciate your work.


Thank you,
Mudhit Kumar

mudhitkumar
Автор

Hey Corey, I know these videos are geared towards beginners like myself - and also a few years old at this point - but it would be helpful to explain how each concept in the tutorials are used in the real world, beyond just printing out values.

Hopefully this makes sense! Thank you for the instruction - I appreciate your teaching style

etcredsox
Автор

You are saving all of my bacon. I didn't know anything about dictionaries before entering into grad school that assumed I was very familiar with them. This is everything. Thank you~~~

kimpierce
Автор

It so funny I put "find me a video that explains sets and dictionaries in py better than my professor " into ChatGPT and it recommended me this Corey's content. So cool.

michaelyaacoub
Автор

You deserve 10 million subs, You are simply amazing!!

hdv-qn