0

Code not working

I am new to python. My code isn't displaying desired result import cmath a,b,c = 5,6,2 quadratic_formula = (-b+cmath.sqrt(b**2-4*a*c))/2*a print(quadratic_formula)

26th Jan 2018, 3:47 PM
Haider Ali
Haider Ali - avatar
8 Answers
+ 8
What's the error that you are getting from the code you provided though?
26th Jan 2018, 3:56 PM
Hatsy Rei
Hatsy Rei - avatar
+ 7
The code you provided runs fine from other online Python interpreters that I've tried. This for instance: https://www.jdoodle.com/python-programming-online
26th Jan 2018, 4:02 PM
Hatsy Rei
Hatsy Rei - avatar
+ 4
Yes you use math here. Oh wait I think you're good with C / C++ cuz cmath exists.
26th Jan 2018, 3:57 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 3
@Hatsy 1) Use Python 3 docs. 2) I think cmath should exist, just that it needs to be pip-installed.
26th Jan 2018, 3:50 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
Does math library work in the place of cmath? I am using PyCharm as IDE for python. It says math module doesn't exist.
26th Jan 2018, 3:55 PM
Haider Ali
Haider Ali - avatar
+ 1
The online interpreters compute this result (-15+5j). Instead there should be a floating point value isn't it?
26th Jan 2018, 4:08 PM
Haider Ali
Haider Ali - avatar
0
No error though. Blank
26th Jan 2018, 3:58 PM
Haider Ali
Haider Ali - avatar
0
That's strange. Then it might be a problem in PyCharm
26th Jan 2018, 4:05 PM
Haider Ali
Haider Ali - avatar