コード例 #1
0
ファイル: ex39_test.py プロジェクト: pholton/PyTraining
def main():
    # create a mapping of state to abbreviation
    states = hashmap.new()
    hashmap.set(states, 'Oregon', 'OR')
    hashmap.set(states, 'Florida', 'FL')
    hashmap.set(states, 'California', 'CA')
    hashmap.set(states, 'New York', 'NY')
    hashmap.set(states, 'Michigan', 'MI')

    # create a basic set of states and some cities in them
    cities = hashmap.new()
    hashmap.set(cities, 'CA', 'San Francisco')
    hashmap.set(cities, 'MI', 'Detroit')
    hashmap.set(cities, 'Fl', 'Jacksonville')

    # add some more cities
    hashmap.set(cities, 'NY', 'New York')
    hashmap.set(cities, 'OR', 'Portland')


    # print out some cities
    print '-' * 10
    print 'NY State has: %s' % hashmap.get(cities, 'NY')
    print "OR State has: %s" % hashmap.get(cities, 'OR')

    # print some states
    print '-' * 10
    print "Michigan's abbreviation is: %s" % hashmap.get(states, 'Michigan')
    print "Florida's abbreviation is: %s" % hashmap.get(states, 'Florida')

    # do it by using the state then cities dict
    print '-' * 10
    print "Michigan has: %s" % hashmap.get(cities, hashmap.get(states, "Michigan"))
    print "Florida has: %s" % hashmap.get(cities, hashmap.get(states, "Florida"))

    # print every state abbreviation
    print '-' * 10
    hashmap.list(states)

    #print every city in state
    print '-' * 10
    hashmap.list(cities)

    print '-' * 10
    state = hashmap.get(states, "Texas")

    if not state:
        print "Sorry, no Texas."

    # default values using ||= with the nil result
    # can you do this in one line?
    city = hashmap.get(cities, 'TX', 'Does Not Exist')
    print "The city for the state 'TX' is: %s" % city
def writeToTrain(wd):
    fname = wd.split('.')[0]
    f1 = open("trainInstances/"+fname+"_train.instance","r")
    context = False
    dict1=hashmap.new()
    sensids = []
    for line in f1:
        if line.startswith("<answer instance"):
            split_for_sensid = line.split()[2]
            #print(split_for_sensid)
            sid = split_for_sensid[9:-3]
            if sid not in sensids:
                sensids.append(sid)
            continue
        if line.startswith("<context"):
            context = True
            continue
        if line.startswith("</context"):
            context = False
            continue
        if context and (not line.startswith("<instance")) and (not line.startswith("</instance")) and (not line.startswith("<answer")):
            newList = []
            list1 = hashmap.get(dict1,sid)
            splitLine = line.split()
            if list1:
                hashmap.delete(dict1,sid)
                for word in splitLine:
                    #print(word)
                    if word not in list1:
                        list1.append(word.lower())
                hashmap.set(dict1,sid,list1)
            else:
                for word in splitLine:
                    if word not in newList:
                        #print(word)
                        newList.append(word.lower())
                hashmap.set(dict1,sid,newList)
    cleanAndWrite(fname,dict1,sensids)
コード例 #3
0
import hashmap

# create a mapping of state to abbreviation
states = hashmap.new(10)
hashmap.set(states, 'Oregon', 'OR')
hashmap.set(states, 'Florida', 'FL')
hashmap.set(states, 'California', 'CA')
hashmap.set(states, 'New York', 'NY')
hashmap.set(states, 'Michigan', 'MI')

# create a basic set of states and some cities in them
cities = hashmap.new(10)
hashmap.set(cities, 'CA', 'San Francisco')
hashmap.set(cities, 'MI', 'Detroit')
hashmap.set(cities, 'FL', 'Jacksonville')

# add some more cities
hashmap.set(cities, 'NY', 'New York')
hashmap.set(cities, 'OR', 'Portland')

# print out some cities
print '-' * 10
print "NY State has: %s" % hashmap.get(cities, 'NY')
print "OR State has: %s" % hashmap.get(cities, 'OR')

# print some states
print '-' * 10
print "Michigan's abbreviation is: %s" % hashmap.get(states, 'Michigan')
print "Florida's abbreviation is: %s" % hashmap.get(states, 'Florida')

# do it by using the state then cities dict
コード例 #4
0
import hashmap

