5.7 연습문제

  • 5.1
    # zoo.py
    def hours():
    return 'Open 9-5 daily'
    
  • 5.2
    import zoo as menagerie
    
      ModuleNotFoundError Traceback (most recent call last)
      <ipython-input-2-0f421f5e024b> in <module>()
      ----> 1 import zoo as menagerie
    
      ModuleNotFoundError: No module named 'zoo'
    
  • 5.3
    from zoo import hours
    
      ModuleNotFoundError Traceback (most recent call last)
      <ipython-input-3-52ff1fe5c7c6> in <module>()
      ----> 1 from zoo import hours
    
      ModuleNotFoundError: No module named 'zoo'
    
  • 5.4
    from zoo import hours as info
    
  • 5.5
    from pprint import pprint
    from collections import OrderedDict
    plain = {
    'a':1,
    'b':2,
    'c':3
    }
    pprint(plain)
    

    {‘a’: 1, ‘b’: 2, ‘c’: 3}

  • 5.6
    fancy = OrderedDict(plain)
    
    fancy
    

    OrderedDict([(‘a’, 1), (‘b’, 2), (‘c’, 3)])

    from collections import defaultdict
    dict_od_lists = defaultdict(int)
    
    dict_od_lists['a'] = 'something for a'
    
    dict_od_lists['a']
    

    ‘something for a’

Comments