If you want a random integer values between -40 and +40, then
import random
random.randint(-40, 40)
https://docs.python.org/3.1/library/random.html#random.randint
If you want to choose either -40 or +40, then
import random
random.choice([-40, 40])
https://docs.python.org/3/library/random.html#random.choice
If you really prefer to go with your implementation of choosing either 1 or 2, as in your question, then plug in those values in random.choice method.
Provided the above solutions, since I feel there is some ambiguity in the question.