HP Forums
HP prime Python code Python app - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: HP prime Python code Python app (/thread-17116.html)



HP prime Python code Python app - Grigosvili - 06-16-2021 06:07 PM

Hello everyone,

I am new to the forum and to the HP Prime, so I am sorry for my lack of knowledge on both of them. Now, I bought my HP prime few months ago, and I saw it had a Python support, so I tried to run a Python code I wrote on my computer and after some time of making the code more simple etc. I managed to make it work on my HP prime. I would enter the CAS mode and call my program with a () on the end and it showed me all the dialogue windows I wanted and calculated everything I wanted. However, yesterday I updated it and on the connectivity kit it now shows that it is Beta version and the calculator now has new app, Python, and my program would no longer work in the CAS mode, it would just reboot the calculator when i tried to run it, like before. Now I saw few posts on how to run a python code, but with me being new to calculator, I didn't find them helpfull.
I was wondering if someone, who doesn't mind explaining this to me, a newbie, could tell me how to run a Python code, previously wrote on my pc in the python app. I understood there were numeric view, which is a shell, and a symbolic view, in which I can write the program on a calculator itself, but I don't see any save options, and I don't know how to run the program wrote in Symb in a Num view. An actual example would probably be the best.
Once again, please remeber I am new to HP graphic calculator,

Best regards


RE: HP prime Python code Python app - ŽŽŽ - 06-16-2021 09:15 PM

This reminds me of a problem that I have with the latest update too, although I must say am having trouble understanding all of the above. I would also be vastly appreciative if someone could give an in-depth explanation regarding the newest HP software improvement.
Thanks in advance!


RE: HP prime Python code Python app - Liamtoh Resu - 06-16-2021 11:31 PM

I willl try to explain how I put a simply python program onto the prime.

I cannected the prime to the computer and launched the CK (hp prime conectivity
kit). I put the 20210505 firmware onto the prime. (There is an item in one of the
menus to update or upgrade the calculator). I have the 20210428 beta CK installed.

From the CK I created a new program (aprxpi02) on the prime. (The prime rebooted).

I went to the CK and double clicked on the new program (aprxpi02) which was
empty. A text box appeared and i pasted my prime python program into it

I had to click on on the floppy icon(s) to save the program.

I disconnected the prime to run the program on the prime.

I pressed the <shift> <1> to get a listed of my programs on the prime.

I selected the the program and touched the run item on the prime screen.

Python programs on the prime need a ppl wrapper around them.

The code for aprxpi02 follows

Code:

#PYTHON name
# aprxpi02
import math

def pintro():
  print ("aprxpi02 pi approximation")
  return

def api():
  return 355/113

def pout():
  q1 = api()
  print ("pi = ", q1)

pintro()
pout()

#end 
 
EXPORT aprxpi02()
BEGIN
  PRINT;
  PYTHON(name);
END;


Perhaps someone else has clearer or better process.


RE: HP prime Python code Python app - toml_12953 - 06-17-2021 04:57 AM

(06-16-2021 11:31 PM)Liamtoh Resu Wrote:  I willl try to explain how I put a simply python program onto the prime.

I cannected the prime to the computer and launched the CK (hp prime conectivity
kit). I put the 20210505 firmware onto the prime. (There is an item in one of the
menus to update or upgrade the calculator). I have the 20210428 beta CK installed.

From the CK I created a new program (aprxpi02) on the prime. (The prime rebooted).

I went to the CK and double clicked on the new program (aprxpi02) which was
empty. A text box appeared and i pasted my prime python program into it

I had to click on on the floppy icon(s) to save the program.

I disconnected the prime to run the program on the prime.

I pressed the <shift> <1> to get a listed of my programs on the prime.

I selected the the program and touched the run item on the prime screen.

Python programs on the prime need a ppl wrapper around them.

The code for aprxpi02 follows

Code:

#PYTHON name
# aprxpi02
import math

def pintro():
  print ("aprxpi02 pi approximation")
  return

def api():
  return 355/113

def pout():
  q1 = api()
  print ("pi = ", q1)

pintro()
pout()

#end 
 
EXPORT aprxpi02()
BEGIN
  PRINT;
  PYTHON(name);
END;


Perhaps someone else has clearer or better process.

You can type the program right into the same editor you use with HPPL (from Home screen: Shift-1, New) and save it the same way also.