From fd51a1ac948fb9db6ad0a7aea9ea37f682b6e160 Mon Sep 17 00:00:00 2001 From: simransonkar17 <32771667+simransonkar17@users.noreply.github.com> Date: Tue, 31 Oct 2017 23:32:45 +0530 Subject: [PATCH] squareroot --- python/squareroot.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 python/squareroot.py diff --git a/python/squareroot.py b/python/squareroot.py new file mode 100644 index 0000000..073f9ca --- /dev/null +++ b/python/squareroot.py @@ -0,0 +1,11 @@ +# Find square root of real or complex numbers +# Import the complex math module +import cmath + +# change this value for a different result +num = 1+2j + +# uncommment to take input from the user +#num = eval(input('Enter a number: ')) +num_sqrt = cmath.sqrt(num) +print('The square root of {0} is {1:0.3f}+{2:0.3f}j'.format(num ,num_sqrt.real,num_sqrt.imag))