# create a mapping of state to abbreviation
statesList = hashmap.new()
hashmap.set(statesList, 'Oregon', 'OR')
hashmap.set(statesList, 'Florida', 'FL')
hashmap.set(statesList, 'California', 'CA')
hashmap.set(statesList, 'New York', 'NY')
hashmap.set(statesList, 'Michigan', 'MI')

# create a basic set of states and some cities in them
citiesList = hashmap.new()
hashmap.set(citiesList, 'CA', 'San Francisco')
hashmap.set(citiesList, 'MI', 'Detroit')
hashmap.set(citiesList, 'FL', 'Jacksonville')

#add some more cities
hashmap.set(citiesList, 'NY', 'New York')
hashmap.set(citiesList, 'OR', 'Portland')

# print some states
print '-' * 10
print "Michigan has: %s" % hashmap.get(citiesList, 'MI')
print "Florida has: %s" % hashmap.get(citiesList, 'FL')

# do it by using the state then cities dict
print '-' * 10
print "Michigan has: %s" % hashmap.get(citiesList, hashmap.get(statesList, 'Michigan'))
print "Florida has: %s" % hashmap.get(citiesList, hashmap.get(statesList, 'Florida'))

# print every abbreviation
コード例 #5
0
import hashmap

sample = hashmap.new()
print "empty dict: "
print sample

hashmap.set(sample, "key1", "value1")
hashmap.set(sample, "key2", "value2")
hashmap.set(sample, "key3", "value3")
hashmap.set(sample, "apples", "bananas")

print "hash_key: "
print hashmap.hash_key(sample, "key1")
print hashmap.hash_key(sample, "key2")
print hashmap.hash_key(sample, "key3")
print hashmap.hash_key(sample, "apples")

print "get_bucket: "
print hashmap.get_bucket(sample, "key1")

print "get_slot: "
print hashmap.get_slot(sample, "key1")
print hashmap.get_slot(sample, "key2")
print hashmap.get_slot(sample, "key3")

print "dictionary again: "
print sample

print "list: "
print hashmap.list(sample)
コード例 #6
0
import hashmap

#create a mapping of state to abbreviation
states = hashmap.new()
hashmap.set(states, 'Oregon', 'OR')
hashmap.set(states, 'Florida', 'FL')
hashmap.set(states, 'California', 'CA')
hashmap.set(states, 'New York', 'NY')
hashmap.set(states, 'Michigan', 'MI')

#create a basic set of states and some cities in them
cities = hashmap.new()
hashmap.set(cities, 'CA', 'San Francisco')
hashmap.set(cities, 'MI', 'Detroit')
hashmap.set(cities, 'FL', 'Jacksonville')

#add some more cities
hashmap.set(cities, 'NY', 'New York')
hashmap.set(cities, 'OR', 'Portland')

#print out some cities
print '-' * 10
print "NY State has: %s" % hashmap.get(cities, 'NY')
print "OR State has: %s" % hashmap.get(cities, 'OR')

#print some states
print '-' * 10
print "Michigan's abbreviation is: %s" % hashmap.get(states, 'Michigan')
print "Florida's abbreviation is: %s" % hashmap.get(states, 'Florida')

#do it by using the stats then cities dict
コード例 #7
0
import hashmap_d

states = hashmap_d.new()
hashmap_d.set(states,'Oregon','OR')


cities = hashmap_d.new()
hashmap_d.set(cities,'CA','San Francisco')

print '-' * 20
print "%s"% hashmap_d.get(cities,'CA')

import hashmap
states = hashmap.new()
hashmap.set(states,'CN','china')
hashmap.set(cities,'china','Beijing')

print '-' * 20
print "%s"% hashmap.get(states,'CN')

hashmap.get_slot(cities,'CN','china')
hashmap.list(states)
hashmap.list(cities)

mystuff = {'apple':'I am apples!'}
print mystuff['apple']

def apple():
	print "i am apples!"

apple()
コード例 #8
0
import hashmap

# create a mapping of state to abbreviation
states = hashmap.new(10)
hashmap.set(states, 'Oregon', 'OR')
hashmap.set(states, 'Florida', 'FL')
hashmap.set(states, 'California', 'CA')
hashmap.set(states, 'New York', 'NY')
hashmap.set(states, 'Michigan', 'MI')

# create a basic set of states and some cities in them
cities = hashmap.new(10)
hashmap.set(cities, 'CA', 'San Francisco')
hashmap.set(cities, 'MI', 'Detroit')
hashmap.set(cities, 'FL', 'Jacksonville')

