简体   繁体   中英

Complex numbers calculator

So, if I type (4*9j**2) into the console, it returns (-324+0j) Is there any way to re-create this with code, basically, take input and simplify it as if you just typed it into the console (j acts as the imaginary number i)

Thanks in advance!

You can use the built in function eval() .

>>> 4*9j**2
(-324+0j)
>>> equation = "4*9j**2"
>>> eval(equation)
(-324+0j)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM