Error is not an Error? - 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: Error is not an Error? (/thread-17119.html) |
Error is not an Error? - toml_12953 - 06-17-2021 05:13 AM 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 RE: Error is not an Error? - Liamtoh Resu - 06-17-2021 08:48 AM 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. RE: Error is not an Error? - Albert Chan - 06-17-2021 10:46 AM 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 } RE: Error is not an Error? - Thomas_Sch - 06-17-2021 11:32 AM 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/50401632/f-strings-giving-syntaxerror) RE: Error is not an Error? - toml_12953 - 06-17-2021 02:28 PM (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. RE: Error is not an Error? - toml_12953 - 06-17-2021 02:57 PM (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. RE: Error is not an Error? - Didier Lachieze - 06-17-2021 03:01 PM (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). RE: Error is not an Error? - Liamtoh Resu - 06-17-2021 06:30 PM 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. RE: Error is not an Error? - Albert Chan - 06-20-2021 03:25 PM (06-17-2021 03:01 PM)Didier Lachieze Wrote: 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). You can also enter a space before [-] [2] |