Python Forum
Problem with the math.sin(x) function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with the math.sin(x) function
#2
(Feb-21-2019, 04:36 PM)Carson147 Wrote: However when I tested some values they come close but doesn't match my phone's calculator, I'm not sure what went wrong.
please provide sample input, output and presumably correct output from your phone
Actually I see the problem
on line 7 you convert the user input to degrees (but it is already in degrees). You need to convert the user input to radians
from math import sin
from math import degrees
from math import radians
 
user_input = input('Enter an angle in degrees >')
degs = int(user_input)
rads = radians(degs)
answer = sin(rads)
print('The sin of {} degrees is {}'.format(degs, answer))
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: Problem with the math.sin(x) function - by buran - Feb-21-2019, 04:42 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  math problem for experts miltmobley 5 1,128 Jul-09-2023, 07:14 AM
Last Post: Gribouillis
  math.log versus math.log10 stevendaprano 10 2,542 May-23-2022, 08:59 PM
Last Post: jefsummers
  Why getting ValueError : Math domain error in trig. function, math.asin() ? jahuja73 3 3,877 Feb-24-2021, 05:09 PM
Last Post: bowlofred
  matrices math problem lokoprof 1 2,253 Aug-27-2018, 07:48 PM
Last Post: perfringo
  Math problem python Dhaval 1 2,986 Jun-05-2017, 10:28 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020