Question: I need to compose a program using python 3 that uses math.sin() and math.cos() to check that the value of cos^2(x) + sin^2(x) is close
I need to compose a program using python 3 that uses math.sin() and math.cos() to check that the value of cos^2(x) + sin^2(x) is close to 1.0 for an x entered as a command line argument. Here is my code but I am getting an error saying that theta, or x in the question, is not defined what am I doing wrong?
import math import sys
a = float(sys.argv[1])
theta = int(a)
stdio.write("Theta is: ") stdio.write(theta)
stdio.writeln( "" ) #Line Break
value = math.pow(math.cos(theta), 2) + math.pow(math.sin(theta), 2)
stdio.write("Value is: ") stdio.write(value)
stdio.writeln( "" ) #Line Break
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
