Caesar cipher exercise
Magic numbers.

Try to avoid them. 65 is really ord('A'), 90 is ord('Z'); so say that explicitly. Along the same line,

if i == ' ':


looks better than

if ord(i) == 32:

Naming

Try to use descriptive names. I'd prefer caesar_decrypt(ciphertext, shift) to shift(S, n). Same goes for A, a, etc.
Streamlining

I was really stumbled upon an asymmetry of elif and else cases of shift: 

     a = n-(90-ord(i))+64
     word += chr(a)


is quite counter-intuitive. I'd suggest

for i in S:
  if ord(i) == 32:
      word += ' '
      continue
  a = ord(i) + n
  if a &gt; ord('Z'):
      a -= ord('Z') - ord('A')
  word +=chr(a)