We investigate the logic by which sensory input is translated into behavioral output. First we provide a functional analysis of the entire odor receptor repertoire of an olfactory system. We construct tuning curves for the 21 functional odor receptors of the Drosophila larva and show that they sharpen at lower odor doses. We construct a 21-dimensional odor space from the responses of the receptors and find that the distance between two odors correlates with the extent to which one odor masks the other. Mutational analysis shows that different receptors mediate the responses to different concentrations of an odorant. The summed response of the entire receptor repertoire correlates with the strength of the behavioral response. The activity of a small number of receptors is a surprisingly powerful predictor of behavior. Odors that inhibit more receptors are more likely to be repellents. Odor space is largely conserved between two dissimilar olfactory systems.