Example #1
0
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 cleanAndWrite(wd,hmap,sensids):
    file = open("pickleOutput/" + wd + "_output.p","wb")
    mainDict = {}
    tempList = []
    for sid in sensids: #outer loop for going through all sense-ids
        dict1={}
        list1 = hashmap.get(hmap,sid)
        for othersid in sensids: #inner for loop 
            if sid==othersid:   #if both sense-ids are same, move forward
                continue
            else:
                l1 = hashmap.get(hmap,othersid)
                hashmap.delete(hmap,othersid)
                if list1:
                    for word in list1:  #check if word from outer loop is in inner
                        dict1[word]=1
                        #print(word)
                        if l1:
                            if word in l1:
                                dict1[word]=dict1[word]+1
                                l1.remove(word)
                    hashmap.set(hmap,othersid,l1)
        dict2 = dict1.copy()
        for key in dict2:
            if dict2[key]>1:
                del dict1[key]
        mainDict[sid] = dict1.keys()
        tempList.append(sid)
        for item in dict1.keys():
            tempList.append(item)
        tempList.append("-")
    #print(mainDict["bank%1:17:02::"])
    #print(mainDict)
    #print(tempList)
    pickle.dump(tempList,file)
    file.close()
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)
Example #4
0
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')
assert hashmap.get(cities, 'NY') == 'New York', "Error: city/state not exists!"

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
Example #5
0
# 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')
assert hashmap.get(cities, 'NY') == 'New York'

# 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 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'))
assert hashmap.get(cities, hashmap.get(states, 'Florida')) == 'Jacksonville'

# print every state abbreviation
# print '-' * 10
Example #6
0
hashmap.set(states, 'New York', 'NY')
hashmap.set(states, 'Hawaii', 'HI')

# create a basic set of states and some cities in them
cities = hashmap.new()
hashmap.set(cities, 'CA', 'Los Angeles')
hashmap.set(cities, 'HI', 'Honolulu')
hashmap.set(cities, 'FL', 'Orlando')

# 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("HI State has: %s" % hashmap.get(cities, 'HI'))

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

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

# print every state abbreviation
print('-' * 10)
hashmap.list(states)
Example #7
0
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 cites
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 has: %s" % hashmap.get(states, 'Michigan')
print "Florida has: %s" % hashmap.get(states, 'Florida')

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

# print every city in state
print '-' * 10
hashmap.list(cities)
Example #8
0
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
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)
Example #9
0
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')

# do it by using the state the cities dict
print '-' * 10
print "Lazio has: %s" % hashmap.get(cities, hashmap.get(regions, 'Lazio'))
print "Lombardi has: %s" % hashmap.get(cities, hashmap.get(regions, 'Lombardi'))

# print every state abbreviation
print '-' * 10
hashmap.list(regions)
Example #10
0
hashmap.set(states, 'New York', 'NY')
hashmap.set(states, 'Hawaii', 'HI')

#oreate a basio set of states and  some oities in them
cities = hashmap.new()
hashmap.set(cities, 'CA', 'Los Angeles')
hashmap.set(cities, 'Hi', 'Honolulu')
hashmap.set(cities, 'FL', 'Orlando')

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

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

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

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

# print every state abbreviaiton
print('-' * 10)
hashmap.list(states)
Example #11
0
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
assert "New York" in hashmap.get(cities, 'NY')
#assert "New York" in hashmap.get(cities, 'NY')
assert "Portland" in hashmap.get(cities, 'OR')

# print some states
print '-' * 10
assert "MI" in hashmap.get(states, 'Michigan')
#print "Michigan's abbreviation is: %s" % hashmap.get(states, 'Michigan')
assert "FL" in hashmap.get(states, 'Florida')
#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'))
Example #12
0
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")

cities = hashmap.new()
hashmap.set(cities, "CA", "San Francisco")
hashmap.set(cities, "MI", "Detroit")
hashmap.set(cities, "FL", "Jacksonville")
hashmap.set(cities, "NY", "New York")
hashmap.set(cities, "OR", "Portland")

print('-' * 50)
print("NY state has:", hashmap.get(cities, "NY"))
print("OR state has:", hashmap.get(cities, "OR"))

