Is that valid Python? I think you mean:
mood_scale = {
'-30':"Panic",
'-20':'Fear',
'-10':'Concern',
'0':'Normal',
'10':'Satisfaction',
'20':'Happiness',
'30':'Euphoria'}
print mood_scale[str(min(map(int,mood_scale)))]
print mood_scale[str(max(map(int,mood_scale)))]
Outputs
Panic
Euphoria
Much better and faster with ints as keys
mood_scale = {
-30:"Panic",
-20:'Fear',
-10:'Concern',
0:'Normal',
10:'Satisfaction',
20:'Happiness',
30:'Euphoria'}
print mood_scale[min(mood_scale))]
print mood_scale[max(mood_scale))]
Edit 2:
Is much faster using the iterator
print timeit.timeit( lambda: mood_scale[min(mood_scale.keys())])
print timeit.timeit( lambda: mood_scale[min(mood_scale)])
1.05913901329
0.662925004959
Another solution could be to keep track of the max/min values upon insertion and simply do
mood_scale.min() / max()