I'm in my first year of CS and we use Python3. I managed to code properly and submitted it into gradescope, but it was incorrect because one decimal was missing (the 4 at the end). My professor told me to rearrange the equation, so I tried swapping the numbers around, but it still didn't give me the answer I want.
I swapped the multiplied numbers with the one beside it, but it only threw off the number more.
import math
import stdio
import sys
theta = float(sys.argv[1])
n1 = float(sys.argv[2])
n2 = float(sys.argv[3])
theta1_rad = theta1*math.pi/180
theta2_rad = math.asin(n1*math.sin(theta1_rad)/n2)
theta2 = theta2_rad*180/math.pi
print(theta2)
When I plug in $ python3 snell.py 58 1 1.52
into the terminal, I expect the output of 33.912513998258994
, but the actual output I get is 33.91251399825899
.