215k views
3 votes
The trigonometry book says: sin^2(t) + cos^2(t) = 1 Write a Python program that verifies the formula with the help of the Python Math module. Note that the trigonometric functions in the module act on the angles in radians. Your program should perform the following steps 3 times: 1. Pick a random number between 0 and 180 degrees representing an angle in degrees, say Dangle 2. Convert the angle from degrees to radians, say Rangle 3. Use the Math module to find and print the values of sin(Rangle) and cos(Rangle), and 4. Compute and print the value of the above expression: sin^2(Rangle) + cos^2(Rangle). You can then visually verify if the result printed is 1 (or close to it).

User Wyatt
by
4.9k points

1 Answer

2 votes

Answer:

If you open your python-3 console and execute the following .py code you will have the following output. (Inputing 20 e.g)

Write the angles in degrees: 20

radian angles is: 0.3490658503988659

cosene( 0.3490658503988659 ) = 0.9396926207859084

sine( 0.3490658503988659 ) = 0.3420201433256687

sin^2( 0.3490658503988659 ) + cos^2( 0.3490658503988659 ) = 1.0

Step-by-step explanation:

Code

import math

for i in range(1,4):

angle = int(input('Write the angles in degrees: '))

#mat library better works with radians

angle_radians = (angle*math.pi)/180

#print output

print('radian angles is: ',angle_radians)

print('cosene(',angle_radians,') = ',math.cos(angle_radians))

print('sine(',angle_radians,') = ',math.sin(angle_radians))

res = (math.sin(angle_radians))**2 + (math.cos(angle_radians))**2

print('sin^2(',angle_radians,') + cos^2(',angle_radians,') = ',res)

User Henri Menke
by
5.9k points