# add some more cities
hashmap.set(cities, 'NY', 'New York')
hashmap.set(cities, 'OR', 'Portland')


# print out some cities
print '-' * 10
print "NY State has: %s" % hashmap.get(cities, 'NY')
print "OR State has: %s" % hashmap.get(cities, 'OR')

# print some states
print '-' * 10
print "Michigan's abbreviation is: %s" % hashmap.get(states, 'Michigan')
print "Florida's abbreviation is: %s" % hashmap.get(states, 'Florida')
コード例 #9
0
ファイル: ex39_testSD.py プロジェクト: 20MESC/LPTHW
import hashmap

# create a mapping of state to abbreviation
regions = hashmap.new()
hashmap.set(regions, 'Calabria', 'CB')
hashmap.set(regions, 'Campania', 'CM')
hashmap.set(regions, 'Lazio', 'LZ')
hashmap.set(regions, 'Lombardi', 'LB')
hashmap.set(regions, 'Tuscany', "TC")

# create a basic set of regions and add some cities in them
cities = hashmap.new()
hashmap.set(cities, 'CB', 'Catanzaro')
hashmap.set(cities, 'CP', 'Naples')
hashmap.set(cities, 'LZ', 'Rome')

# add some more cities
hashmap.set(cities, 'LB', 'Milan')
hashmap.set(cities, 'TC', 'Florence')


# print out some cities
print '-' * 10
print "CB has: %s" % hashmap.get(cities, 'CB')
print "LZ has: %s" % hashmap.get(cities, 'LZ')

# print some regions
print '-' * 10
print "Calabria's abbreviation is: %s" % hashmap.get(regions, 'Calabria')
print "Tuscany's abbreviation is: %s" % hashmap.get(regions, 'Tuscany')
コード例 #10
0
import hashmap

provinces = hashmap.new()
# Dutch provinces; key is province name, value is its largest city
hashmap.set(provinces, 'North Holland', 'Amsterdam')
hashmap.set(provinces, 'South Holland', 'Rotterdam')
hashmap.set(provinces, 'Utrecht', 'Utrecht')
hashmap.set(provinces, 'Zeeland', 'Middelburg')
hashmap.set(provinces, 'Groningen', 'Groningen')
hashmap.set(provinces, 'Limburg', 'Maastricht')
hashmap.set(provinces, 'Flevoland', 'Almere')
hashmap.set(provinces, 'North Brabant', 'Den Bosch')
hashmap.set(provinces, 'Friesland', 'Leeuwarden')
hashmap.set(provinces, 'Drenthe', 'Assen')
hashmap.set(provinces, 'Gelderland', 'Nijmegen')
hashmap.set(provinces, 'Overijssel', 'Enschede')

hashmap.list(provinces)
print '-' * 10
print hashmap.get(provinces, 'Drenthe')
コード例 #11
0
import hashmap
country = hashmap.new()
hashmap.set(country, 'VietNam', 'VN')
hashmap.set(country, 'ThaiLan', 'TL')
hashmap.set(country, 'Malaysia', 'ML')
city = hashmap.new()
hashmap.set(country,'VN', 'HaNoi')
hashmap.set(country, 'TL', 'BangKok')
hashmap.set(country, 'ML', 'Kualalumpur')
print "Viet Nam duoc viet gon la: ", hashmap.get(country, 'VietNam')
print "Thu do cua Viet Nam la: ", hashmap.get(city, 'VN')
print "Danh sach: "
hashmap.list(country)
hashmap.list(city)
コード例 #12
0
import hashmap

# create a mapping of state to abbreviation
states = hashmap.new()  # Initializes a Map with the given number of buckets.
hashmap.set(
    states, 'Oregon', 'OR'
)  # In the Map, sets the key to the value, replacing any existing value.
hashmap.set(states, 'Florida', 'FL')
hashmap.set(states, 'California', 'CA')
hashmap.set(states, 'New York', 'NY')
hashmap.set(states, 'Michigan', 'MI')

# create a basic set of states and their capitals
cities = hashmap.new()
hashmap.set(cities, 'CA', 'Sacramento')
hashmap.set(cities, 'MI', 'Lansing')
hashmap.set(cities, 'FL', 'Tallahassee')

# add some more capitals
print '-' * 10
print "NY State has: %s" % hashmap.get(cities, 'NY')
print "OR State has: %s" % hashmap.get(cities, 'OR')

