#! /usr/bin/env python
#coding=utf-8
bob = dict(name='Bob Smith', age=42, pay=30000, job='dev')
sue = dict(name='Sue Jones', age=45, pay=40000, job='hdw')
print(bob)
db = {}
db['bob'] = bob # reference in a dict of dicts
db['sue'] = sue
print(db['bob']['name']) # fetch bob's name
db['sue']['pay'] = 50000 # change sue's pay
print(db['sue']['pay'])
print(db)
for key in db:
print(key, '=>', db[key]['name'])
for key in db:
print(key, '=>', db[key]['pay'])
for key in db:
print(db[key]['name'].split()[-1])
db[key]['pay'] *= 1.10
for record in db.values():
print(record['pay'])
x = [db[key]['name'] for key in db]
print(x)
x = [rec['name'] for rec in db.values()]
print(x)
db['tom'] = dict(name='Tom', age=50, job=None, pay=0)
print(db['tom'])
print(list(db.keys()))
print([rec['age'] for rec in db.values()])
print([rec['name'] for rec in db.values() if rec['age'] >= 45])
#coding=utf-8
bob = dict(name='Bob Smith', age=42, pay=30000, job='dev')
sue = dict(name='Sue Jones', age=45, pay=40000, job='hdw')
print(bob)
db = {}
db['bob'] = bob # reference in a dict of dicts
db['sue'] = sue
print(db['bob']['name']) # fetch bob's name
db['sue']['pay'] = 50000 # change sue's pay
print(db['sue']['pay'])
print(db)
for key in db:
print(key, '=>', db[key]['name'])
for key in db:
print(key, '=>', db[key]['pay'])
for key in db:
print(db[key]['name'].split()[-1])
db[key]['pay'] *= 1.10
for record in db.values():
print(record['pay'])
x = [db[key]['name'] for key in db]
print(x)
x = [rec['name'] for rec in db.values()]
print(x)
db['tom'] = dict(name='Tom', age=50, job=None, pay=0)
print(db['tom'])
print(list(db.keys()))
print([rec['age'] for rec in db.values()])
print([rec['name'] for rec in db.values() if rec['age'] >= 45])