EasyManua.ls Logo

Casio fx-CG50 - Page 590

Casio fx-CG50
667 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
17-31
Description
def f(x,y,z):
Defines a user-defined function with function name f, and arguments
x, y, and z.
if x>0: If variable x is greater than 0,
t=x+y+z defines variable t as the execution result of x+y+z.
else: Otherwise (if variable x is 0 or less),
t=x-y-z
defines variable t as the execution result of x-y-z.
return(t) Makes t the return value.
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 Imports userfunc.py and runs the written process.
a=userfunc.f(1,2,3)
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.
print(a) Outputs the value stored in the variable a.

Table of Contents

Other manuals for Casio fx-CG50

Related product manuals