# print some states
print '-' * 10
print "Michigan's abbreviation is: %s" % hashmap.get(states, 'Michigan')
print "Florida's abbreviation is: %s" % hashmap.get(states, 'Florida')

assert hashmap.get(states, 'Michigan') == 'MI'

# do it by using the state dict, then the cities dict
コード例 #13
0
import hashmap

# create a mapping of animal to genus (not necessarily accurate)
animals = hashmap.new()
hashmap.set(animals, 'Dog', 'Canine')
hashmap.set(animals, 'Cat', 'Feline')
hashmap.set(animals, 'Human', 'Sapien')
hashmap.set(animals, 'Wolf', 'Canine')
hashmap.set(animals, 'Jellyfish', 'Scyphozoa')
hashmap.set(animals, 'Octopus', 'Octopus')

# create a basic set of animals and some sounds for them
sounds = hashmap.new()
hashmap.set(sounds, 'Canine', 'woof')
hashmap.set(sounds, 'Sapien', 'hello world')
hashmap.set(sounds, 'Scyphozoa', '...')

# add some more sounds
hashmap.set(sounds, 'Feline', 'meow')
hashmap.set(sounds, 'Octopus', '...')


# print out some sounds
print '-' * 10
print "Wolves make %s sounds" % hashmap.get(sounds, 'Canine')
print "Humans make %s sounds" % hashmap.get(sounds, 'Sapien')

# print some genii
print '-' * 10
print "Dog is of genus %s" % hashmap.get(animals, 'Dog')
print "Octopus is of genus %s" % hashmap.get(animals, 'Octopus')
コード例 #14
0
import hashmap

aMap = hashmap.new()
hashmap.set(aMap,10,"ten")
hashmap.set(aMap,20,"twenty")
print hashmap.get(aMap,10)
print "Old hashmap:"
hashmap.list(aMap)
hashmap.delete(aMap,10)
hashmap.set(aMap,20,"2*10")
print "New hashmap:"
hashmap.list(aMap)


コード例 #15
0
ファイル: visited.py プロジェクト: gssakib/python-projects
import hashmap

#states that I visited and their abbreviations
states = hashmap.new()

hashmap.set(states, 'New-York', 'NY')
hashmap.set(states, 'Texas', 'TX')
hashmap.set(states, 'Massachusetts', 'MA')
hashmap.set(states, 'Rhode-Island', 'RI')
hashmap.set(states, 'Florida', 'FL')
hashmap.set(states, 'Maine', 'ME')
hashmap.set(states, 'Connecticut', 'CT')

#countries I have visited and the continent

countries = hashmap.new()

hashmap.set(countries, 'USA', 'North-America')
hashmap.set(countries, 'Bangladesh', 'Asia')
hashmap.set(countries, 'India', 'Asia')
hashmap.set(countries, 'Saudi-Arabia', 'Asia')
hashmap.set(countries, 'UAE', 'Asia')
hashmap.set(countries, 'Canada', 'North-America')

print "Please input the name of the state you think you visited."
rqst = raw_input(">>>>>>>>>  ")

st = hashmap.get(states, rqst, 'Not-Visited')

if st == 'Not-Visited':
    print "Nope,%s is %s" % (rqst, st)
コード例 #16
0
ファイル: ex39_2.py プロジェクト: kuiwa/learngit
# -*- coding: utf-8 -*-

import hashmap

# create a mapping of state to abbreviation
#states = hashmap.new()
#hashmap.set(states, 'New York', 'NY')
cities = hashmap.new()
hashmap.set(cities, 'NY', 'New York')

print '-' * 10
print "NY State has: %s" % hashmap.get(cities, 'NY')

#print "OR State has: %s" % hashmap.get(states, 'OR')
# print every state abbreviation
#print '-' * 10
#hashmap.list(states)
コード例 #17
0
ファイル: test.py プロジェクト: drwit/2015SummerPython
import hashmap
	
x = hashmap.new()
print x

#print hashmap.hash_key(x, 'shit')
#print hashmap.hash_key(x, 'shit')
#print hashmap.hash_key(x, 'apple')
#print hashmap.hash_key(x, 4)
#print hashmap.hash_key(x, 88)
#print hashmap.hash_key(x, 4)
#print hashmap.hash_key(x, 250)
#print hashmap.hash_key(x, 258)
#print hashmap.hash_key(x, 2)

y = [1,2,3,4,5]

for i, j in enumerate(y):
	print i, j
	
yy = [[0,1], [1,2], [2,3], [3,4]]	
for i, kv in enumerate(yy):
	print kv
	k, v = kv
	print k,v
コード例 #18
0
print '->' * 5, "def set(aMap, key, default=None)",'<-' * 5
print "getting set(aMap, key, value)"
set1 = hashmap.set(aMap, key, value)
i, k, v = get_slot
print "bucket = ", bucket
print "i, k, v = ", i, k, v
print "aMap contents: ",aMap
print '=' *50

print '->' * 5, "def get(aMap, key, default=None)",'<-' * 5
print "getting get(aMap, key, default=None)"
get = hashmap.get(aMap, key)
print "returns v: = ", get

print '-' * 10, "Reverse engineer part 2", '-' * 10
aMap1 = hashmap.new() # creates aMap1 dict
hashmap.set(aMap1, 'key1', 'value1') # sets value for aMap, key, value. 
# bucket gets get_bucket(aMap, key)
# where 
# i, k, v gets get_slot
# where get_slot(aMap, key, default=None) aMap = aMap1, key = 'key1', default=None = 'value1' 
print aMap1
# print "this is hash_key = ", test1
# print "this is the hash(key) '%' len(aMap) = hash_key = ", test1
# test2 = hashmap.get_bucket('a', 1)
# print "this is get_bucket =", test2
# print "this is the hash_key(aMap, key) = bucket_id = ", test1
# print "aMap[bucket_id] = ", test2
# print "this is def get_slot variable bucket =", test2
# test3 = test2
# print "bucket = ", test3
コード例 #19
0
import hashmap

states = hashmap.new()
hashmap.set(states, 'california', 'CA')

print hashmap.get(states, 'california')
コード例 #20
0
#Learnpythonthehardway
# Exercise 39 - hashmap example

import hashmap

# create a mapping of state to abbreviation
races = hashmap.new()
hashmap.set(races, 'Dwarf', 'DWF')
hashmap.set(races, 'Elf', 'ELF')
hashmap.set(races, 'Halfling', 'HLF')
hashmap.set(races, 'Human', 'HUM')
hashmap.set(races, 'Dragonborn', 'DRG')
hashmap.set(races, 'Gnome', 'GNM')
hashmap.set(races, 'Half-elf', 'HEF')
hashmap.set(races, 'Half-orc', 'HOC')
hashmap.set(races, 'Tiefling', 'TFL')

# create a basic set of states and some cities in them
traits = hashmap.new()
hashmap.set(traits, 'DWF', 'Dwarven Combat Training')
hashmap.set(traits, 'ELF', 'Elf Weapon Training')
hashmap.set(traits, 'HLF', 'Naturally Stealthy')
hashmap.set(traits, 'HUM', 'Feat Bonus')
hashmap.set(traits, 'DRG', 'Breath Weapon')

# add some more cities
hashmap.set(traits, 'GNM', 'Gnome Cunning')
hashmap.set(traits, 'HEF', 'Skill Versatility')
hashmap.set(traits, 'HOC', 'Relentless Endurance')
hashmap.set(traits, 'TFL', 'Infernal Legacy')
コード例 #21
0
# Extra exercise.
# Date: 2014-16-25

import hashmap

# The tests that it will work.

jazz = hashmap.new()
hashmap.set(jazz, 'Miles Davis', 'Flamenco Sketches')
# confirms set will replace previous one
hashmap.set(jazz, 'Miles Davis', 'Kind Of Blue')
hashmap.set(jazz, 'Duke Ellington', 'Beginning To See The Light')
hashmap.set(jazz, 'Billy Strayhorn', 'Lush Life')

print "---- List Test ----"
hashmap.list(jazz)

print "---- Get Test ----"
print hashmap.get(jazz, 'Miles Davis')
print hashmap.get(jazz, 'Duke Ellington')
print hashmap.get(jazz, 'Billy Strayhorn')

print "---- Delete Test ----"
print "** Goodbye Miles"
hashmap.delete(jazz, "Miles Davis")
hashmap.list(jazz)

print "** Goodbye Duke"
hashmap.delete(jazz, "Duke Ellington")
hashmap.list(jazz)
コード例 #22
0
ファイル: ex39_test.py プロジェクト: LuckyJoey/Python
import hashmap
import collections
# states = hashmap.new()
# hashmap.set(states, "Oregon", "OR")

cities = hashmap.new()
hashmap.set(cities, "SZ", "shenzhen")
hashmap.set(cities, "BJ", "beijing")

