0

help!python code error

I got two wrong code about Python Why the complex number appeared in the first code? And why the second code is wrong? How to calculate (x^sin x) by python ? Thanks for your help. https://code.sololearn.com/c0QvOaAk4lY0/?ref=app https://code.sololearn.com/cuj6Do6EcCys/?ref=app

5th Dec 2018, 5:46 PM
SKYCHYY
3 Réponses
+ 10
So to raise x to the power of a in python you just do x**a. So the first code is correct and works without any errors.....😕😕 math.pow works only in other programming languages so use just pow()
5th Dec 2018, 6:15 PM
Uni
Uni - avatar
+ 3
I guess this should be able to help https://code.sololearn.com/c12RjhvkJ8dZ/?ref=app
5th Dec 2018, 6:27 PM
Dlite
Dlite - avatar
+ 2
1. You are raising a negative number to a fractional root which gives a complex number e. g. - 1**.5 2. pow() is a built-in function, if you use pow() rather than math.pow() then it works 🙂
5th Dec 2018, 6:15 PM
David Ashton
David Ashton - avatar