Some Python Scripts to understand Variables Transfer
|
10-21-2022, 10:31 AM
(This post was last modified: 10-27-2022 08:01 PM by Ioncubekh.)
Post: #1
|
|||
|
|||
Some Python Scripts to understand Variables Transfer
~~~ Transferring Python variables to / from PPL by Guenter Schink ~~~
https://www.hpmuseum.org/forum/thread-17833.html https://www.hpmuseum.org/forum/thread-18...#pid160378 ~~~ Using sys.argv[0] by drbarnack ~~~ https://www.hpmuseum.org/forum/thread-16...#pid148350 A script that produces x2 Matrix assigned data generated from python. Can be used in CAS for plotting multiple data in same graph like: plotlist(M1), plotlist(M2) Code:
Above can be modified to produce lists instead of Matrix; useful to study them in APPs related to Stats Code:
A further implementation of python dict() that avoids excessive use of if else blocks. Perhaps a Python equivalent of PPL CHOOSE() Code:
HP Prime G1 Python via Android Termux... |
|||
10-25-2022, 08:02 PM
Post: #2
|
|||
|
|||
RE: Some Python Scripts to understand Variables Transfer
I tried to program a python script with that syntax and I keep getting an Invalid Syntax error. I have hardware version 14603. I can get the rk44 to run but I can't write one myself.
Frustrating. |
|||
10-25-2022, 08:27 PM
(This post was last modified: 10-25-2022 08:28 PM by Ioncubekh.)
Post: #3
|
|||
|
|||
RE: Some Python Scripts to understand Variables Transfer
(10-25-2022 08:02 PM)Eddie W. Shore Wrote: I tried to program a python script with that syntax and I keep getting an Invalid Syntax error. I have hardware version 14603. I can get the rk44 to run but I can't write one myself. Which syntax you're referring to? I can run this rk44 python implementation; the function is hardcoded but it works; The iterations & answer stuff can be routed to Matrix / List variables https://github.com/defencedog/HP-Prime-A...tfinal.txt Do tell how do I use \t character of python tab is not understandable by HP terminal HP Prime G1 Python via Android Termux... |
|||
10-26-2022, 02:04 AM
(This post was last modified: 10-26-2022 02:06 AM by Eddie W. Shore.)
Post: #4
|
|||
|
|||
RE: Some Python Scripts to understand Variables Transfer
I found what was causing the error:
I typed "import math as *" when it should be just "from math import *". Here is the code: Code: EXPORT VTEST() Observations: 1. Every time I changed the code, the HP rebooted. Fortunately the changes are retained. 2. Everything has to be typed out, and in the correct case. There are no command menus to help with the syntax. I guess we can use a blank Python app and then copy the code into a PPL program after testing? 3. Another print statement is required to show the user just entered after an input on the terminal. I find it quite annoying. 4. \t shows a box. |
|||
10-26-2022, 03:08 AM
(This post was last modified: 10-26-2022 03:25 AM by Ioncubekh.)
Post: #5
|
|||
|
|||
RE: Some Python Scripts to understand Variables Transfer
Quote:3. Another print statement is required to show the user just entered after an input on the terminal. I find it quite annoying.Good observation thanks Quote:4. \t shows a box. Python chr(9) also doesn't work Alternative is Code: tab=4*chr(32) REMEMBER: there is python built-in eval() & then there is hpprime eval() so always import hpprime lib as alias like Code: import hpprime as hp Also python fstring print not supported: https://realpython.com/python-f-strings/ HP Prime G1 Python via Android Termux... |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)