RUVIDEO
Поделитесь видео 🙏

Python Dictionary - Dict Object Type Tutorial with Examples - APPFICIAL

In Python, a dictionary stores data as key-value pairs. Like a real dictionary book, when you look up a word for the definition, the word is the key, and the definition is the value. For example, if you look up Appficial, it should say something like “Best programming YouTube channel ever, and you should subscribe right now!”.

The object type for a dictionary is called a dict. Although it sounds like a funny word, you can easily create a dict object by using curly braces { } to surround the key-value pairs in your dictionary, with each key-value separated by a comma. You can create a dictionary of Detroit Pistons basketball players as follows:

pistons= {11:’Isaiah Thomas’, 4:’Joe Dumars’}
print(pistons)

You can create an empty dictionary by using empty curly braces.

Ex:
my_dict = { } # empty dict
big_dict = {1:’A’, 2:’B’, 3:’C’, 4:’D’, …. }

You would typically use a dictionary where key-value pair relationships exist. It might make more sense to store an associated relationship as a value to a key. For example, a person’s phone number can be a key, and an associative relationship as the value can include the persons name, address, date of birth, and so on.

Accessing dictionary entries

Dictionaries cannot be accessed by an index number, like you can with a list. Instead, access each value in a dictionary by passing the key inside square backets []. If no results are found, then you get a KeyError runtime error while your program is running, and it crashes.

Adding, modifying, and removing dictionary entries

A dictionary is mutable, so you can add new entries or update existing ones as needed. To add a new dictionary entry:

pistons[40] = ‘Billy Laimbeer’ #adds a new key-value pair, it it didn’t already exist in the dictionary
Pistons[10] = ‘Dennis Rodman’

To update an existing dictionary entry:

pistons[40] = ’Bill Laimbeer’ #updates the name for key number 40

To remove a dictionary entry:

del pistons[10] #deletes Dennis Rodman, since he got traded from the pistons


Subscribe to Appficial for more programming videos coming soon. Also, don't forget to click LIKE and comment on the video if it helped you out!

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Python Dictionary - Dict Object Type Tutorial with Examples - APPFICIAL», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.