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
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()
+ 3
I guess this should be able to help
https://code.sololearn.com/c12RjhvkJ8dZ/?ref=app
+ 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 🙂