Download Print this page

Casio fx-CG50 User Manual page 590

Hide thumbs Also See for fx-CG50:

Advertisement

Description
def f(x,y,z):
if x>0:
t=x+y+z
else:
t=x-y-z
return(t)
Running this py script as a standalone script will only define the user defined function. The
function will not be executed so the py script will end without output.
Execution Result
Sample 4: Importing a py File
Purpose
import
can be used to import py files into other py files and
run the processes written in the imported py files.
This makes it possible to use user-defined functions and
variables across multiple py files.
Use the syntax below for execution of a module function or
variable.
<py file (module) name>.<function name or variable name>
Description
import userfunc
a=userfunc.f(1,2,3)
print(a)
Defines a user-defined function with function name f, and arguments
x, y, and z.
If variable x is greater than 0,
defines variable t as the execution result of x+y+z.
Otherwise (if variable x is 0 or less),
defines variable t as the execution result of x-y-z.
Makes t the return value.
Imports userfunc.py and runs the written process.
Inputs arguments 1, 2, and 3 to the user defined function f defined by
userfunc.py, executes the function f, and defines variable a as the result
value.
Outputs the value stored in the variable a.
17-31

Advertisement

loading

This manual is also suitable for:

Fx-cg50 auFx-cg20Fx-cg20 auFx-cg10