print('-' * 10)
#
print("Shenzen:", hashmap.get(cities, "SZ"))
print("Beijing:", hashmap.get(cities, "BJ"))
# print("OR:",hashmap.get(states, "Oregon"))
# print("ABC:", hashmap.get(states, "abc"))

print('-' * 10)
hashmap.list(cities)

print("==" * 20)
print(hashmap.get(cities, "GZ", "Dont Exit"))

testOrderDict = {}
testOrderDict['1'] = "a"
testOrderDict['3'] = 'dc'
testOrderDict['2'] = 'fc'
new = collections.OrderedDict(sorted(testOrderDict.items()),
                              key=lambda t: t[1])
for k, v in testOrderDict.items():
    print("OrderDict:", k)
for k, v in new.items():
コード例 #23
0
# The Exercise 39 Test Suite
# Various function calls to test hashmap.py, which is
# part of Exercise 39.

import hashmap

# create a mapping of state to abbreviation
states = hashmap.new()
hashmap.set(states, 'Oregon', 'OR')
hashmap.set(states, 'Florida','FL')
hashmap.set(states, 'California','CA')
hashmap.set(states, 'New York','NY')
hashmap.set(states, 'Michican','MI')

# create a basic set of states and some cities in them
cities = hashmap.new()
hashmap.set(cities, 'CA', 'San Francisco')
hashmap.set(cities, 'MI', 'Detroit')
hashmap.set(cities, 'FL', 'Jacksonville')

# add some more cities
hashmap.set(cities, 'NY', 'New York')
hashmap.set(cities, 'OR', 'Portland')

# print out some citiies
print '-' * 10
print "NY State has: %s" % hashmap.get(cities, 'NY')
print "OR State has: %s" % hashmap.get(cities, 'OR')

# print some states
print '-' * 10
コード例 #24
0
ファイル: visited.py プロジェクト: gssakib/python-projects
import hashmap

#states that I visited and their abbreviations
states = hashmap.new()

hashmap.set(states, 'New-York','NY')
hashmap.set(states, 'Texas','TX')
hashmap.set(states, 'Massachusetts','MA')
hashmap.set(states, 'Rhode-Island','RI')
hashmap.set(states, 'Florida','FL')
hashmap.set(states, 'Maine','ME')
hashmap.set(states, 'Connecticut','CT')


#countries I have visited and the continent

countries = hashmap.new()

hashmap.set(countries,'USA','North-America')
hashmap.set(countries,'Bangladesh','Asia')
hashmap.set(countries,'India','Asia')
hashmap.set(countries,'Saudi-Arabia','Asia')
hashmap.set(countries,'UAE','Asia')
hashmap.set(countries,'Canada','North-America')

print "Please input the name of the state you think you visited."
rqst = raw_input(">>>>>>>>>  ")

st = hashmap.get(states, rqst, 'Not-Visited')

if st == 'Not-Visited':
コード例 #25
0
ファイル: test.py プロジェクト: helenwang2014/python-practice
import hashmap

# create a mapping of state to abbreviation
states = hashmap.new()
hashmap.set(states, 'Oregon', 'OR')
hashmap.set(states, 'Florida', 'FL')
hashmap.set(states, 'California', 'CA')
hashmap.set(states, 'New York', 'NY')
hashmap.set(states, 'Michigan', 'MI')

# create a basic set of states and some cities in them
cities = hashmap.new()
hashmap.set(cities, 'CA', 'San Francisco')
hashmap.set(cities, 'MI', 'Detroit')
hashmap.set(cities, 'FL', 'Jacksonville')

# add some more ciites
hashmap.set(cities, 'NY', 'New York')
hashmap.set(cities, 'OR', 'Portland')

#print out some ciites
print '_' * 10
print 'NY State has: %s' % hashmap.get(cities, 'NY')
print 'OR State has: %s' % hashmap.get(cities, 'OR')


#print some states
print '_' * 10
print "Michigan's abbreviation is: %s" % hashmap.get(states, 'Michigan')

print "Florida's abbreviation is: %s" % hashmap.get(states, 'Florida')
コード例 #26
0
ファイル: quote.py プロジェクト: cyanlime/StudyPython
import hashmap

if __name__ == "__main__":
    amap = hashmap.new()
    print amap
    num = hashmap.hash_key(amap, 3)
    print num
    value = hashmap.get_bucket(amap, 3)
    print value

    print hashmap.get_slot(amap, 3)