print('-' * 50)
print("Michigan's abbreviation is :", hashmap.get(states, "Michigan"))
print("Florida's abbreviation is :", hashmap.get(states, "Florida"))

print('-' * 50)
print("Michigan has :", hashmap.get(cities, hashmap.get(states, "Michigan")))
print("Florida has  :", hashmap.get(cities, hashmap.get(states, "Florida")))

print('-' * 50)
hashmap.printList(states)

print('-' * 50)
hashmap.printList(cities)
Example #13
0
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)
Example #14
0
hashmap.set(states, 'New York', 'NY')
hashmap.set(states, 'Michigan', 'MI')

#create a mapping 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', 'Jacksonvillo')

# 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: %" % hashmap.get(cities, 'NY')
print "NY State has: %" % hashmap.get(cities, 'OR')

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

# do itby using the state then cities dict
print '_' * 10
print "Michigan has: %s" % hasmap.get(cities, hasmap.get(states, 'Michigan'))
print "Florida has: %s" % hasmap.get(cities, hasmap.get(states, 'Florida'))

#print every state abbreviation
print '_' * 10
hashmap.list(states)
Example #15
0
import hashmap

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

print hashmap.get(states, 'california')
Example #16
0
hashmap.set(states, 'New York', 'NY')
hashmap.set(states, 'Michigan', 'MI')

# create a basic set of states nad 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 has %s" % hashmap.get(cities, hashmap.get(states, 'Michigan')))
print("Florida has %s" % hashmap.get(cities, 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 abbrevation
print('-' * 10)
Example #17
0
hashmap.set(states, 'New York', 'NY')
hashmap.set(states, 'Hawaii', 'HI')

# create a basic set of states amd some cities in them
cities = hashmap.new()
hashmap.set(cities, 'CA', 'Los Angeles')
hashmap.set(cities, 'HI', 'Honolulu')
hashmap.set(cities, 'FL', 'Orlando')

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

# print out some cities
print('-' * 10)
print("Hawaii's abbreviation is: %s" % hashmap.get(states, 'Hawaii'))
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)
hashmap.set(states, 'Florida', 'FL')
hashmap.set(states, 'California', 'CA')
hashmap.set(states, 'New York', 'NY')
hashmap.set(states, 'Michigan', 'MI')

cities = hashmap.new()
hashmap.set(cities, 'CA', 'San Francisco')
hashmap.set(cities, 'MI', 'Detroit')
hashmap.set(cities, 'FL', 'Jacksonville')

hashmap.set(cities, 'NY', 'New York')
hashmap.set(cities, 'OR', 'Portland')


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

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

print '-' * 10
values = []
for state in hashmap.get(states, 'Michigan'):
	values += hashmap.get(cities, state)
print "Michigan has: %s" % values

print '-' * 10
hashmap.list(states)
Example #19
0
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')
hashmap.set(cities, 'NY', 'New York')
hashmap.set(cities, 'OR', 'Portland')

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

print "Michigan's abbreviation is: %s" % hashmap.get(states, 'Michigan')
print "Florida's abbreviation is: %s" % hashmap.get(states, 'Florida')

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 '-'*10
hashmap.list(states)

print '-'*10
hashmap.list(cities)
hashmap.set(states, '云南', '滇')

# create a basic set of states and some cities in them
cities = hashmap.new()
hashmap.set(cities, '川', '成都')
hashmap.set(cities, '浙', '杭州')
hashmap.set(cities, '黔', '贵阳')

# add some more cities
hashmap.set(cities, '渝', '江北')
hashmap.set(cities, '滇', '丽江')


# print out some cities
print '-' * 10
print "川 有: %s" % hashmap.get(cities, '川')
print "滇 有: %s" % hashmap.get(cities, '滇')

# print some states
print '-' * 10
print "重庆的简称是: %s" % hashmap.get(states, '重庆')
print "浙江的简称是: %s" % hashmap.get(states, '浙江')

# do it by using the state then cities dict
print '-' * 10
print "重庆有: %s" % hashmap.get(cities, hashmap.get(states, '重庆'))
print "浙江有: %s" % hashmap.get(cities, hashmap.get(states, '浙江'))

# print every state abbreviation
print '-' * 10
hashmap.list(states)
Example #21
0
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():
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, 'Florida')))

