import math
def SOH(oppositeSOH, hypotenuseSOH):
oppDIVhyp = oppositeSOH/hypotenuseSOH
soh = math.asin(oppDIVhyp)
print("The angle theta is equivelent to", soh)
def CAH(adjacentCAH, hypotenuseCAH):
adjDIVhyp = adjacentCAH/hypotenuseCAH
cah = math.acos(adjDIVhyp)
print("Angle theta is equivelent to", cah)
def TOA(oppositeTOA, adjacentTOA):
oppDIVhyp = oppositeTOA/adjacentTOA
toa = math.atan(oppDIVadj)
print("Angle theta is equivelent to", toa)
SOHCAHTOA = input("Do you want to calculate angle theta with a: soh, b: cah, c: toh ")
A = SOHCAHTOA.upper()
if A == 'A':
oppositeSOH = int(input("Enter the length of the opposite side "))
hypotenuseSOH = int(input("Enter the length of the hypotenuse "))
SOH(oppositeSOH, hypotenuseSOH)
if A == 'B':
adjacentCAH = int(input("Enter the length of the adjacent side "))
hypotenuseCAH = int(input("Enter the length of the hypotenuse "))
CAH(adjacentSOH, hypotenuseSOH)
if A == 'C':
oppositeCAH = int(input("Enter the length of the opposite side "))
adjacentCAH = int(input("Enter the length of the hypotenuse "))
TOA(oppositeSOH, adjacentSOH)
Als ich put 'oppDIVhyp', 'adjDIVhyp' oder 'oppDIVhyp' in math.a [sin, cos oder tan], es ist ein Fehler Mathe Domäne I im Gegenzug:Warum erhalte ich bei Verwendung von asin, acos und atan einen mathematischen Domänenfehler?
Traceback (most recent call last):
File "C:\Users\Alex\Documents\sohcahtoa.py", line 23, in <module>
SOH(oppositeSOH, hypotenuseSOH)
File "C:\Users\Alex\Documents\sohcahtoa.py", line 5, in SOH
soh = math.asin(oppDIVhyp)
ValueError: math domain error
Was bedeutet der mathematische Domänenfehler?
Welche Werte geben Sie/der Benutzer ein, wenn Sie diese Fehler erhalten? Es kann nur sein, dass Sie Werte eingeben, die nicht berechnet werden können. Ein Adj, der länger ist als ein Hyp oder so etwas. – mypetlion
Wahrscheinlich, weil Sie Variablen verwenden, denen Sie keine Werte zugewiesen haben. (Nehmen wir an, Sie wählen "B". Sie setzen \ * CAH, aber dann * verwenden * \ * SOH.) – cHao
Wurde nur realisiert und bearbeitet –