0

can i get help how to know a number imaginary or not

wel i m try to use sqrt(d*d-4*a*c) so if my d*d<4*a*c that become imaginary number and i didn't get what i want i put random number so with condition like if d > 0 or d= 0 but if it got imaginary it didn't show anything it shows error in sqrt https://code.sololearn.com/cgjL3AQMFYvy/?ref=app

16th Jun 2021, 2:40 PM
Sourov Das
Sourov Das - avatar
3 Answers
+ 2
Is it math.sqrt()? It does not allow negative numbers. But you can get an imaginary number by raising it by the power of 2 https://code.sololearn.com/c0R2lr77RQ2Q/?ref=app
16th Jun 2021, 3:23 PM
Lisa
Lisa - avatar
+ 1
d = b*b-4*a*c this is the value you need to compare with 0 to find out the number and type of solutions. You need the sqrt(d) if you need to calculate the solutions. For the case when d is negative you can use sqrt from the cmath module.
17th Jun 2021, 4:51 AM
Mihai Apostol
Mihai Apostol - avatar