#print every state abbreviation
print('-'*10)
hashmap.list(cities)
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')
hashmap.set(cities, 'NY', 'New York')
hashmap.set(cities, 'NY', 'Rochester')
hashmap.set(cities, 'OR', 'Portland')

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

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

# do it by using the state then cities dict
print '-' * 10
print "Michigan's abbreviation is: ", hashmap.get(cities, hashmap.get(states, 'Michigan')[0])
print "Florida's abbreviation is: ", hashmap.get(cities, hashmap.get(states, 'Florida')[0])

# print every abbreviation
print '-' * 10
hashmap.list(states)
Example #24
0
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 some cities ", hashmap.get(cities,'NY')
print "OR state has some cities ", hashmap.get(cities,'OR')

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

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

#print every state abbreviation
print '--'* 10
hashmap.list(states)
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')

cities = hashmap.new()
hashmap.set(cities, 'CA', 'San Fran')
hashmap.set(cities, 'MI', 'Detroit')
hashmap.set(cities, 'FL', 'Jacksonville')

hashmap.set(cities, 'NY', 'New York')
hashmap.set(cities, 'OR', 'Portland')

print '_' * 10
print "NY state has: %s" % hashmap.get(cities, 'NY')
print "OR state has %s" % hashmap.get(cities, 'OR')

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

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 '_' * 10
hashmap.list(states)

print '_' * 10
hashmap.list(cities)
Example #26
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()
Example #27
0
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)
Example #28
0
hashmap.set(states, 'DKI Jakarta', 'DKI')
hashmap.set(states, 'Sumatra Utara', 'Sumut')

# create a basic set of states and some cities in them
cities = hashmap.new()
hashmap.set(cities, 'Jabar', 'Bandung')
hashmap.set(cities, 'Jatim', 'Surabaya')
hashmap.set(cities, 'DKI', 'Jakpus')

# add some more cities
hashmap.set(cities, 'Kalsel', 'Pangandaran')
hashmap.set(cities, 'Sumut', 'Medan')

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

# print some states
print '-' * 10
print "Jawa Barat's abbreviation is: %s" % hashmap.get(states, 'Jawa Barat')
print "Kalimantan Selatan's abbreviation is: %s" % hashmap.get(
    states, 'Kalimantan Selatan')

# do it by using the state then cities dict
print '-' * 10
print "Jawa Barat has: %s" % hashmap.get(cities,
                                         hashmap.get(states, 'Jawa Barat'))
print "DKI Jakarta has: %s" % hashmap.get(cities,
                                          hashmap.get(states, 'DKI Jakarta'))
Example #29
0
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)
Example #30
0
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
assert hashmap.get(cities, 'NY') is "New York"
assert hashmap.get(cities, 'OR') == "Portlan", "Bad value found!"

#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'))
Example #31
0
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
assert hashmap.get(cities, 'NY') == 'New York'
assert hashmap.get(cities, 'OR') == 'Portland'
print "NY State has: %s" % hashmap.get(cities, 'NY')
print "OR State has %s" % hashmap.get(cities, 'OR')

# print some states
print '-' * 10
assert hashmap.get(states, 'Michigan') == 'MI'
assert hashmap.get(states, 'Florida') == 'FL'
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'))
Example #32
0
hashmap.set(states, 'Michigan', 'MI')

# creates 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')
assert "New York" == hashmap.get(cities, 'NY')
print "OR State has: %s" % hashmap.get(cities, 'OR')
assert "Portland" == 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 states then the cities hashmap
print '-' * 10
print "Michigan has: %s" % hashmap.get(cities, hashmap.get(states, 'Michigain'))
print "Florida has: %s" % hashmap.get(cities, hashmap.get(states, 'Florida'))

# print every state abbreviation
Example #33
0
hashmap, set(cities, 'OR', 'Portland')

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

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

# do it by using the state then cities diet
print('-' * 10)
print('Hawaii has: %s' % hashmap. get(cities, hashmap. get(states, 'Hawaii')))
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")
Example #34
0
hashmap.set(cities, 'FL', 'Jacksonville')

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


# I am not typing out this line anymore
def line(dashes):
    """ Takes a number of dashes to print for a visual line-break"""
    print '-' * dashes


