How could I get square root of a symbol in python?
Question: I am using math.sqrt in python to compute the squre root of something, but
that "something" is a symbol instead of a known value. I am using that
"something" as an intermediate variable for later use.

    
    
    import math
    from math import sqrt
    x = Symbol('x')
    y = math.sqrt(x)
    print(y)
    

Hower I get the error message

    
    
    File "/Library/Python/2.7/site-packages/sympy/core/expr.py", line 207, in __float__
        raise TypeError("can't convert expression to float")
    TypeError: can't convert expression to float
    

Looks like there's no other packages for me to compute square root except
"math.sqrt", does anyone know how I could get rid of this problem?


Answer: When using `sympy`, one should use the functions in `sympy` that operate on
symbols, rather than the `math.*` functions that operate on floating point
numbers, e.g.

    
    
    from sympy import *
    x = Symbol('x')
    y = sqrt(x)
    print(y)
    

In this case, the code is using `sympy`'s `sqrt()` function.

