Example #1
0
    print(accumulate)

# pprint()
qt = OrderedDict([
    ('Moe', 'A wise guy, huh?'),
    ('Larry', 'Ow!'),
    ('Curly', 'Nyuk nyuk!'),
])

print(qt)
pprint(qt)

# Things Do
# 5.1
import zoo
print(zoo.hours())

# 5.2
import zoo as menagerie
print(menagerie.hours())

# 5.3
from zoo import hours
print(hours())

# 5.4
from zoo import hours as info
print(info())

# 5.6
plain = {'a': 1, 'b': 2, 'c': 3}
#Problem 5.1: Make a file called zoo.py. In it define a function called hours that prints the string 'Open 9-5 daily'. Then, use the interpreter to import the zoo module and call its hours function.
#where zoo.py is:
def hours():
  print('Open 9-5 daily')

import zoo
zoo.hours()

#Problem 5.2: In the interpreter, import the zoo module as menagerie and call its hours function
#where zoo.py is:
def hours():
  print('Open 9-5 daily')
	
import zoo as menagerie
menagerie.hours()

#Problem 5.3: Import the hours function directly from zoo and call it.
from zoo import hours
hours()

#Problem 5.4: Import the hours() function as info and call it
from zoo import hours as info
info()

#Problem 5.5: Make a dictionary called plain with the key-vlaue pairs 'a':1,'b':2,'c':3 and print it.
plain = {'a':1,'b':2,'c':3}
print(plain)

#Problem 5.6: Make an OrderedDict called fancy from the same pairs and print it.
from collections import OrderedDict
fancy = OrderedDict([('a',1),('b',2),('c',3)])
Example #3
0

# from zoo import hours
import zoo
zoo.hours()






Example #4
0
import zoo as menagerie

print(menagerie.hours())
Example #5
0
from zoo import hours

print(hours())
Example #6
0
import zoo as menagerie

menagerie.hours()

# result
#
# Open 9-5 daily
Example #7
0
#4. import module as another name 'playpen'
import zoo as playpen
playpen.hours()

Example #8
0
def doTheThing():
    import zoo as menagerie
    print('---Thing 2---')
    menagerie.hours()
Example #9
0
#3. Call hours() in zoo
import zoo
zoo.hours()


Example #10
0
from zoo import hours

hours()
Example #11
0
def doTheThing():
    print('---Thing 3---')
    from zoo import hours
    hours()
Example #12
0
# 5-1
import zoo
zoo.hours()

# 5-2
import zoo as managerie
managerie.hours()

# 5-3
from zoo import hours
hours()

# 5-4
from zoo import hours as info
info()

# 5-5
plain = {"a": 1, "b": 2, "c": 3}
print(plain)

# 5-6
from collections import OrderedDict
fancy = OrderedDict([("a", 1), ("b", 2), ("c", 3)])
print(fancy)

# 5-7
from collections import defaultdict
dict_of_lists = defaultdict(list)
dict_of_lists["a"].append("something for a")
print(dict_of_lists["a"])
Example #13
0
import zoo

print(zoo.hours())
Example #14
0
def doTheThing():
    import zoo
    print('---Thing 1---')
    zoo.hours()
Example #15
0
import zoo as playpen

playpen.hours()
Example #16
0
#5.1
import zoo
zoo.hours()
#5.2
import zoo as menagerie
menagerie.hours()
#5.3
from zoo import hours
hours()
#5.4
from zoo import hours as info
info()
#5.5
plain = {'a': 1, 'b': 2, 'c': 3}
print(plain)
#5.6
from collections import OrderedDict
fancy = OrderedDict([
		('a', 1),
		('b', 2),
		('c', 3)
	])
print(fancy)
#5.7
from collections import defaultdict
dict_of_lists = defaultdict(list)
dict_of_lists['a'].append('something for a')
print(dict_of_lists['a'])