# print out some cities
line(10)
print "NY State has: {0}".format(hashmap.get(cities, 'NY'))
print "OR State has: {0}".format(hashmap.get(cities, 'OR'))

# print some states
line(10)
print "Michigan's abbreviation is: {0}".format(hashmap.get(states, 'Michigan'))
print "Florida's abbreviation is: {0}".format(hashmap.get(states, 'Florida'))

# do it by using the state then cities dict
line(10)
print "Michigan has: {0}".format(
    hashmap.get(cities, hashmap.get(states, 'Michigan')))
print "Florida has: {0}".format(
    hashmap.get(cities, hashmap.get(states, 'Florida')))

# print every state abbreviation
import hashmap

# Tests that it will work.

jazz = hashmap.new()
hashmap.set(jazz, 'Miles Davis', 'Flamenco Sketches')
assert hashmap.get(jazz, 'Miles Davis') == 'Flamenco Sketches', "Failed Flamenco test."


# confirms set will replace previous one
hashmap.set(jazz, 'Miles Davis', 'Kind of Blue')
assert hashmap.get(jazz, 'Miles Davis') == 'Kind of Blue', "Failed Kind of Blue test."

hashmap.set(jazz, 'Duke Ellington', 'Beginning to See the Light')
assert hashmap.get(jazz, 'Duke Ellington') == 'Beginning to See the Light', "Failed test."

hashmap.set(jazz, 'Billy Strayhorn', 'Lush Life')
assert hashmap.get(jazz, 'Billy Strayhorn') == 'Lush Life', "Failed test."
# assert that Miles Davis is unchanged
assert hashmap.get(jazz, 'Miles Davis') == 'Kind of Blue', "Failed Kind of Blue test."

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

# These replaced by assertions above
# print "---- Get Test ----"
# print hashmap.get(jazz, 'Miles Davis')
# print hashmap.get(jazz, 'Duke Ellington')
# print hashmap.get(jazz, 'Billy Strayhorn')

print "---- Delete Test ----"
Example #36
0
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')

cities = hashmap.new()
hashmap.set(cities, 'CA', 'San Francisco')
hashmap.set(cities, 'MI', 'Detroit')
hashmap.set(cities, 'FL', 'Jacksonville')
hashmap.set(cities, 'NY', 'New York')
hashmap.set(cities, 'OR', 'Portland')

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

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

print "3", '-' * 10
print "Michigan has:", hashmap.get(cities, hashmap.get(states, 'Michigan'))
print "Florida has:", hashmap.get(cities, hashmap.get(states, 'Florida'))

print "4", '-' * 10
print hashmap.list(states)

