There is a package named "fractions" that could be imported that does simple fraction conversion. Following is a refactored example of using that package.
from fractions import Fraction
def chooseradians():
choice = str(input("1. Side Side Side \n2. Side Angle Side\n3. Angle Side Angle "))
if str(choice) == str(1):
x =float(Fraction(input("Side A: ")))
y =float(Fraction(input("Side B: ")))
z =float(Fraction(input("Side C: ")))
print("Side A:", x, "Side B:", y, "Side C:", z)
#sidesidesiderad(x, y, z)
elif str(choice) == str(2):
x =float(Fraction(input("Side A: ")))
y =float((Fraction(input("Angle b: "))))
z =float(Fraction(input("Side C: ")))
print("Side A:", x, "Angle b:", y, "Side C:", z)
#SideAngleSiderad(x, y, z)
elif str(choice) == str(3):
x =float((Fraction(input("Angle a: "))))
y =float(Fraction(input("Side B: ")))
z =float((Fraction(input("Angle c: "))))
print("Angle a:", x, "Side B:", y, "Angle c:", z)
#AngleSideAnglerad(x, y, z)
chooseradians()
Performing a simple test resulted in the following terminal output.
craig@Vera:~/Python_Programs/Triangle$ python3 Fractions.py
1. Side Side Side
2. Side Angle Side
3. Angle Side Angle 1
Side A: 3
Side B: 22/33
Side C: 5
Side A: 3.0 Side B: 0.6666666666666666 Side C: 5.0
Now this probably solves half of the battle if any of the values are comprised of a whole number plus a fraction (e.g. "1 1/3"). When testing this type of compound entry, an input error still occurs.
craig@Vera:~/Python_Programs/Triangle$ python3 Fractions.py
1. Side Side Side
2. Side Angle Side
3. Angle Side Angle 1
Side A: 1 1/3
Traceback (most recent call last):
File "/home/craig/Python_Programs/Triangle/Fractions.py", line 24, in <module>
chooseradians()
File "/home/craig/Python_Programs/Triangle/Fractions.py", line 6, in chooseradians
x =float(Fraction(input("Side A: ")))
File "/usr/lib/python3.10/fractions.py", line 115, in __new__
raise ValueError('Invalid literal for Fraction: %r' %
ValueError: Invalid literal for Fraction: '1 1/3'
If such compound whole and fractional numbers are going to be allowed for entry, either a subsequent parsing function would need to be built or the whole number portion would need to be converted into a fractional equivalent (e.g. "4/3" which would be the equivalent value for this example). But either way, this should provide you with some possibilities to progress.
/, then split it and do the division.evil(input("prompt"))....ast.literal_eval(input())? I thought about it, decided it wasn't really appropriate.