The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
complex numbers in Python
10-12-2024, 01:18 PM
Post: #1
complex numbers in Python
In Python on my computer,
Code:
complex("1.2+3.4j")
complex("1.2-3.4j")
return
Code:
(1.2+3.4j)
(1.2-3.4j)
as expected.

However, in Python on the Prime, these give a "ValueError: invalid syntax for number" error message.

Interestingly,
Code:
complex("1.2")
complex("3.4j")
correctly return
Code:
(1.2+0j)
(3.4j)

Even
Code:
complex("1.2+0j")
complex("(1.2+0j)")
both fail.

Code:
complex("1.2")+complex("3.4j")
correctly returns
Code:
(1.2+3.4j)
but I'd rather not have to do that sort of processing unnecessarily.

Is this a microPython issue or a Prime issue? Or am I doing something completely wrong?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
complex numbers in Python - Wes Loewer - 10-12-2024 01:18 PM
RE: complex numbers in Python - komame - 10-12-2024, 02:25 PM
RE: complex numbers in Python - Wes Loewer - 10-12-2024, 05:51 PM
RE: complex numbers in Python - Wes Loewer - 10-12-2024, 06:04 PM
RE: complex numbers in Python - Wes Loewer - 10-12-2024, 06:34 PM



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