The sine and cosine function (sin and cos) are easily two of the most important (and fun) functions in all of mathematics.
This lesson will introduce you to their use just a bit. Most programming languages recognize sin and cos via their names. Here,
sin and cos are known as sin and cos, like this:
sin(a-number) and cos(a-number)
Move the mouse over a dotted box for more information.
Note that you can also use the functions math.sin and math.cos. They work the same as sin and cos. So for if you wanted to use math.sin
to take the sin of $90^\circ$, you'd do math.sin(math.pi/2). For your convenience, we also have two more function defined, called dcos and dsin. These take
the sine and cosine as usual, but you can put in the angle in degrees (which is convenient). So you can program dcos(90) or dsin(65) to take
the cos or sin of 90, or 65 degrees.
Now you try. Try displaying the dsin and dcos of a few numbers. Try numbers like 0 and 90 and see if the results
match what you may have learned in your math class.
Type your code here:
See your results here:
Share your code
Show a friend, family member, or teacher what you've done!