In: Computer Science
(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
=== === ==== === === === === =====
Write a Python program that prompts the user for a starting integer, ending integer and interval (step) value. Based on these entries, and using functions from the Python math library, calculate and display each integer (x) along with the values for: x2, sin x, cos x, tan x, log(x) and log10x .
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
import math
print "This program displays the results of several math\nfunctions
across a numeric progression"
start = input("Enter the starting integer: ")
end = input("Enter the ending integer: ")
interval = input("Enter the interval (step) vale: ")
print "Num\tSqr\tSqRt\tSin\tCos\tTan\tLog\tLog10"
print "===\t===\t===\t===\t===\t===\t===\t==="
for i in range (start, end, 3):
print
str(i)+"\t"+str(i*i)+"\t"+str(round(math.sqrt(i),2))+"\t"+str(round(math.sin(i),2))+"\t"+str(round(math.cos(i),2))+"\t"+str(round(math.tan(i),2))+"\t"+str(round(math.log(i),2))+"\t"+str(round(math.log10(i),2))
Output: