Post Reply 
HP_PRIME PYTHON SYNTAX: HP_PPY
08-30-2020, 02:48 AM
Post: #41
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
(08-29-2020 10:00 PM)pinkman Wrote:  Change this line:
Code:

if abs(z=z*z+c)>2:

Into this:
Code:

z=z*z+c
if abs(z)>2:

Thanks! It does work now. I wonder how it worked in the YouTube video since I copied it directly from there.

Tom L
I don't care for whom you voted. If you put ice in your beer, you're crazy.
Find all posts by this user
Quote this message in a reply
08-30-2020, 02:56 AM
Post: #42
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
I see the print() function doesn't work the same in CAS as in Python

PHP Code:
print(4,5

should print

PHP Code:
4 5 

Instead it prints

PHP Code:
4,

However

PHP Code:
print(4,5,sep=''

does work the same as in python. It prints

PHP Code:
45 

Tom L
I don't care for whom you voted. If you put ice in your beer, you're crazy.
Find all posts by this user
Quote this message in a reply
08-30-2020, 09:09 AM
Post: #43
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
(08-30-2020 02:48 AM)toml_12953 Wrote:  Thanks! It does work now. I wonder how it worked in the YouTube video since I copied it directly from there.

The reason is that the Python syntax converter was improved, instead of translating = (Python) to := (Xcas) everywhere, it take cares of the context.
I think := is now valid under Python, you can therefore write
Code:

if abs(z:=z*z+c)>2:
This code will run a little bit faster than
Code:

z:=z*z+c
if abs(z)>2:
and that's why I wrote it like that.
Find all posts by this user
Quote this message in a reply
08-30-2020, 12:29 PM
Post: #44
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
(08-30-2020 09:09 AM)parisse Wrote:  I think := is now valid under Python, you can therefore write ...

Guido stepped down over this ... Sad


Find all posts by this user
Quote this message in a reply
08-30-2020, 10:29 PM
Post: #45
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
Yes, sadly, but I don’t know what to think. There are pros and cons.
https://www.python.org/dev/peps/pep-0572/

Thibault - not collector but in love with the few HP models I own - Also musician : http://walruspark.co
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)