title: Arrange into group based on integer value
body: <p>So I'm mostly looking for advice on how I could tidy up my code. I've got a class that's got an integer instance variable, x \in [0, 100]. I want to assign each instance a letter grade (instance variable g) based on its x value. Is there a better/more concise way of doing this than using lots of if, elif, else statements?</p>
  <pre><code>if self.x &lt; 25:
     self.g = 'f'
  elif self.x &lt; 50:
     self.g = 'e'
  elif self.x &lt; 70:
     self.g = 'd'
  elif self.x &lt; 80:
     self.g = 'c'
  elif self.x &lt; 90:
     self.g = 'b'
  else:
     self.g = 'a'
  </code></pre>