Could anybody help me with this topology question?

i) Prove that every map e: X-> R^n is homotopic to a constant map.

ii) If f: X->S^n is a map that is not onto (surjective), show that f is homtopic to a constant map.

It's part of a past exam paper but it does not come with solutions. Any help on the solution would be greatly appreciated.

Thanks.