print "5", '-' * 10
print hashmap.list(cities)
Example #37
0
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 '-' * 10
print hashmap.dump
'''
# 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'))
Example #38
0
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)
Example #39
0
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.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')

cities = hashmap.new()
hashmap.set(cities, 'CA', 'San Francisco')
hashmap.set(cities, 'MI', 'Detroit')
hashmap.set(cities, 'FL', 'Jacksonville')

hashmap.set(cities, 'NY', 'New York')
hashmap.set(cities, 'OR', 'Portland')

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

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

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

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

print '-' * 10
state = hashmap.get(states, 'Texas')
Example #41
0
hashmap.set(states, 'DKI Jakarta', 'DKI')
hashmap.set(states, 'Sumatra Utara', 'Sumut')

# create a basic set of states and some cities in them
cities = hashmap.new()
hashmap.set(cities, 'Jabar', 'Bandung')
hashmap.set(cities, 'Jatim', 'Surabaya')
hashmap.set(cities, 'DKI', 'Jakpus')

# add some more cities
hashmap.set(cities, 'Kalsel', 'Pangandaran')
hashmap.set(cities, 'Sumut', 'Medan')

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

# print some states
print '-' * 10
print "Jawa Barat's abbreviation is: %s" % hashmap.get(states, 'Jawa Barat')
print "Kalimantan Selatan's abbreviation is: %s" % hashmap.get(states, 'Kalimantan Selatan')

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

# print every state abbreviation
print '-' * 10
hashmap.list(states)
Example #42
0
# -*- 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)
Example #43
0
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)
Example #44
0
hashmap.set(cities, 'HE', 'Wiesbaden')
hashmap.set(cities, 'NI', 'Hannover')
hashmap.set(cities, 'MV', 'Schwerin')
hashmap.set(cities, 'NW', 'Duesseldorf')

# add some more cities
hashmap.set(cities, 'RP', 'Mainz')
hashmap.set(cities, 'SL', 'Saarbruecken')
hashmap.set(cities, 'SN', 'Dresden')
hashmap.set(cities, 'ST', 'Magdeburg')
hashmap.set(cities, 'SH', 'Kiel')
hashmap.set(cities, 'TH', 'Erfurt') ## VANF HIER VERDER

# print out some cities
print '-' * 10
print "HH State has: %s" % hashmap.get(cities, 'HH')
print "HE State has: %s" % hashmap.get(cities, 'HE')
print "NI State has: %s" % hashmap.get(cities, 'NI')
print "MV State has: %s" % hashmap.get(cities, 'MV')
print "NW State has: %s" % hashmap.get(cities, 'NW')


# print some states
print '-' * 10
print "Rheinland-Pfalz's abbreviation is: %s" % hashmap.get(states, 'Rheinland-Pfalz')
print "Saarland's abbreviation is: %s" % hashmap.get(states, 'Saarland')
print "Freistaat Sachsen's abbreviation is: %s" % hashmap.get(states, 'Freistaat Sachsen')
print "Sachsen-Anhalt's abbreviation is: %s" % hashmap.get(states, 'Sachsen-Anhalt')
print "Schleswig-Holstein's abbreviation is: %s" % hashmap.get(states, 'Schleswig-Holstein')

Example #45
0
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)
else:
	print "Yes %s(%s) was visited" %(rqst,st)

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)
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
print '-' * 10
hashmap.list(statesList)

# print every city in state
print '-' * 10
hashmap.list(citiesList)
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')

cities = hashmap.new()
hashmap.set(cities, 'CA', 'San Francisco')
hashmap.set(cities, 'MI', 'Detroit')
hashmap.set(cities, 'FL', 'Jacksonville')
hashmap.set(cities, 'NY', 'New York')
hashmap.set(cities, 'OR', 'Portland')

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

print "=" * 10
print "Michigan is: %s" % hashmap.get(states, 'Michigan')
print "Florida is:  %s" % hashmap.get(states, 'Florida')

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 "=" * 10
hashmap.list(cities)

print "=" * 10
state = hashmap.get(states, "Texas")
Example #49
0
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, 'FL'))

# 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)
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)

print "** Goodbye Billy"
hashmap.delete(jazz, "Billy Strayhorn")
hashmap.list(jazz)
Example #51
0
hashmap.set(cities, 'NY', 'New York')
hashmap.set(cities, 'OR', 'Portland')

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

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

# do it by using the state then cities dict
print('-' * 10)
test1 = hashmap.get(cities, hashmap.get(states, 'Michigan'))
print(f"Michigan has: {test1}")
test2 = hashmap.get(cities, hashmap.get(states, 'Florida'))
print(f"Florida has: {test2}")

# 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')
Example #52
0
hashmap.set(states, 'Hawaii', 'HI')

# create a basic set of states and some cities in them
cities = hashmap.new()
hashmap.set(cities, 'CA', 'Los Angeles')
hashmap.set(cities, 'HI', 'Honolulu')
hashmap.set(cities, 'FL', 'Orlando')

#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 "Hawaii's abbreviation is: %s" % hashmap.get(states, "Hawaii")
print "Florida's abbreviation is: %s" % hashmap.get(states, 'Florida')

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

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

# The tests that 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)

print "**Goodbye Billy"
hashmap.delete(jazz, "Billy Strayhorn")
hashmap.list(jazz)
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)
Example #55
0
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 abbreciation is :%s" % hashmap.get(states, "Michigan")
print "Florida's abbreviation is:%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)
Example #56
0
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')

# 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
Example #57
0
#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("*" * 20)
print("NY state has:%s" % hashmap.get(cities, "NY"))
print("OR state has:%s" % hashmap.get(cities, "OR"))

#print some states

print("*" * 20)
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("*" * 20)
hashmap.list(states)

#print every city in state