Python Programming · High School (11–12) · 2 courses, 21 worked problems, 40 practice questions
Sine and cosine describe anything that repeats, from a swinging pendulum to an alternating current. In Python, np.sin() and np.cos() work on whole arrays of angles in radians, so one line can draw a full wave. Changing the amplitude , the frequency or the phase in changes the shape, and a graph makes the change easy to see. Adding two waves in code shows interference and beats. You can also check identities such as with numbers.
Choose an answer, then check it. Each one shows a full explanation.
A sprinkler arm turns through 84 degrees. What does this print? import math; print(round(math.radians(84), 3))
An angle of 2.2 radians is changed to degrees. What does this print? import math; print(round(math.degrees(2.2), 1))
Which call gives the sine of an angle of 35 degrees?
A loop prints cosines of three angles. What does this print? import math; print(*[round(math.cos(math.radians(d))) for d in (0, 90, 180)])
Each one has a hint, the key idea and a full worked solution.
A program draws y = 6 * np.sin(4 * x - 1). What is the amplitude of the wave?
A list of angles in degrees. What does this print? import numpy as np; x = np.arange(0, 181, 30); print(len(x), x[-1])
Why is the tangent changed with t[np.abs(t) > 8] = np.nan before it is plotted?
A check of an identity on three angles. What does this print? import numpy as np; a = np.radians(np.array([10, 20, 30])); print(np.allclose(np.sin(a) ** 2 + np.cos(a) ** 2, 1))
Why compare np.sin(a) ** 2 + np.cos(a) ** 2 with 1 using np.allclose and not ==?
The true sine of a sum and the false rule, side by side. What does this print? import numpy as np; a, b = np.radians(25), np.radians(65); print(round(float(np.sin(a + b)), 2), round(float(np.sin(a) + np.sin(b)), 2))