title: Modular addition in python
body: <p>I want to add a number y to x, but have x wrap around to remain between zero and 48. Note y could be negative but will never have a magnitude greater than 48. Is there a better way of doing this than:</p>
  
  <pre><code>x = x + y
  if x &gt;= 48:
      x = x - 48
  elif x &lt; 0:
      x = x + 48
  </code></pre>
  
  <p>?</p>