Post Reply 
Python, how to input a complex number
04-30-2021, 09:51 AM
Post: #7
RE: Python, how to input a complex number
Hi Stevetuc, thanks

I discovered this yesterday for the HP Prime as well.
Indeed, <complex> does not work with a string, contrary to what the help info indicates.
I think this could indeed be a bug in micropython.
To test, I solved this as follows:

PHP Code:
a=float(input(“real:))
print(
a)
b=float(input(“imag:))
print(
b)
c=complex(a,b)
print(
c

Regards

— Dirk Hartland
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Python, how to input a complex number - Dirk.nl - 04-30-2021 09:51 AM



User(s) browsing this thread: 1 Guest(s)