Call argument from multi returned arguments function using Python

Question:

By using Python : I want to call just one argument from defined function (Angles) which return two arguments theta and phi. How can I call just theta value from Angles funcition and assign it to x value?

values = [1,-1]    
g = np.random.choice(values)
q= np.random.choice(values)   
def Angles ():
    theta = (((1 + g*g - ((1 - g*g)/(1 - g + 2*g*q))**2)/(2*g)))
    phi = 2 * math.radians(180) * q
    return theta,phi

x = cos(theta)
Asked By: user19314723

||

Answers:

You have to call Angles first; theta will be the first element of the tuple returned by Angles.

th, ph = Angles()
x = cos(th)

or

x = cos(Angles()[0])
Answered By: chepner
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.