2

I'm working a small program that calculates the trajectory of an object fired on certain planetary bodies, then plots them with Turtle graphics. Currently, I'm stuck on an issue with a Type Error that I can't seem to figure out.

So, here is the stack:

Traceback (most recent call last):
File "MY FILEPATH", line 174, in <module> main()
File "MY FILEPATH", line 153, in main
    x1,y1 = xtoy(dist(velo,ang,grav),velo,ang,grav,i)
File "MY FILEPATH", line 66, in xtoy
    sety = int(dist*tan(ang)-(grav*dist**2)/(2*velo**2*cos*((cos(ang)))))
TypeError: unsupported operand type(s) for *: 'int' and 'builtin_function_or_method'

and here is a pastebin of the code.

http://pastebin.com/aY0fhGEV

I am absolutely stumped, and have been wracking my brain for a week. Any help would be truly appreciated.

2 Answers 2

3

You have 2 * cos. This is trying to multiply the number 2 times the function cos. You need to take the cosine of something in the second part. Perhaps you meant 2*cos(ang)*cos(ang)?

Sign up to request clarification or add additional context in comments.

1 Comment

@user1724602 The same goes for your own functions like dist.
1

You have an extra * after the second to last cos, which treats it like a built-in instead of evaluating an argument.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.