Post Reply 
How does python work?
09-08-2021, 10:48 AM
Post: #9
RE: How does python work?
(09-07-2021 10:05 PM)roadrunner Wrote:  I think you would have to save it as a variable, then do what ever you want with the variable like in the following example:

PHP Code:
#PYTHON test
from sys import argv
from builtins import float
from cas import caseval

def func1
(ab):
 return 
b

def func2
(ab):
 return 
b

def func3
(abc):
 if 
== 0:
  return 
func1(ab)
 else:
  return 
func2(ab)

answer=func3(
 
float(argv[0]),
 
float(argv[1]),
 
float(argv[2]))

caseval(
 
"pythonanswer1698554:=" str(answer))

#end

EXPORT runtest(a,b,c)
BEGIN
 local d
;
 
PYTHON(test,a,b,c);
 
d:=CAS("pythonanswer1698554");
 
CAS("purge(pythonanswer1698554)");
 
d;
END

You can also save it as a home variable with hpprime.eval instead of cas.caseval.

-road

Thanks for this. This seems more complicated than I hoped for. Is there some resource I can use to learn things like this?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
How does python work? - hamorabi - 09-06-2021, 04:37 PM
RE: How does python work? - Dougggg - 09-06-2021, 04:53 PM
RE: How does python work? - hamorabi - 09-06-2021, 05:01 PM
RE: How does python work? - roadrunner - 09-06-2021, 08:15 PM
RE: How does python work? - hamorabi - 09-07-2021, 07:45 AM
RE: How does python work? - roadrunner - 09-07-2021, 12:06 PM
RE: How does python work? - hamorabi - 09-07-2021, 09:24 PM
RE: How does python work? - roadrunner - 09-07-2021, 10:05 PM
RE: How does python work? - hamorabi - 09-08-2021 10:48 AM
RE: How does python work? - roadrunner - 09-08-2021, 11:08 AM



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