178k views
4 votes
1. Write a program that prints a table showing the sin, cos, and tan values for the uncommon angles (15, 20, 70, and 140). Make sure that the values are displayed only up to 4 significant digits.​

1 Answer

6 votes

Answer:

import math

# Print a table header

print("Angle (deg) | Sin | Cos | Tan")

print("-------------|-----|-----|-----")

# Calculate and print the values for each angle

for angle in [15, 20, 70, 140]:

radians = math.radians(angle)

sin = round(math.sin(radians), 4)

cos = round(math.cos(radians), 4)

tan = round(math.tan(radians), 4)

print(f"{angle:>10} | {sin:>4} | {cos:>4} | {tan:>4}")

Step-by-step explanation:

This program first imports the math module, which provides functions for performing mathematical operations. It then prints a table header with column titles.

Next, it loops through the list of angles, calculates the sin, cos, and tan values for each angle in radians, and rounds each value to 4 significant digits. It then prints the angle, sin value, cos value, and tan value for each angle in a formatted string.

User Adam Mikulski
by
5.0k points