Error is not an Error?
|
06-17-2021, 05:13 AM
(This post was last modified: 06-17-2021 05:31 AM by toml_12953.)
Post: #1
|
|||
|
|||
Error is not an Error?
When I enter the code blow, I check it and get no errors in the HPPL editor. When I try to run it, however, I get a syntax error in line 51. It works in CPython.
Traceback (most recent call last): File "<stdin>", line 51 SyntaxError: invalid syntax Code: #PYTHON name Tom L Cui bono? |
|||
06-17-2021, 08:48 AM
Post: #2
|
|||
|
|||
RE: Error is not an Error?
I was able to reproduce your results.
BTW your code runs ok with python 3.9.4 on the pc after PPL wrapper code is removed. My guess is that the hp prime python may not support the split and formatting codes, but I will have to create some small programs to confirm or refute that theory. What is the HPPL editor? Thanks. |
|||
06-17-2021, 10:46 AM
Post: #3
|
|||
|
|||
RE: Error is not an Error?
HP Prime Python (micro Python?) might not support f string
Try string interpolation with format(), or % On Python 2.6: >>> z1, z2, z3, im = 1,2,3,4 >>> print "{ %6.4f, %6.4f + %6.4fj, %6.4f - %6.4fj }" % (z1,z2,im,z3,im) { 1.0000, 2.0000 + 4.0000j, 3.0000 - 4.0000j } |
|||
06-17-2021, 11:32 AM
(This post was last modified: 06-17-2021 11:53 AM by Thomas_Sch.)
Post: #4
|
|||
|
|||
RE: Error is not an Error?
HP-Prime python is micropython. (http://micropython.org/; https://docs.micropython.org)
Micropython is based on Python 3.4. (see Help > Tree > HP apps > Python app > OK, page 2) You may check this: Code: from sys import * F-string literals have been added to python since python 3.6. You can check more about it here (https://www.python.org/dev/peps/pep-0498/) (from https://stackoverflow.com/questions/5040...yntaxerror) |
|||
06-17-2021, 02:28 PM
Post: #5
|
|||
|
|||
RE: Error is not an Error?
(06-17-2021 08:48 AM)Liamtoh Resu Wrote: I was able to reproduce your results. From Home screen, press Shift then 1. Now press New and you're in the HPPL editor. Tom L Cui bono? |
|||
06-17-2021, 02:57 PM
Post: #6
|
|||
|
|||
RE: Error is not an Error?
(06-17-2021 11:32 AM)Thomas_Sch Wrote: HP-Prime python is micropython. (http://micropython.org/; https://docs.micropython.org) OK, I changed the format statements to the old method. Now I get an error on the input() statement. I try to enter -2,1,-2 and it enters Ans-2 for the first number. Tom L Cui bono? |
|||
06-17-2021, 03:01 PM
(This post was last modified: 06-17-2021 03:07 PM by Didier Lachieze.)
Post: #7
|
|||
|
|||
RE: Error is not an Error?
(06-17-2021 02:57 PM)toml_12953 Wrote: OK, I changed the format statements to the old method. Now I get an error on the input() statement. I try to enter -2,1,-2 and it enters Ans-2 for the first number. You need to enter -2 with [2] [+/-] or [+/-] [2], not with [-] [2]. If you start the entry with an operator key (+, -, x, /) the Prime will assume you want to apply this operator to the previous result (Ans). |
|||
06-17-2021, 06:30 PM
(This post was last modified: 06-18-2021 03:07 AM by Liamtoh Resu.)
Post: #8
|
|||
|
|||
RE: Error is not an Error?
Here is a small python program that calculates the average of three numbers
entered by the user. Code:
And another version that provides formatted output. Code:
And thanks for the nomenclature for HPPL. Thanks. |
|||
06-20-2021, 03:25 PM
Post: #9
|
|||
|
|||
RE: Error is not an Error? | |||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)