Python_중간발표

데이터사이언스학과 M2015228 조재환


In [1]:
drinks={
    'martini' : {'vodka', 'vermouth'},
    'black russian' : {'vodka', 'kahlua'},
    'white russian' : {'cream', 'kahlua', 'vodka'},
    'manhattan' : {'rye', 'vermouth', 'bitters'},
    'screwdriver': {'orange juice', 'vodka'},
    'verorange' : {'orange juice', 'vermouth'},
    'kahlua milk' : {'kahlua', 'milk'},
    'jin tonic' : {'jin', 'tonic water'},
    'mojito' : {'rum', 'lime juice'},
    'cinderella' : {'orange juice', 'lemon juice','pineapple juice'}
    }

In [2]:
inputs = input('what do you want? ')
print('Here are some Recipt:')

for name, contents in drinks.items():
    if inputs in contents:
        print(name)


what do you want? rum
Here are some Recipt:
mojito

In [19]:
morse = {
    '.-':'A','-...':'B','-.-.':'C','-..':'D','.':'E','..-.':'F',
    '--.':'G','....':'H','..':'I','.---':'J','-.-':'K','.-..':'L',
    '--':'M','-.':'N','---':'O','.--.':'P','--.-':'Q','.-.':'R',
    '...':'S','-':'T','..-':'U','...-':'V','.--':'W','-..-':'X',
    '-.--':'Y','--..':'Z', '':' '
}

In [18]:
code = '.... .  ... .-.. . . .--. ...  . .- .-. .-.. -.--'

In [20]:
senten = input("What's going on? ")
senten = ".".join(senten)
senten = senten.split('.')
print(senten)


What's going on? am late
['a', 'm', ' ', 'l', 'a', 't', 'e']

In [21]:
for dot, capi in morse.items():
    if capi in senten:
        print(dot,end=" ")
        print(morse.get(dot), end=" ")