food = {
'beef': 19,
'chicken_breast': 24.7,
'turkey': 25.9,
'ham': 21,
'salami': 25,
'egg': 13.5,
'duck': 19
}
print(food)
print(food['duck'])
delicious = 'beef'
print(food[delicious])
food = {
'beef': 19,
'chicken_breast': 24.7,
'turkey': 25.9,
'ham': 21,
'salami': 25,
'egg': 13.5,
'duck': 19
}
# Count the number of key:value pairs and put in a variable.
howmany = len(food)
# Show how many.
print(howmany)
# Make data dictionary named food
food = {
'beef': 19,
'chicken_breast': 24.7,
'turkey': 25.9,
'ham': 21,
'salami': 25,
'egg': 13.5,
'duck': 19
}
# Is there an egg in food dictionary ?
print('egg' in food)
# Is there an ham in food dictionary ?
print('beans' in food)
# Look for a person.
delicious = 'turkey'
print(food.get(delicious))
# Make data dictionary named food
food = {
'beef': 19,
'chicken_breast': 24.7,
'turkey': 25.9,
'ham': 21,
'salami': 25,
'egg': 13.5,
'duck': 19
}
# Look for a food
delicious = 'beans'
print(food.get(delicious))
# Print turkey's current value
print(food['turkey'])
# Change the value of turkey key
food['turkey'] = 26.3
#Print turkey key to verify the value has updated
print(food['turkey'])
# Make a data dictionary named food.
food = {
'ham': 21,
'turkey': 25.9
}
# Change the value of the turkey key.
food.update({'turkey':26.3})
print(food)
# Update the dictionary with a new property:value pair.
food.update({'salami':25})
print(food)
# Show what's in the data dictionary now.
for value in food.keys():
print(value + " = " + food[value])