+ 1
Im trying to make something... Help?
I'm trying to make a code that will solve for a Mathematical reference angle in python. I dont know how to make the code subtract from user input to solve for the reference angle. Help?
17 odpowiedzi
+ 3
Well I want the user to input an angle say 150 (which is 30 away from the x axis) and make it subtract and set as new value. Should I set user input as a variable like:
input ("Enter an angle.")
input == x
Then just subtract like:
x -= 180
x ** 2
x // 2 (I think that's root.)
>>>
30
>>>
The reason I put the square and then root is to get rid of any negatives just in case it is. I could of also done:
If x < 0:
x *= -1
else:
x += 0
Thoughts?
+ 1
I guess I'm talking for most people here if i say: What angle are you talking about?
+ 1
A reference angle is just an angle between the terminal side and the x axis. But the thing I'm asking about is how to subtract from the user input say if it's greater than 180, to subtract and set new value. If I need to teach a lesson on reference angles I can but I don't need someone to make the whole code for me, just what I specified.
+ 1
You probably talking about angle functions like sin cos and tan
And why the subtraction, a simple if statement should do the trick to set the imput to 180.
+ 1
I still don't see a problem(and there is no need for else)
+ 1
True, but it says invalid syntax when I do x -= 180
^
+ 1
Same problem with x = x - 180?
+ 1
I'll try that.
+ 1
How should I set input to equal a variable like x? It says it's not defined.
+ 1
Define it with x = 0
+ 1
Now it's saying there is a problem with:
if x > 180
^
+ 1
With or without the :
+ 1
With
+ 1
OK send the whole statement
+ 1
#terminal angle aka Reference angle...
#solver
input ("Enter an angle!")
x = 0
x = input
if x >= 180:
x = x - 180
else:
print("Working...")
print ("This is your Reference Angle: " + x)
+ 1
Kinda the same trick if x > 179:
+ 1
I'll work on this later, if you want to help, see what you can do. Goodnight!