Python dictionaries are easy 📙

preview_player
Показать описание
#python #tutorial #course

# dictionary = a collection of {key:value} pairs
# ordered and changeable. No duplicates

capitals = {"USA": "Washington D.C.",
"India": "New Delhi",
"China": "Beijing",
"Russia": "Moscow"}

# print(dir(capitals))
# print(help(capitals))

# print("That capital exists")
# else:
# print("That capital doesn't exist")

# print(key)

# print(value)

# print(f"{key}: {value}")
Рекомендации по теме
Комментарии
Автор

# dictionary = a collection of {key:value} pairs
# ordered and changeable. No duplicates

capitals = {"USA": "Washington D.C.",
"India": "New Delhi",
"China": "Beijing",
"Russia": "Moscow"}

# print(dir(capitals))
# print(help(capitals))
# print(capitals.get("Japan"))

# if capitals.get("Russia"):
# print("That capital exists")
# else:
# print("That capital doesn't exist")

# capitals.update({"Germany": "Berlin"})
# capitals.update({"USA": "Detroit"})
# capitals.pop("China")
# capitals.popitem()
# capitals.clear()

# keys = capitals.keys()
# for key in capitals.keys():
# print(key)

# values = capitals.values()
# for value in capitals.values():
# print(value)

# items = capitals.items()
# for key, value in capitals.items():
# print(f"{key}: {value}")

BroCodez
Автор

This is the only course I can actually understand at this stage. Other courses say for "beginners"... well... maybe for someone else who is clever enough as a beginner to take those courses...

li
Автор

menu = {
"Burger": 40,
"Hotdog": 30,
"Pizza": 180,
"Chicken": 87
}

print("Menu:")
for item, price in menu.items():
print(f"{item} - {price}")


orders = []

while True:
item = input("What food would you like? ").capitalize()
if item.lower() == "done":
break
elif item not in menu:
print("Invalid item.")
continue
else:
quantity = int(input(f"How many {item}s do you want? "))
if quantity > 0:
orders.append((item, quantity))


print("You ordered:")
for order in orders:
print(f"{order[0]} x {order[1]}")

total = sum([menu[order[0]] * order[1] for order in orders])

print(f"The total amount of food is {total}pessos")

benjaminjohnpabroquez
Автор

Thank you for explaining this topic so thoroughly and preemptively answerinf follow ups one may have. This is how teaching should be

Canxxxxxc
Автор

You made this subject so interesting. Excellent teacher

gifty
Автор

One of the best explaination of python dictionaries

Thanks bro

mengekyosyaringanKamui
Автор

2:27 Also, there is a second optional argument for the get() method where you can provide a value to return if the specified key does not exist. If you don’t give get() the second argument, you will just get `None` which is a special way of saying that there isn’t a value yet.

josueramirez
Автор

Man, your teaching skills are so awesome. Thanks for helping us

harikishore
Автор

finally an explanation I understand completely and answered all of my issues, brilliant !!

lionellindley
Автор

The best python tutor for me, I love your easy and fun teaching style❤

yake
Автор

We certainly appreciate your efforts 😍

mohamad_subhi
Автор

helps remembering after reading a book. tysm!

pylejjy
Автор

For those people who are greedy with their self but you the are who really help us so many are privileged and innocent people's are here those who don't have money or own laptop these type people's are also here a huge respect to you brother 😢 you are helping us you are the teacher of us - thanks to you bro 💖

auoy_
Автор

your voice is smooth and attractive i could see you working as a narrator

gwvzghn
Автор

Very good bro! You’ve just earn a subscriber

kidfromforeign
Автор

Definition 0:07
Example 0:20
.get method: 1:55
.update method 3:23
.keys method 4:55
.values method 5:58

irvinpalacios
Автор

Mast h dekh watch this video from India 🇮🇳🥰
Bro you are great programer 😊

technicalresi
Автор

Great video as alwys. For me especially the dir() and help(). I didn't know they existed. What would a dictonairy mostly be used for and how?

VixxieWixxie
Автор

Bro, superb instructions of dictionaries and advance topics for dummies. Love how you teach, suscribed--bell rung, I'll be back. Thank you!

stevendumont
Автор

as a person who has an exam tommorow about this, thank you

mid___