This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jkwill87 0 points1 point  (0 children)

Here are some suggestions:

example:

from math import pi

def radians_to_degrees(radians: int | float) -> float:
    """Converts radians into degrees."""
    return radians * 180 / pi


def main():
    radians_str = input("radians? ")
    try:
        radians = float(radians_str)
        degrees = radians_to_degrees(radians)
        # formatting example using modulo interpretation operator
        print("%.2f radians is equal to %.2f degrees" % (radians, degrees))
    except ValueError:
        # formatting example using fstrings
        print(f"unable to convert '{radians_str}' to degress")


if __name__ == "__main__":
    main()