PYTHONYour company prints math reference tables for high sch

(PYTHON)Your company prints math reference tables for high school and first year college students. You’d like to write a flexible program that will display the results for several mathematical functions applied to a range of integers, and the results displayed in a table with a header that includes labels separated by tabs:

Num Sqr SqRt Sin Cos Tan Log Log10

=== === ==== === === === === =====

Organize your file using comments for each block of planned code

Import the math library and initialize any necessary variables

Prompt the user for the starting, ending and interval values (integers)

Print the table headers

Create a loop based on the user’s values

Print the formatted values with 2 decimal places

V

Solution

PROGRAM CODE:

# Program to calculate math function on certain intervals
import math

#getting the start and end intervals from user
start = int(input(\'Enter the starting integer: \'));
end = int(input(\'Enter the ending integer: \'));
print(\"\ Num \\tSqr \\tSqRt \\tSin \\tCos \\tTan \\tLog \\tLog10\");
print(\"=== \\t=== \\t==== \\t=== \\t=== \\t=== \\t=== \\t=====\");
num = 0; sqr = 0; sqrt = 0; sin = 0;
cos = 0; tan = 0; log = 10; logbaseTen = 0;
#using for loop to calculate for each interval
for i in range(start, end+1):
   num = i;
   sqr = i*i;
   sqrt = math.sqrt(i);
   sin = math.sin(i);
   cos = math.cos(i);
   tan = math.tan(i);
   log = math.log(i);
   logbaseTen = math.log10(i);
   print(\"%.2f\" % num,\"\\t\",\"%.2f\" % sqr,\"\\t\",\"%.2f\" % sqrt,\"\\t\",\"%.2f\" % sin,\"\\t\",\"%.2f\" % cos,\"\\t\",\"%.2f\" % tan,\"\\t\",\"%.2f\" % log,\"\\t\",\"%.2f\" % logbaseTen);

OUTPUT:

(PYTHON)Your company prints math reference tables for high school and first year college students. You’d like to write a flexible program that will display the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site