Black Friday Special: Free $500 CourseHorse Gift Card with Eligible Certificate Program Purchase. Terms & Conditions Apply.

Dictionary in Python

Free Video Tutorial and Guide

In this video, we're going to look at how to manage data using Dictionary in Python

Video Transcription

Python for Data Science Bootcamp: Live & Hands-on, In NYC or Online, Learn From Experts, Free Retake, Small Class Sizes,  1-on-1 Bonus Training. Named a Top Bootcamp by Forbes, Fortune, & Time Out. Noble Desktop. Learn More.

Hi, my name is Art and I teach Python at Noble Desktop. In this video, I'll explain dictionaries to you. Remember that Python has built-in data types like integers, floats, strings, and lists. How do you initialize a dictionary?

First, come up with a variable name, like 'd', and use curly braces. To check if it's a dictionary, use the 'type' function and it should return 'dictionary'.

Before I give you a formal definition of a dictionary, let me show you how we can populate the dictionary with data. Suppose this is my phone book, and I have a friend named John. John is the key, and 'Manhattan' is the value. We can add another friend, Mary, her phone number, and also Mark and his phone number.

A dictionary is a completely different collection than what we've seen so far - it is a collection of items, where each item has a key and a value, separated by a colon and each item separated by a comma. Keys must be unique.

It's easy to update values - just use the key and assign a new value. To see all keys, use the 'keys' function. To fetch a value, use the key in square brackets. To update a value, use the key in square brackets and assign a new value.

Watch my other videos to learn how to use a 'for' loop to iterate through a dictionary.

How to Learn Python

Master Python with hands-on training. Python is a popular object-oriented programming language used for data science, machine learning, and web development. 

Yelp Facebook LinkedIn YouTube Twitter Instagram