t136.py
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 import dict, list
00019
00020
00021
00022 if 1:
00023 d = {}
00024 d[0] = "zero"
00025 d["one"] = 1
00026 print d
00027 print dict.keys(d)
00028 print dict.values(d)
00029
00030 dict.clear(d)
00031 print d
00032 d['new'] = "more"
00033 print d
00034
00035 print "d has key 'new' = ", dict.has_key(d, 'new')
00036 print "d has key 'old' = ", dict.has_key(d, 'old')
00037
00038
00039
00040 if 1:
00041 foo = [0]
00042 list.append(foo, 1)
00043 print foo
00044
00045 list.extend(foo, [2, 2])
00046 print foo
00047
00048
00049 print list.count(foo, 1)
00050 print list.count(foo, 2)
00051 print list.count(foo, 42)
00052
00053 print list.index(foo, 0)
00054
00055 list.insert(foo, 0, "zero")
00056 list.insert(foo, -1, "penultimate")
00057 print foo
00058
00059 print list.pop(foo)
00060 print list.pop(foo, 2)
00061 print foo
00062
00063 list.remove(foo, 2)
00064 list.remove(foo, "zero")
00065 print foo
00066
00067 list.append(foo, "bob")
00068 print list.index(foo, "bob")
00069 print list.index(foo, "z")
00070