Ask coding questions

← Back to all posts
How would I do this?
MaciahLawson (32)

How would I turn these Trigonometry functions to use user input?

Comments
hotnewtop
IMayBeMe (473)

To get a user input just use the input() function like this with a variable:

x = input('Enter your num: ')
y = input('Enter your second num: ')
MaciahLawson (32)

@IMayBeMe I have already tried that and I get a syntax error.....
Traceback (most recent call last):
File "main.py", line 8, in <module>
print("math.cos(",x,"): ", math.cos(x));
TypeError: must be real number, not str

IMayBeMe (473)

@MaciahLawson Oh sorry, I forgot to mention that you have to convert the input to a float by doing this:

x = float(input('Enter your number: '))
y = float(input('Enter your second number: '))