this first question on stack overflow, please comment on how improve on asking questions.
this feel pertinent part of code.
#import libraries numpy import * matplotlib.pyplot import * #leapfrog method def orbit(m1=1.0e30, m2=1.0e24, a=1.0e11, e=0.1): #conditions g=6.67*e-11 q=m1/m2 m=m1+m2 r0=(1-e)*a/(1+q) v0=1/(1+q)sqrt((1+e)/(1-e)*g*m/a) when import code receive error:
import hw5redo file "hw5redo.py", line 12 r0 = (1-e)*a/(1+q) ^ syntaxerror: invalid syntax also when comment out of code receive:
import hw5redo file "hw5redo.py", line 12 #r0=(1-e)*a/(1+q) ^ syntaxerror: invalid syntax i thought comments should not considered syntaxerrors because user only.
@rth right, please check code below, should use * before sqrt function:
def orbit(m1=1.0e30, m2=1.0e24, a=1.0e11, e=0.1): g = 6.67 * e - 11 q = m1 / m2 m = m1 + m2 r0 = (1 - e) * / (1 + q) value = (1 + e) / (1 - e) * g * m / # note value negative in case, , raise warning print value v0 = 1 / (1 + q) * sqrt(value) hope code helps you.
Comments
Post a Comment