k
Using Modules (
In the Python mode, you can use the functions below in addition to Python built-in functions.
•
Python standard math module and random module functions
•
CASIO-original casioplot module functions (see page 17-18)
However, to use a function contained in a module you have to first import (
import <module name>
from <module name> import ½
from <module name> import <element>
[, <element>]
*
An element with a name that starts with an underscore (_) character cannot be imported.
•
A single py file written by a py script is called a "module". py files are imported using the
same syntax as
•
For an example of importing and using a py file, see "Sample 4: Importing a py File" in
"Sample Scripts" (page 17-31).
Notation Examples:
import math (Imports the math module.)
from math import pi, sqrt (From the math module, imports
import
•
If you use
function in order to use that function. To use
need to be written as "math.pi".
from
•
When using
<module name>.<function name>
Executing an import operation with this syntax will cause an error.
import)
import
Syntax
import
.
to import a module, you need to include "<module name>." before a
to import a module, do not use the syntax below.
Imports the module (py file) specified by
<module name>.
Imports all of the elements* included in the
module specified by <module name>.
Imports the specified elements (functions,
etc.) included in the module specified by
<module name>.
pi
and
pi
within the math module, for example, it would
17-12
import
) the module.
Description
sqrt
only.)