CSC 171 - Introduction to Computer Programming

Lab Assignment #16 - Working with Mathematical functions

Due Monday, November 6, 2023

Computers were originally about doing mathematical work. Lots of mathematical work. And you can do this in Python.

To access all the math functions that we will want to use, you need to start by writing
import math

This will give you access to all the built-in math functions that we will need.

We will start by look at three trigonometric functions: sin , cos, and tan

We can write them:


x = math.sin(rads)
y = math.cos(rads)
z = math.tan(rads)

Please keep in mind that the argument is in radians, NOT degrees. You can convert degrees into radians by multiplying by math.pi and dividing by 180.

Write three functions mysin(), mycos(), mytan(), that will accept an angle in degrees and will use math.sin, math.cos, and math.tan to return the sine, cosine and for an angle.

Have the main program use mysin(), mycos(), and mytan() to print a trig table for angles from 1 degree to 89 degrees.

All you will turn in here is your program and output.

[Back to the Lab Assignment List]