new user python on hp prime g2, casio cg50
|
05-23-2021, 05:51 PM
Post: #1
|
|||
|
|||
new user python on hp prime g2, casio cg50
I am trying to get a simple hello world python program onto the prime g2.
I have read the post: "https://www.hpmuseum.org/forum/thread-16950.html"" The post mentions a DevKit. Where can I get it? Also, once I get the program onto the prime, how do I launch/run it. BTW: The casio cg-50 has upfront file, run, open, shell, ... commands built into its micropython environment. Thanks. |
|||
05-24-2021, 03:52 PM
(This post was last modified: 05-24-2021 04:01 PM by Liamtoh Resu.)
Post: #2
|
|||
|
|||
RE: new user python on hp prime g2, casio cg50
The python shell on the prime works fine as a calculator.
eg. s = 100 a = 21 b = 5 c = a + b t = s - c t c === I put the following on the cg50 which i can run on the casio and from a windows cmd line shell via "python test0004.py". # 20190704 casio cg50 # micro python # print string array # test0004.py import math j=3 a=['moe','larry','curly'] print (j) print (a) for j in range(3): x=a[j] print (x) === This blog post does not present the indentation of the python source code of the last two lines, x=a[j], print(x). === Is there a way to put this program into the prime via the prime hp connectivity kit and then run it from the prime? Thanks. |
|||
05-24-2021, 05:11 PM
(This post was last modified: 05-24-2021 05:14 PM by toml_12953.)
Post: #3
|
|||
|
|||
RE: new user python on hp prime g2, casio cg50
(05-24-2021 03:52 PM)Liamtoh Resu Wrote: I put the following on the cg50 which i can run on the casio Yes, you can write the program like this: Code: #PYTHON(name) Then copy it to the programs folder in the CK. You can run it like an HPPL program from the menu. You can put your code between code tags (# in the list) to preserve the indentation. Tom L Cui bono? |
|||
05-24-2021, 05:56 PM
Post: #4
|
|||
|
|||
RE: new user python on hp prime g2, casio cg50
Thanks Tom for your help.
I put the edited code into the prime, but I am still having problems. I did the following. ) launched Python ) pressed <shift> <programs> ) selected test0004 ) pressed the Run tab The prime presented the yellow exclamation mark. I double checked the source file. Thanks again. |
|||
05-24-2021, 06:56 PM
Post: #5
|
|||
|
|||
RE: new user python on hp prime g2, casio cg50
(05-24-2021 05:56 PM)Liamtoh Resu Wrote: Thanks Tom for your help. In my example, you don't launch Python. Go to the Functions Home screen then press Shift-1. Select test0004 from the menu and press enter. That's the same way as you launch a regular HPPL program. Tom L Cui bono? |
|||
05-24-2021, 09:46 PM
Post: #6
|
|||
|
|||
RE: new user python on hp prime g2, casio cg50
I still can not get your edited code to run.
I reflashed the prime g2 with the 20210505 update--same result. I have the revision D hardware. Is there a subtle setting(s) change in the prime to be done to get it working? Thanks. |
|||
05-25-2021, 02:26 AM
(This post was last modified: 05-25-2021 02:33 AM by toml_12953.)
Post: #7
|
|||
|
|||
RE: new user python on hp prime g2, casio cg50
(05-24-2021 09:46 PM)Liamtoh Resu Wrote: I still can not get your edited code to run. Oops! My fault. Try this: Code: #PYTHON name Tom L Cui bono? |
|||
05-25-2021, 03:47 AM
Post: #8
|
|||
|
|||
RE: new user python on hp prime g2, casio cg50
And that finally worked!
Thank you very much. Incidently, I am a new blog user. I was wondering how to create the scrollable source code boxes and how to put the quoted text boxes into white boxes on this blog site. Thanks! |
|||
05-25-2021, 05:38 AM
Post: #9
|
|||
|
|||
RE: new user python on hp prime g2, casio cg50
(05-25-2021 03:47 AM)Liamtoh Resu Wrote: ..Please have a look at the attached pic. |
|||
05-25-2021, 06:12 AM
Post: #10
|
|||
|
|||
RE: new user python on hp prime g2, casio cg50
Thanks for the tip on on the toolbar just below and extending to the right of the font and text size changers.
. |
|||
05-26-2021, 06:28 AM
Post: #11
|
|||
|
|||
RE: new user python on hp prime g2, casio cg50
Following on this, is there a way to return the output from a Python script embedded in a PPL program to the stack?
For example, this program will print the output to the Terminal: Code:
Is there a way of returning 4 instead of 0 as shown in the screenshot? -DrBarnack |
|||
05-26-2021, 06:42 PM
Post: #12
|
|||
|
|||
RE: new user python on hp prime g2, casio cg50
There are several things going on there.
) The use of "y = sqrx(sys.argv[0])" rather than a standard python input statement. I was surprised (positively) that an input form line was presented. ) The intended square was presented on the terminal screen rather instead of being returned as a return value. ) If the python environment accepts the C-style input maybe there is a C-style output statement. |
|||
05-27-2021, 03:04 AM
(This post was last modified: 05-27-2021 03:16 AM by Liamtoh Resu.)
Post: #13
|
|||
|
|||
RE: new user python on hp prime g2, casio cg50
I tweaked your program a bit. I don't know if this was your intent.
Code:
Sorry, I just condensed the white space. I was trying variations on the prime g2 for a long while trying different variations. I don't know if hp prime g2 prime python can return pointers to sys.arg[0]. |
|||
05-29-2021, 08:09 AM
(This post was last modified: 05-29-2021 08:24 AM by drbarnack.)
Post: #14
|
|||
|
|||
RE: new user python on hp prime g2, casio cg50
(05-26-2021 06:28 AM)drbarnack Wrote: Following on this, is there a way to return the output from a Python script embedded in a PPL program to the stack? I figured this out. The trick is to evaluate the output from the Terminal: Code:
This takes a value from the stack ("sys.argv[0]"), does the calculation in Python, prints the answer to the Terminal, parses the first string in the Terminal into an expression and evaluates it, leaving the answer on the stack for future use ("RETURN EXPR(TERMINAL(1));"). So in Home or CAS mode I can use Python scripts like any other function in the Toolbox to manipulate values. |
|||
05-30-2021, 10:15 PM
Post: #15
|
|||
|
|||
RE: new user python on hp prime g2, casio cg50
Editing text with the new 20210428 beta connectivity kit seems
to have solved the problem of sending extra characters along with source code. I had to install the 20210428 beta on top of the 2020 CK. The beta software failed to run with an uninstall old software and then installing the beta. Clicking on the retro 3.5 disk icon saves the program onto the prime. The 2020 CK would show a simpler text window with a prompt to save the program. |
|||
06-02-2021, 08:42 PM
Post: #16
|
|||
|
|||
RE: new user python on hp prime g2, casio cg50
At this point after 20 days of using the prime g2, I have decided to slog through
chapter 29 of the 2018 user guide ( just like I did with the K&R 30 years ago). I am most fortunate to have a laser printer that does duplex printing. There will be a PPL version of the small python program referred to in this thread. Thanks again to Tom L and others. |
|||
10-20-2022, 11:21 PM
Post: #17
|
|||
|
|||
RE: new user python on hp prime g2, casio cg50
@drbarnack
Quote:This takes a value from the stack ("sys.argv[0]"), does the calculation in Python, prints the answer to the Terminal, parses the first string in the Terminal into an expression and evaluates it, leaving the answer on the stack for future use ("RETURN EXPR(TERMINAL(1));"). So in Home or CAS mode I can use Python scripts like any other function in the Toolbox to manipulate values. Excellent explanation! Kindly tell what is this Terminal(1) what is this variable? HP Prime G1 Python via Android Termux... |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)