Im trying to make something... Help? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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?

24th Sep 2019, 10:27 PM
Momo
Momo - avatar
17 Answers
+ 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?
25th Sep 2019, 12:35 AM
Momo
Momo - avatar
+ 1
I guess I'm talking for most people here if i say: What angle are you talking about?
25th Sep 2019, 12:20 AM
Lexfuturorum
Lexfuturorum - avatar
+ 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.
25th Sep 2019, 12:24 AM
Momo
Momo - avatar
+ 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.
25th Sep 2019, 12:28 AM
Lexfuturorum
Lexfuturorum - avatar
+ 1
I still don't see a problem(and there is no need for else)
25th Sep 2019, 12:43 AM
Lexfuturorum
Lexfuturorum - avatar
+ 1
True, but it says invalid syntax when I do x -= 180 ^
25th Sep 2019, 12:44 AM
Momo
Momo - avatar
+ 1
Same problem with x = x - 180?
25th Sep 2019, 12:45 AM
Lexfuturorum
Lexfuturorum - avatar
+ 1
I'll try that.
25th Sep 2019, 12:47 AM
Momo
Momo - avatar
+ 1
How should I set input to equal a variable like x? It says it's not defined.
25th Sep 2019, 12:49 AM
Momo
Momo - avatar
+ 1
Define it with x = 0
25th Sep 2019, 12:52 AM
Lexfuturorum
Lexfuturorum - avatar
+ 1
Now it's saying there is a problem with: if x > 180 ^
25th Sep 2019, 12:55 AM
Momo
Momo - avatar
+ 1
With or without the :
25th Sep 2019, 12:57 AM
Lexfuturorum
Lexfuturorum - avatar
+ 1
With
25th Sep 2019, 12:58 AM
Momo
Momo - avatar
+ 1
OK send the whole statement
25th Sep 2019, 12:58 AM
Lexfuturorum
Lexfuturorum - avatar
+ 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)
25th Sep 2019, 1:01 AM
Momo
Momo - avatar
+ 1
Kinda the same trick if x > 179:
25th Sep 2019, 1:08 AM
Lexfuturorum
Lexfuturorum - avatar
+ 1
I'll work on this later, if you want to help, see what you can do. Goodnight!
25th Sep 2019, 1:12 AM
Momo
Momo - avatar