Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

math.sin() not returning proper value

Hello I have an equation I am trying to calculate using python. Where
The desired output I am looking for is 1.71528

Below I have my current code with all of the current values d should equal 100 and theta should equal 60.

import math

m = 0.065
g = 9.8
print("Input the distance to professor")
d = 100 # float(input())
k = 25
print("Now input the value for theta")
theta = 60 # float(input())

x = math.sqrt(m*g*d/k*math.sin(2 * theta))
print(x, 'meters')

The output I get when I run this code is 1.2163047715819324 meters

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I think my issue is something with math.sin any help would be appreciated thanks.

>Solution :

Convert to theta to radians and put brackets around the denominator.

x = math.sqrt(m*g*d/(k*math.sin(2 * math.radians(theta))))
print(f"{x:.5f} meters")

Will result in

Input the distance to professor
100
Now input the value for theta
60
1.71528 meters
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading