# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Dictionaries

urls = {'google':'www.google.com', 'yahoo':'www.yahoo.com'}

urls['google']

names_ages = [('Richard',30),('Vivian',26)]

d = dict(names_ages)

d

# ## shallow copy

e = d.copy()

e

f = dict(e)

f

# ## dict.update() : add entries from one dictionary to another 

g = {'Aung': 20}

f.update(g)

f

# ### if keys are already existed in dict, values will be overwritten

stocks = {'GOOG': 981, 'AAPL': 425, 'YHOO': 25}

stocks

stocks.update( {'GOOG': 1000, 'AAPL': 600, 'YHOO': 30})

stocks

# ### iteration for dict

for item in stocks:
    print(f'{item} is currently priced at {stocks[item]}')

for value in stocks.values():
    print(value)

for key in stocks.keys():
    print(key)

# ## dict.items()

for key,value in stocks.items():
    print(f'{key} is currently priced at {value}')

# ## in / not in

'GOOG' in stocks

'STI' in stocks

# ## del keyword to remove item from dict

stocks

del stocks['YHOO']

stocks

# ## updating dict item

world = {'North America':['USA','Canada'], 'Asia':['Myanmar','Singapore']}

world

world['Asia'] += ['Thailand','Malaysia']

world

# ## pretty printing
#

from pprint import pprint as pp

pp(world)



StarcoderdataJupyterScriptsDedupFiltered