Saturday, April 3, 2021

Python on Calculators: Python Files used as Modules

Python on Calculators:  Python Files used as Modules

(and Programming Tutorials by Mike Dane)

Python Files Can Be Transferred Between Calculators

Python scripts that are calculators have the .py extension, allowing the files to be transferred to and from calculators and python computer applications.   The calculators that I have with Python are:

* Casio fx-9750GIII

* Casio fx-CG 50

* Numworks

* TI-NSpire CX II

To my knowledge, other calculators with a Python module are:

* TI-83 Premium CE Edition Python (primarily sold in France)

* Casio fx-9860GIII (the fx-9750GIII model sold outside of the United States)

Importing Python Files - Extended Functions (

For a Python file to imported in a python script, the source python file must be included in the calculator.   


I would be working on the file and I want to import the functions defined on the to be used.  All is needed is an import statement:

import source

To use any of the functions from the, use the source-dot prefix, like:


Remember to type the name of the module, the decimal point, and the function.  The Casio calculators do not store custom functions in a catalog, while the NSpire CX and Numworks do include the custom functions in the variable list but not the module prefix.

The python scripts and serves as an illustration:

# create a custom module

# 2021-02-03 EWS

import math

# functions code

def radius(a,b):

  return math.sqrt(a**2+b**2)

def angle(a,b):



  if b<0:


  return t

def pchg(a,b):

  return (b-a)/a*100

def taxplus(a,b):

  return a*(1+.01*b)

def pvaf(a,b):  

  return (1-(1+.01*b)**(-a))/(.01*b)


def fvaf(a,b):

  return ((1+.01*b)**a-1)/(.01*b)

def rsum(a,b):

  return 1/(1/a+1/b)

# constants

# gravity of Earth


# speed of light


# 2020-02-03 EWS

# import file

import extf

print("Import any py file.")

print("The source file must")

print("be in memory.")

# \n new line



print("extf.angle(a,b=arg(a+bi) in degrees")

print("a=11.25, b=13.36")


# other functions


print("extf.pchg: percent change")



print("a =22.52,b=29")



print("present value annuity factor")


print("pv = pmt*pvaf")

print("pmt=250, n=24, i%=4.5")


# more to discover


print("More to discover!")

You can download the two files here:

Programming Tutorials by Mike Dane

Mike Dane, also known as Giraffe Academy, has many tutorials of current popular programming languages, including Python, C++, Javascript, and HTML. It is his channel where I learned about the ability to use any Python script to be imported as a module and other basic skills for Python.  

Dane has both playlists of short tutorials and a comprehensive tutorial of programming languages.  Please check out his YouTube page at:

His web site:



All original content copyright, © 2011-2021.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 

1 comment:

  1. I've grown so accustomed to my old trusty HP-48GX I've not explored newer calculators. I needed an excuse to get a new one, and I've been looking at the TI-NSpire CX-II. I was unaware it was Python compatible. I'm presently taking a Python class, and now may get a new calculator.


Swiss Micros DM16L: Advanced Boolean and Factorial (up to 20)

Swiss Micros DM16L:   Advanced Boolean and Factorial (up to 20) Introduction The program listing, for the Swiss Micros DM16L and Hewlett Pac...