[Python] Want to convert degrees to radians and have the answer output symbolically

Discussão em 'Python' iniciado por Stack, Junho 3, 2025.

  1. Stack

    Stack Membro Participativo

    I am using the Sympy library in Python, and I'm trying to convert degrees to radians, and have the output rendered symbolically. Sympy does not have a function for converting degrees to radians, but the Sympy docs recommend using mpmath. I tried the following code:

    import mpmath as mp
    import sympy as sym
    mp.radians(126)


    The output is 2.19911485751286, which is correct, but computed numerically rather than symbolically. I would like it to be rendered as 0.7π (symbolic computation). The google AI guidance was convoluted and actually incorrect. Is there an easy way to do this?

    Continue reading...

Compartilhe esta Página