Post Reply 
Python version on the HP Prime
02-14-2022, 07:07 PM
Post: #4
RE: Python version on the HP Prime
The prime has a few issues with the sun_moon.py code:

a. fsum and isclose do not exit in the math module.
b. exit is in the sys module

To fix this i put the following code at the top of the file:

Code:
from builtins import sum as fsum
from builtins import abs
from sys import exit

def isclose(a,b,abs_tol):
    return abs(a-b)<abs_tol

Then I went thru the code and replace math.fsum with fsum and math.isclose with isclose.

With these changes it runs on the prime and seems to give results similar to the original file when run in spider. You may want to change the print statements to fit better on the prime's screen.

The file is attached below with the extension changed to .txt.

-road

.txt  sun_moon_prime.txt (Size: 47.64 KB / Downloads: 23)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Python version on the HP Prime - kuenze - 02-13-2022, 10:12 AM
RE: Python version on the HP Prime - roadrunner - 02-14-2022 07:07 PM



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