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?
if self.x < 25:
self.g = 'f'
elif self.x < 50:
self.g = 'e'
elif self.x < 70:
self.g = 'd'
elif self.x < 80:
self.g = 'c'
elif self.x < 90:
self.g = 'b'
else:
self.g = 'a'