Ti-Pyappprgg v570 en

Download as pdf or txt
Download as pdf or txt
You are on page 1of 170

Python Programming

for the
TI-84 Plus CE-T Python Edition
Graphing Calculator
Version 5.7.0 Bundle 84CE-T

Learn more about TI Technology through the online help at education.ti.com/eguide.


Important Information
Except as otherwise expressly stated in the License that accompanies a program, Texas
Instruments makes no warranty, either express or implied, including but not limited to
any implied warranties of merchantability and fitness for a particular purpose,
regarding any programs or book materials and makes such materials available solely
on an "as-is" basis. In no event shall Texas Instruments be liable to anyone for special,
collateral, incidental, or consequential damages in connection with or arising out of the
purchase or use of these materials, and the sole and exclusive liability of Texas
Instruments, regardless of the form of action, shall not exceed the amount set forth in
the license for the program. Moreover, Texas Instruments shall not be liable for any
claim of any kind whatsoever against the use of these materials by any other party.
"Python" and the Python logos are trademarks or registered trademarks of the Python
Software Foundation, used by Texas Instruments Incorporated with permission from
the Foundation.
Note: Actual screens may vary slightly from provided images.
© 2019 - 2021 Texas Instruments Incorporated

ii
Contents

What's New 1
What's New in Python App 1

Python App 2
Using Python App 3
Python program (PY AppVar) memory management 3
Python App Navigation 4
Example Activity 5
Setting up a Python Session with your Programs 7

Python Workspaces 8
Python File Manager 9
Python Editor 11
Python Shell 14

Fast Editing Support 17


Using the Python Keypad 18
Using the Python Catalog 20
Using the [a A #] Character Map 21

[Fns] Menus, Modules and Add-On Modules 22


[Fns…] Menus 23
[Fns...] Built-in, Operators and Keywords 23
[Fns...] Modules 24
[Fns...] Add-On Modules 30
[Fns...] ti_draw Add-On Module 31
[Fns...] ti_image Add-On Module 35

Python App Messages 38


Using TI-SmartView™ CE-T and the Python Experience 40
Using TI Connect™ CE to Convert Python Programs 41

What is the Python programming experience? 42


Modules Included in the TI-84 Plus CE-T Python Edition 42

Sample Programs 49
Reference Guide for TI-Python Experience 57
CATALOG Listing 57
Alphabetical List 57

iii
Appendix 150
Selected TI-Python Built-in, Keywords, and Module Content 151
Keypad mapping for wait_key() 165

General Information 166


Online Help 166
Contact TI Support 166
Service and Warranty Information 166

iv
What's New
What's New in Python App
TI-84 Plus CE-T Python Edition

Python Programming
• Access the Python App from [prgm] when the Python App is loaded. Python App is
also listed in [2nd] [apps].
- Stay up to date at education.ti.com/84cetupdate.
- Find details for the Python App in the Python Programming guide at
education.ti.com/eguide.
• Quick paste of import statements for Add-On modules. Add-On modules are
available in Python activities posted on education.ti.com.
• New ti_draw and ti_image Add-On modules load with the CE Bundle.
- Draw and use images in your Python programs.
• ti_system module menu now contains the wait_key() method for ease of use.
• ti_hub and ti_rover modules contain the latest TI-Innovator™ Hub sketch v 1.5
support.
- Data Collection - collect multiple data samples in a single command
- Compound Statements to synchronize multiple outputs
- TI-RGB Array - control multiple LEDs
- Sound - use single command to play repeated beeps
- Ranger - return "time of flight"

Transferring Python Programs


When transferring Python programs from a non-TI platform to a TI platform OR from
one TI product to another:
• Python programs that use core language features and standard libs (math, random
etc.) can be ported without changes.
Note: List length limit is 100 elements.
• Programs that use platform-specific libraries - matplotlib (for PC),
ti_plotlib/ti_system/ti_hub/etc. for TI platforms, will require edits before they will
run on a different platform.
This may be true even between TI platforms.

For more information about the new and updated functionality, go to


education.ti.com/84cetupdate.

What's New 1
Python App
See the following for using, navigating, and running the Python App.
• Using Python App
- Python program (PY AppVar) memory management
• Python App Navigation
• Example Activity
• Setting up a Python Session with your Programs

2 Python App
Using Python App
The Python App is available for the TI-84 Plus CE-T Python Edition. The information in
this eGuide is for use with the TI-84 Plus CE-T Python Edition updated with the latest
CE Bundle.
When you first run the Python App on your TI-84 Plus CE-T Python Edition, the App may
direct you to update to the latest CE Bundle for the latest Python App.
Please see at education.ti.com/84cetupdate to update your
TI-84 Plus CE-T Python Edition.
Python program (PY AppVar) memory management
The Python App offers a File Manager, an Editor to create programs, and a Shell to run
programs and interact with the Python interpreter. Python programs stored or created
as Python AppVars will execute from RAM.You may store Python AppVars in Archive for
memory management y L 2:. If the Python App File Manger screen does not
display one of your PY AppVar programs, you can move a PY AppVar calculator Python
program between RAM or Archive memory as shown. The * denotes a file in Archive.
Press [enter] to move file between RAM and Archive.

Note: If your calculator is the TI-84 Plus CE-T, please see education.ti.com/84cetupdate
to find the latest information for your CE.

Python App 3
Python App Navigation
Use the shortcut keys on the screen in the App to navigate between workspaces in the
Python App. In the image, the shortcut tab labels indicate:
* Navigation to the File Manager [Files]
** Navigation the Editor [Edit] or [Editor]
*** Navigation to the Shell [Shell]
Access shortcut tabs on the screen using the graphing key row immediately under the
screen. Also, see Keypad. The Editor>Tools menu and Shell>Tools menu also contain
navigation actions.

4 Python App
Example Activity
Use the example activity provided as an experience to become familiar with the
workspaces in the Python App.
• Create a new program from the File Manager
• Write the program in the Editor
• Execute the program in the Shell in the Python App.
For more about Python programming on your CE, please see resources for
TI-84 Plus CE-T Python Edition.

Getting Started:
• Run the Python App.
Note: Actual screens may vary slightly from
provided images.
Enter new program name from File Manager.
• Press q ([New]) to create a new
program.

New File Name Entry


• The example program will be named
"PRINT". Enter the program name and
press s ([Ok]).
• Notice the cursor is in ALPHA lock. Always
enter a program name following the given
requirements on the screen.
TIp: If the cursor is not in ALPHA lock, press
y ƒ ƒ for upper case letters.
Enter program as shown.
TIp: The App provides a quick entry! Always
watch the cursor state as you enter your
program!
Alphabet characters on ƒ toggles the insert
Keypad cursor state in the Editor
and Shell.
_ non-alpha
a lower case alpha
A upper case ALPHA

Where is the equal sign? Press ¿ when the

Python App 5
cursor is _.

Where are these [Fns…] I/O


located? 1:print()
input()
2:input()
print()
Where is double quote? ƒ[“]

Where are ( and )? Use keypad when cursor


is _.

Try-It! [a A #] and y N also are


helpers for quick entry as needed!
Execute the program PRINT Shell
cursor
• From the Editor, press r ([Run]) to state
execute your program in the Shell. indicator.

• Enter your name at the “What is your Input


name?” prompt. your
name.
• Output displays “HELLO” with your name. Output of
Note: At the Shell prompt >>>, you can PRINT
execute a command, such as 2+3. If you use displays.

any method from math, random, or other


available modules, be sure to execute an
import module statement first as in any
Python coding environment.

6 Python App
Setting up a Python Session with your Programs
When the Python App is launched, the CE connection with the TI-Python experience will
synchronize for your current Python session. You will see your list of programs in RAM
and dynamic modules, as they synchronize to the Python experience.
When the Python session is established, the status bar contains a green square
indicator near the battery icon that signals the Python session is ready for use. In the
event the indicator is red , wait for the indicator to change back to green when the
Python experience is again available.
You may see an update of the Python distribution when launching the Python App along
with program synchronization after the latest update for your
TI-84 Plus CE-T Python Edition from education.ti.com/84cetupdate.
Disconnecting and Reconnecting the Python App
When the Python App is running, the status bar contains an indicator that signals
whether Python is ready for use. Until the connection is established, the CE keypad may
not respond. Best practice is to be aware of the status bar connection indicator while
in your Python session.

Python Not Ready Python Ready

Screen Captures
Using TI Connect™ CE at education.ti.com/84cetupdate, screen captures of any Python
App screen is allowed.

Python App 7
Python Workspaces
The Python App contains three workspaces for your Python programming development.
• File Manager
• Editor
• Shell

8 Python Workspaces
Python File Manager
The File Manager lists the Python AppVars available in RAM on your calculator. You can
create, edit, and run programs as well as navigate to the Shell.
See Python program (PY AppVar) memory management

When in alpha state, press any letter on the keypad to jump to programs
beginning with that letter.
Press ƒ if needed when A indicator is not in the status bar.

File Manager shortcut keys and menus


Menus Keypress Description
[Run] o Select a program using }or †. Next, select
[Run] to execute your program.
[Edit] p Select a program using }or †. Next, select
[Edit] to display the program in the Editor to
edit your program.
[New] q Select [New] to enter a new program name and
continue to the Editor to enter your new
program.
On the [New] screen, select [Types] (press
[zoom]), to select a Type of program. By
selecting a type of program, a template of
import statements and frequently used
functions and methods will be pasted to your
new program for that activity.
[Shell] r Select [Shell] to display the Shell prompt
(Python interpreter). The Shell will be in the
current state.
[Manage] s Select [Manage] to:
• View version number.
• Replicate, delete or rename a selected
program.
• View the About screen.

Python Workspaces 9
File Manager shortcut keys and menus
Menus Keypress Description
• Quit the App. Also use y 5

Create a New Program Using Program Type Templates

Create a New STEM Activity Program Using Templates


When the TISTEMEN AppVar is loaded in Archive, the
“TI STEM Project Helpers...” menu item will display in
the Select Program Type menu. Select the STEM
activity template as needed to help begin a new
STEM program.

10 Python Workspaces
Python Editor
The Python Editor is displayed from a selected program in File Manager or from the
Shell. The Editor displays keywords, operators, comments, strings and indents in color.
Quick paste of common Python keywords and functions are available as well as direct
keypad entry and [a A #] character entry . When pasting a code block such as if.. elif..
else, the Editor offers auto-indent which can be modified as needed as you write your
program.

Cursor is always in insert


mode. Use y and ƒ to
toggle cursor. Cursor states
are numeric, a, and A. [del]
behaves as a backspace and
delete of a character.

Program line location of the cursor.

Auto indent code blocks.


Gray dots as visual indicator of
indented lines.

Useful tools for editing and working in the


Shell. Full description below.

Python Editor shortcut keys and menus


Menus Keypress Description
[Fns…] o Select [Fns…] to access menus of commonly
used functions, keywords, and operators. Also
access selected contents of the math and
random modules.
Note: y N is also helpful for quick
paste.
[a A #] p Select [a A #] to access a character palette as
an alternate way to enter many characters.

Python Workspaces 11
Python Editor shortcut keys and menus
Menus Keypress Description
[Tools] q Select [Tools] to access features to assist in
your editing or your interaction with the Shell.
1: Indent 4 Indents the program line to the
right cursor moves to first character
of the line.
2: Indent 3 Reduces the indent of the program
line to the left. Cursor moves to first
character of the line.
3: Undo Clear Pastes the last cleared line to a new
line below the program line
containing the cursor. Cursor
displays at the end of the pasted
line.
4: Insert Line Inserts a line above the program line
Above with the cursor. Line will indent and
display indent dots when
appropriate.
5: Cut Line Current program line with cursor is
cut. Cursor displays on program line
below the cut line.
6: Copy Line Copies current program line with
cursor. A copied program line can
be pasted to the Shell prompt. See
Shell below.
7: Paste Line Pastes the last stored program line
Below to the line below the cursor
position.
8: Go to Displays cursor at the beginning of
Program the specified program line.
Line…
9: Go to New Displays reinitialized Shell.
Shell
0: Return to Displays Shell in current state.
Shell
A: Page up Displays 11 program lines above
current cursor position as available.
B: Page Down Displays 11 program lines below
current cursor position as available.
C: Insert Inserts # on a new line below cursor
#comment position.
Below

12 Python Workspaces
Python Editor shortcut keys and menus
Menus Keypress Description
[Run] r Select [Run] to execute your program.
[Files] s Select [Files] to display the File Manager.

Python Workspaces 13
Python Shell
The Python Shell is the console where you can interact with the Python interpreter or
run your Python programs. Quick paste of common Python keywords and functions is
available as well as direct keypad entry and [a A #] character entry . The Shell prompt
can be used to test one line of code pasted from the Editor. Multiple lines of code may
also be entered and run at a Shell prompt >>>.

Shell cursor state indicator.

Shell reinitialize when a new


program is executed.

Useful tools for working in the Shell.


See details below.

Shell Cursor States


non-alpha
yƒ yƒ
if needed lock alpha
to toggle

ƒ again
ƒ
alpha lock ALPHA

ƒ again
ALPHA

14 Python Workspaces
Python Shell shortcut keys and menus
Menus Keypress Description
[Fns…] o Select [Fns…] to access menus of commonly
used functions, keywords, and operators. Also
access selected contents of the math and
random modules.
Note: y N is also helpful for quick
paste.
[a A #] p Select [a A #] to access a character palette as
an alternate way to enter many characters.
[Tools] q Select [Tools] to display the following menu
items.
1: Rerun last Reruns last program which was
program executed in the Shell.
2: Run… Displays a list of the Python
programs available to run in Shell.
3: Paste from Pastes the last copied program line
Editor from the Editor to the Shell prompt.
4: Vars… Displays the vars from the last
program which ran. Does not
display program defined vars from
an imported program.
5: Clear Clears the Shell screen. Does not
Screen reinitialize a new Shell.
6: New Shell Reinitialize a new Shell.
7: Go to Displays the Editor from the Shell
Program with cursor on the specified
Line… program line.
8: Last Displays up to the last 8 entries at
Entry>>> the Shell prompt during a Shell
}† session.
9: View Scroll the Shell screen to view up to
History the last 60 lines of output in the Shell
y} during a Shell session. After drawing
y† to the Shell using ti_plotlib, ti_draw
or ti_image, pressing [clear] will clear
the drawing back to the Shell. The
history will not be in display. Use
[2nd] } and [2nd] † to view the
history if needed.
0: Tab Displays the names of the variables
Complete and functions available for access in
y [enter] the current Shell session.

Python Workspaces 15
Python Shell shortcut keys and menus
Menus Keypress Description
When a letter of an available variable
or function is entered, press y
[enter] to auto-complete the name
if a match is available in the current
Shell session.
A: from When first executed in a Shell
PROGRAM session, PROGRAM will run and vars
import *… will only be viewable using Tab
Complete.
When executed again in the same
Shell session, the execution will
appear as no execution.
This command can also be pasted
from y N.

[Editor] r Select [Editor] to display the Editor with the


last programs in Editor. If Editor is empty, you
can display File Manager.
[Files] s Select [Files] to display the File Manager.

Note:
• To break a running Python program, such as if a program is in a continuous loop,
press É. Press [Tools] (q) > 6:New Shell as an alternate method to halt a
running program.
• When using ti_plotlib, ti_draw or ti_image modules to draw to the Shell, press
[clear] to clear the draw and return to the Shell prompt at the top of the screen. To
view the Shell history, use [2nd] } and [2nd] † to view the history as needed.
Execution Error: Go to Program Line using Shell >Tools
The TI-Python experience will display Python error messages in the Shell when code is
executed. If an error is displayed when a program executes, a program line number
will display. Use Shell>Tools 7:Go to Program Line… Enter the line number and press
[OK]. The cursor will display on the first character of the appropriate program line in
the Editor. The program line number is displayed in the second line of the Status bar in
the Editor.

16 Python Workspaces
Fast Editing Support
When entering code in the Editor or in the Shell, use the following entry methods to
quickly paste to the edit line.
Tips for fast entry
• Using the Python Keypad
• Using the Python Catalog
• Using the [a A #] Character Map

Fast Editing Support 17


Using the Python Keypad
When the Python App is running, the keypad is designed to paste the appropriate
Python operations or open menus designed for easy entry of functions, keywords,
methods, operators, etc. Pressing y and ƒ will access the second and third
functions on a key as in the Operating System.
Python App Navigation, Editing, and Special Characters by Keypad Rows

Python App Specific Key Presses for Menus and Functions by Keypad Rows

18 Fast Editing Support


Python App Specific Key Presses for Menus and Functions by Keypad Rows (Continued)

Fast Editing Support 19


Using the Python Catalog
When the Python App is running, y N will display a list of frequently used
delimiters, keywords, functions and operators to quickly paste to an edit line.
y N is available in Editor and Shell only. For a more detailed description of
each Catalog item, please see the Reference Guide. From the top of the catalog menu,
use } for circular navigation of the catalog.
When in catalog, select ƒ and a letter key to display the listing starting at that
letter.

20 Fast Editing Support


Using the [a A #] Character Map
[a A #] shortcut tab to a character palette is a convenient feature to enter strings when
in Editor or Shell.

Note: When the cursor focus is in the [a A #] edit line, selected keypad keys are not
available. When focus is in the character map, the keypad is restricted.

Fast Editing Support 21


[Fns] Menus, Modules and Add-On Modules
• [Fns…] Menus
• [Fns...] Built-in, Operators and Keywords
• [Fns...] Modules
• [Fns...] Add-On Modules

22 [Fns] Menus, Modules and Add-On Modules


[Fns…] Menus
[Fns…] shortcut tab displays menus containing frequently used Python functions,
keywords, and operators. The menus also provide access to the selected functions and
constants from the Modules and Add-On Modules. While you can enter character by
character from the keypad, these menus provide a quick way to paste in Editor or Shell.
Press [Fns…] when in Editor or Shell. See also Using the Python Catalog and Using the
Python Keypad for alternate entry methods.

[Fns...] Built-in, Operators and Keywords

[Fns] Menus, Modules and Add-On Modules 23


[Fns...] Modules
When using a Python function or constant from a module, always use an import
statement to indicate the module location of the function, method or constant.
See What is the Python programming experience?

[Fns…]>Modul: math module

[Fns…]>Modul: random module

[Fns…]>Modul: time module

24 [Fns] Menus, Modules and Add-On Modules


[Fns…]>Modul: ti_system module

See: Keypad mapping for wait_key()

[Fns…]>Modul: ti_plotlib

Important Plotting Note:


• The order of program lines for plotting must follow the order as in the Setup menu
to ensure expected results.
• Plotting displays when plt.show_plot() is executed at the end of the plotting
objects in a program. To clear the plotting area in the Shell, press [clear]. To view
the Shell history, press [2nd] } and [2nd] †.
• Running a second program that assumes the default values are set within the
same Shell environment, will generally result in unexpected behavior such as color
or other default argument settings. Edit programs with expected argument values
or Reinitialize the Shell before running another plotting program.

[Fns] Menus, Modules and Add-On Modules 25


[Fns…]>Modul: ti_hub module
ti_hub methods are not listed in Catalog and thus, not listed in the Reference Guide.
Please use the screen information in the menus for arguments and argument default
or allowed value details. More information on Python programming for
TI-Innovator™ Hub and TI-Innovator™ Rover will be available at education.ti.com.
Note: TI-Innovator™ Hub should be connected when you run your Python programs.

26 [Fns] Menus, Modules and Add-On Modules


ti_hub module – Add import to Editor and add ti_hub sensor module to the Modul
menu
Screen Example: Import sound
To import TI-Innovator™ sensor methods to your Python program, from the Editor,
1. Select [Fns…] > Modul 6:ti_hub
2. Select the ti_hub Import menu. Select a sensor type from Built-in, Input and
Output.
3. Select a sensor.
4. An import statement will paste to the Editor and the sensor module will be
available in [Fns...] > Modul when you return to that menu from your program.
5. Select [Fns…] > Modul 8:Sound... to paste appropriate methods for this sensor.

[Fns…]>Modul 6:ti_hub

Note: Brightns is a "built-in" object on TI-Innovator Hub.


When using the 'import brightns' statement, enter 'brightns.range(0,100)' to ensure
the correct default range at the start of the program execution.
Example:
import brightns
brightns.range(0,100)
b=brightns.measurement()
print(b)

[Fns] Menus, Modules and Add-On Modules 27


[Fns…]>Modul ti_rover module
ti_rover methods are not listed in Catalog and thus, not listed in the Reference Guide.
Please use the screen information in the menus for arguments and argument default
or allowed value details. More information on Python programming for
TI-Innovator™ Hub and TI-Innovator™ Rover will be available at education.ti.com.

Notes:
• In TI-Python programming, you do not need to include methods to connect and
disconnect TI-Innovator™ Rover. The TI-Innovator™ Rover Python methods handle
connect and disconnect with no additional methods. This is a bit different than
programming TI-Innovator™ Rover in TI-Basic.

28 [Fns] Menus, Modules and Add-On Modules


• rv.stop() executes as a pause and then resume continues with the Rover
movements in the queue. If another movement command is executed after
rv.stop(), then movement queue is cleared. This again is a bit different than
programming TI-Innovator™ Rover in TI-Basic.

Python Support for TI-Innovator Sketch v1.5

[Fns] Menus, Modules and Add-On Modules 29


[Fns...] Add-On Modules
Add-On modules enhance Python App module experience with additional functionality
and easy access to the additional Python methods from menus in the Python App.
You may notice an Add-On module to load, using TI Connect™ CE, as part of a Python
activity posted on education.ti.com such as ce_turtl, ce_chart, ce_box, ce_quivr, and
microbit depending on your region. You will need to have the latest version of currently
posted Add-On modules Some Add-On modules will load to your calculator, such as ti_
draw and ti_image, when you update with the latest CE Bundle.
The Python App will display the Add-On module menus in the [Fns…] > Modul menu
only if your program in the Editor starts with an appropriate import statement.
Pasting an Add-On Module import statement to the Editor
Steps:
1. Create a new program.
2. In Editor, select [Fns…] > Modul.
3. Select [Add-On] and when an Add-On module is loaded on the calculator, an
import statement menu for loaded modules will display.
4. Select the import statement to paste to the Editor.
5. Select [Fns…] > Modul to locate the menus for the Add-On imported module.

Facts:
• [Add-On Modules Imports…] is also listed in [2nd][catalog].
• Add-On modules are calculator “AppVar” files stored in Archive and appear in
[mem] as an AppVar. It is recommended to keep these files in Archive memory for
the enhanced Python App module experience.
• A Python program runs in the Python App from File Manager or Editor when the
“PY AppVar” program is in RAM. If a PY AppVar Python program is placed in
Archive memory, it will not be available to Run or Edit in the Python App.

30 [Fns] Menus, Modules and Add-On Modules


[Fns...] ti_draw Add-On Module
The ti_draw module is included in the latest CE Bundle. Use the [Fns…] > Modul [Add-
On] feature to paste the import statement to your program. The ti_draw menu will
then display in the [Fns…] > Modul menu as shown here.

Program information when using ti_draw:


• After the import statement, use the clear() method to clear the Shell drawing area
if needed.
• Programs must contain the show_draw() command to display the draw when
running the program.
• Using draw_rect(), draw_circle(), or draw_poly() methods draw the border of the
construction whereas fill_rect(), fill_circle(), and fill_poly() methods fill the interior
of the specified shape (dependent on pen size).
• Press [clear] to clear the draw and return to the Shell prompt. Shell history can be
viewed using [2nd] } and [2nd] †.
• Please read through the Shape and Control menu information in the table below.
Your drawings created with the methods in the Shape menu will depend on Control
menu methods such as set_color() and set_ pen().
• Coordinate arguments are either screen pixel coordinates or set by the set_window
() method.
- ti_draw methods using set_window() coordinates

[Fns] Menus, Modules and Add-On Modules 31


- ti_draw methods using pixel screen coordinates

Shape Menu Description


1: draw_line(x1,y1,x2,y2) Draws a line segment between the
specified points (x1,y1) and (x2,y2).
2: draw_rect(x,y,w,h) Draws a rectangle with upper left corner
at (x,y) with a width of w pixels and
height of h.
3: fill_rect(x,y,w,h) Fills the interior of a rectangle with
upper left corner at (x,y) with a width of
w pixels and height of h pixels.
4: draw_circle(x,y,r) Draws a circle with center located at
(x,y) and a radius of r pixels.
5: fill_circle(x,y,r) Draws a circle with center located at
(x,y) and a radius of r pixels and filled
with the specified color (using set_color
or black if not defined).
6: draw_text(x,y,"string") Draws the string as text on the display
with upper left corner of the text
starting at (x,y).
7: draw_poly(x-list,y-list) Draws a set of lines that may represent a
polygon. The lines are drawn using the
current pen size and pen color.
8: fill_poly(x-list,y-list) The x-list and y-list must be of equal-
length of list arguments into a list of (x,y)
vertices. The polygon is drawn by
connecting each pair of vertices and

32 [Fns] Menus, Modules and Add-On Modules


Shape Menu Description
filling the region with the current pen
color.
9: poly_xy(x,y,sh) sh=1-13 Using the x and y arguments as a center-
point location, the requested shape (sh)
value below will draw. Shapes are drawn
using the current pen color.

Shape Description
1 Filled circle of radius 2
2 Open circle of radius 2
3 3x3 filled square
4 3x3 open square
5 x mark is drawn
6 + mark is drawn
7 Single pixel
8 Filled circle with radius 4 pixels
9 Open circle with radius 4 pixels
10 Filled circle with radius 6 pixels
11 Open circle with radius 6 pixels
12 Filled circle with radius 8 pixels
13 Open circle with radius 8 pixels

Control Menu Description


1: clear() Clears the drawing area in the Shell. This
method must be executed prior to
drawing to ensure the Shell drawing area
is cleared to view expected results.
2: clear_rect(x,y,w,h) Fills the interior of a rectangle with
upper left corner at (x,y) and width w
height h.

White is the default fill color. After


pasting the method to the Editor, the
method can accept a fifth optional
argument to specify a different color via
the use of a tuple specifying (r,g,b) value.
A valid (r,g,b) tuple contains integer
values in range 0 to 255.
3: set_color(r,g,b) 0-255 Sets the drawing pen color using (r,g,b)
tuple.
4: set_pen("size","style") Sets the drawing pen to the “size” and

[Fns] Menus, Modules and Add-On Modules 33


Control Menu Description
“style” for all subsequent drawings until
a change is specified.

When importing ti_draw, size is "thin",


"medium", or "thick" and style is "solid",
"dotted", or "dashed". If not specified,
default arguments are "thin" and "solid."
The Argument Helper > will help fill the
correct argument strings.

Note: When importing ti_plotlib module,


pen() method style argument is "solid",
"dot", or "dash".
5: set_window Sets the draw area with coordinates
(xmn,xmx,ymn,ymx) ranges [xmin,xmax] and [ymin,ymax]
with (0,0) at midpoint of the ranges.
Please note: If argument values are
outside of the draw area specified, no
error is given.

If set_window(xmin,xmax,ymin,ymax) is
not executed in a program, the pixel
window window size is the default with
(xmin,xmax,ymin,ymax) = (0,319,0,209)
with (0,0) at upper left hand corner pixel
coordinate of the area.
6: show_draw() [clear] Must be included to display the draw.
Press [clear] to clear the draw and
return to the Shell prompt. To view Shell
history, press [2nd] } and [2nd] †.

34 [Fns] Menus, Modules and Add-On Modules


[Fns...] ti_image Add-On Module
The ti_image module is included in the latest CE Bundle. Use the [Fns…] > Modul [Add-
On] feature to paste the import statement to your program. The ti_image menu will
then display in the [Fns…] > Modul menu as shown here.

Program information when using ti_image:


• The ti_image module can be used to
- display your named Python image AppVar stored in Archive memory on your CE.
- display specified filled color rectangles in a pixel coordinate location.
- set or get a pixel color.
- clear the interior of a rectangular screen area.
- clear the full screen drawing area in Shell from pixel coordinates (0,0) to
(319,209).
• After the import statement, use the clear_image() method to clear the Shell
drawing area if needed.
• Python image AppVar is a special Python image file (*.8xv).
- Currently, a library of curriculum images are posted at
https://resources.t3europe.eu/t3europe-
home?country=15&q=images&cHash=d50a2b65ab1b875dfa3ec11bca12154c
- When using a Python image AppVar, it is best practice to
- store the Python image AppVar in Archive memeory. [2nd][mem]
- know the pixel dimensions of your image for use during coding.
- know the exact name of your Python image AppVar. You must enter the
name with the correct spelling and correct upper and lower case letters. No
errors will be given for mistyped Python image AppVar names.

[Fns] Menus, Modules and Add-On Modules 35


- Keep updated with the latest TI Connect CE and TI-SmartView CE at
education.ti.com/84cetupdate
• (x,y) coordinate arguments are pixel coordinates ONLY in ti_image methods and
range from (0,0) to (319,209). Please read more information on each method in
the table below. Some methods are offered to paste to the Editor in several
formats when optional arguments are offered.
• Press [clear] to clear the draw and return to the Shell prompt. Shell history can be
viewed using [2nd] } and [2nd] †.

Control Menu Description


1: load_image("name") Loads a Python image AppVar "name"
for use in the program.

The Python image "name" must be in


the exact case and spelling of the Python
image AppVar. Please note: There is no
error message generated if the AppVar
name is NOT specified exactly as named.

Python image "name" will be the image


used for display in show_image(x,y).

Best Practices:
• Know the pixel dimensions of your
Python image.
• Memory Tip: Python image AppVars
should be stored in Archive
Memory.
2: show_image(x,y) Displays the image specified in load_
image(“name”).

Displays the image with upper left pixel


corner (x,y) of the drawing area in the
Shell. (x,y) screen pixel coordinates
range from upper left as (0,0) to lower
right (319,209).

If no image name has been specified


using load_image(), an error is reported
when the program Runs. If “name” is
incorrectly entered, no error will display.

Use show_screen() method to retain the


image in display until [clear] to return to
the Shell. To view Shell history, press
[2nd] } and [2nd] †.

36 [Fns] Menus, Modules and Add-On Modules


Control Menu Description
3: clear_image() (0,0)-(319,209) The clear_image() method with no
arguments is used to clear the drawing
area of the Shell. The drawing area will
display as the white screen.

The pixels coordinates range from upper


left as (0,0) to lower right (319,209).

After the full drawing area is "cleared"


with this method, use load_image
("name") method and show_image(x,y)
to display the “name” image as needed.

When also using ti_draw module


methods, note that set_pen() color will
be set to black when ti_image method,
clear_image(), is executed.
4: clear_image(x,y,w,h) white Given an (x,y) pixel coordinate for the
upper left corner of a rectangle w pixels
wide and h pixels high, this method will
"clear" the interior rectangular area to
white.
5: clear_image(x,y,w,h,(r,g,b)) Given an (x,y) pixel coordinate for the
upper left corner of a rectangle w pixels
wide and h pixels high, this method will
"clear" the interior rectangular area to
the specified RGB color in given in the
tuple (r,g,b).
6: tuple=get_pixel(x,y) Returns RGB values of the pixel at pixel
coordinate (x,y) as a tuple (r,g,b).
7: set_pixel(x,y,(r,g,b)) Sets the color of the pixel at pixel
coordinate (x,y) to the RGB color
specified in (r,g,b).

[Fns] Menus, Modules and Add-On Modules 37


Python App Messages
There are several messages that may display while you are in a Python session. Some
selected messages are given in the table. Please follow the instructions on the screen
and navigate using [Quit], [Esc] or [Ok] as needed.

Memory Management
The available memory for the Python
experience will be a maximum of 100 Python
programs (PY AppVars) or 50K of memory. The
modules that are bundled with the app in this
Python release will share the same space with
all files.
Use [2nd] [quit] to quit the App
You will be prompted to make sure you want
to quit the App. Quitting the App will stop your
Python session. When you run the Python App
again, your Python AppVar programs and
modules will synchronize. The Shell will
reinitialize.
In File Manager, you press { on a selected
Python program or you select from File
Manager>Manage 2:Delete Program....
You will see a dialog to delete or escape back
to the File Manager.

You attempt to create a new or duplicate a


Python program that already exists on your CE
either in RAM or Archive or disabled for exam
mode. Please enter a different name.

You attempt to navigate from the Shell to the


Editor but the Editor is empty. Please select an
appropriate option for your work.

38 Python App Messages


When you execute a Python program, defined
variables from the last program executed are
listed in the Shell>Tools> 4:Vars… menu to use
and are avaliable for use in the Shell. If no
variables display, you may need to run your
program again.

Python App Messages 39


Using TI-SmartView™ CE-T and the Python Experience
This guidebook assumes the latest update
of TI-SmartView™ CE-T. Update to the
latest TI-SmartView™ CE-T at
education.ti.com/84cetupdate.
The update includes the latest
TI-84 Plus CE-T Python Edition emulator
OS running the latest Python App. The
updated modules of time,
ti_system, ti_plotlib, ti_rover* and ti_
hub* are included.
Run the Python App on the
TI-84 Plus CE-T Python Edition emulator.
• The Python App offers
– File Manager
– Editor
– Execution of your Python program
in the Shell*

Hub/Rover Programs
– Create ti_hub/ti_rover Python programs in the CE emulator running the Python
App.
* Note: There is no connectivity between TI-SmartView™ CE-T and
TI-Innovator™ Hub or TI-Innovator™ Rover. Programs can be created and then
run on the CE calculator.
– Quit the Python App to prepare to transfer the Python AppVar(s) from the
emulator. The emulator should not “be busy” running an App or program for
the next step.

40 Python App Messages


– Change to the Emulator Explorer workspace and send the program(s) to the
computer.
– Use TI Connect™ CE to send the Python AppVars from the computer to the CE
calculator for the TI-Innovator™ Hub/TI-Innovator™ Rover experience.
Note: To break a running Python program in the Shell, such as if a program is in a
continuous loop, press [on]. Press [Tools] [zoom] > 6:New Shell as an alternate method
to halt a running program.
Reminder: For any computer/TI-Python experience: After creating a Python program in
a Python development environment on the computer, please validate your program
runs on the calculator/emulator in the TI-Python experience. Modify the program as
needed.
SmartPad CE App Remote Keypad
– When running the SmartPad CE App on your connected CE will behave as a
remote keypad including the special keypad mapping offered when the Python
App is running.
Emulator Explorer Workspace
– Please quit the Python App so the emulator is not busy when you access the full
features of the Emulator Explorer workspace.
– program.py < > PY AppVar conversions are allowed. This is similar to the TI
Connect™ CE experience when sending programs to the connected CE
calculator.
– When sending a program.py file created in another Python environment, your
PY AppVar will need to be edited to run as expected in TI-Python. Use the
Python App Editor to modify as needed for the unique modules such as
ti_plotlib, ti_system, ti_hub and ti_rover.
Data Import Wizard
– *.csv files of data, formatted as stated in the wizard dialog, will convert data
into CE list variables. Methods in ti_system can then be used to share lists
between the emulator CE OS and the Python App. This feature is similar to the
Data Import Wizard in TI Connect™ CE.
- If decimal numbers are represented with the use of a comma in the *.csv file,
the file will not convert using the Data Import Wizard. Please check your
computer operating system number formatting and convert the *.csv to use the
decimal point representation. The CE calculator list and matrix editor use the
number format as, for example, 12.34 and not 12,34.
Using TI Connect™ CE to Convert Python Programs
Please update to TI Connect™ CE for the latest features including converting *.py
programs to a PY AppVar as the CE calculator file format.

See TI-84 Plus CE-T e-Guide for more details on the CE calculator, TI-SmartView™ CE-T
and TI Connect™ CE.

Python App Messages 41


What is the Python programming experience?
TI-Python is based on CircuitPython, a variant of Python designed to fit in small
microcontrollers. The original CircuitPython implementation has been adapted for use
by TI.
The internal storage of numbers for computation in this variant of Circuit Python is in
limited-precision binary floats and thus cannot exactly represent all possible decimal
values. The differences from actual decimal representations that arise when storing
these values can lead to unexpected results in subsequent calculations.
• For Floats - Displays up to 16 significant digits of precision. Internally, values are
stored using 53 bits of precision, which is roughly equivalent to 15-16 decimal
digits.
• For Integers - The size of integers is limited only by the memory available at the
time calculations are performed.
Modules Included in the TI-84 Plus CE-T Python Edition
• Built-ins
• math module
• random module
• time
• ti_system
• ti_plotlib
• ti_hub
• ti_rover
Note: If you have existing Python programs created in other Python development
environments, please edit your program(s) to the TI-Python solution. Modules may use
different methods, arguments, and ordering of methods in a program as compared to
the ti_system, ti_plotlib, ti_hub, and ti_rover modules. In general, be aware of
compatibility when using any version of Python and Python modules.
When transferring Python programs from a non-TI platform to a TI platform OR from
one TI product to another:
- Python programs that use core language features and standard libs (math,
random etc.) can be ported without changes
Note: List length limit is 100 elements.
- Programs that use platform-specific libraries - matplotlib (for PC), ti_plotlib,
ti_system, ti_hub, etc. for TI platforms, will require edits before they will run
on a different platform.
- This may be true even between TI platforms.

42 What is the Python programming experience?


As with any version of Python, you will need to include imports such as, from math
import *, to use any functions, methods, or constants contained in the math module.
For an example, to execute the cos() function, use import to import the math module
for use.
See CATALOG Listing.
Example:
>>>from math import *
>>>cos(0)
1.0

Alternate Example:
>>>import math
>>>math.cos(0)
1.0

Modules available can be displayed in the Shell using the following command
>>> help("modules")
__main__ sys gc
random time array
math builtins collections

Content of modules can be viewed in the Shell as shown using “import module” and
“dir(module).”
Not all module contents appear in the quick paste menus such as [Fns…] or y
N.

What is the Python programming experience? 43


Contents of selected modules and keywords
For list of the modules included in this release, please see:
Appendix: Selected TI-Python Built-in, Keywords, and Module Content
Reminder: For any computer/TI-Python experience: After creating a Python program on
the computer, please validate your program runs on the calculator in the TI-Python
experience. Modify the program as needed.

These screens display the module contents for math and random.

math module random module

44 What is the Python programming experience?


These screens display the module contents for time and ti_system.

time ti_system

What is the Python programming experience? 45


These screens display the module contents for ti_plotlib.

ti_plotlib

46 What is the Python programming experience?


This screen displays the module contents for ti_hub.

ti_hub

What is the Python programming experience? 47


These screens display the module contents for ti_rover.

ti_rover

48 What is the Python programming experience?


Sample Programs
Use the following Sample Programs to become familiar with methods from the
Reference section. These samples also contain several TI-Innovator™ Hub and
TI-Innovator Rover™ programs to help you get started with TI-Python.

COLORLIN
import ti_plotlib as plt
plt.cls()
plt.window(-10,10,-10,10)
plt.axes("on")
plt.grid(1,1,"dot")
plt.title("TITLE")
plt.pen("medium","solid")
plt.color(28,242,221)
plt.pen("medium","dash")
plt.line(-5,5,5,-5,"")
plt.color(224,54,243)
plt.line(-5,-5,5,5,"")
plt.show_plot()

Press ‘ to display the Shell prompt

REGEQ1
Setup a regression equation prior to running the Python program in the Python App. An
example would be to first, enter two lists in the CE OS. Then, for example, calculate
[stat] CALC 4:LinReg(ax+b) for your lists. This stores the regression equation to RegEQ
in the OS. Here is a program to recall RegEQ to the Python experience.
# Example of recall_RegEQ()
from ti_system import *
reg=recall_RegEQ()
print(reg)
x=float(input("Input x = "))
print("RegEQ(x) = ",eval(reg))

Sample Programs 49
LINREGR (Provided in CE Bundle)
import ti_plotlib as plt
# current intensity
I = [0.0, 0.9, 2.1, 3.1, 3.9, 5.0, 6.0, 7.1, 8.0, 9.2, 9.9, 11.0,11.9]
# voltage
for n in range (len(I)):
I[n] /= 1000
# la tension
U = [0, 1, 2, 3.2, 4, 4.9, 5.8, 7, 8.1, 9.1, 10, 11.2, 12]
plt.cls()
plt.auto_window(I,U)
plt.pen("thin","solid")
plt.axes("on")
plt.grid(.002,2,"dot")
plt.title("Ohm's Law")
plt.color (0,0,255)
plt.labels("I","U",11,2)
plt.scatter(I,U,"x")
plt.color (255,0,0)
plt.pen("thin","dash")
plt.lin_reg(I,U,"center",2)
plt.show_plot()
plt.cls()
a=plt.a
b=plt.b
print ("a =",round(plt.a,2))
print ("b =",round(plt.b,2))

Press ‘ to display the Shell prompt

50 Sample Programs
GRAPH (Provided in CE Bundle)
import ti_plotlib as plt
#After running the program, press [clear] to clear plot and return to
Shell.
def f(x):
••return 3*x**2-.4
def g(x):
••return -f(x)
def plot(res,xmin,xmax):
••#setup plotting area
••plt.window(xmin,xmax,xmin/1.5,xmax/1.5)
••plt.cls()
••gscale=5
••plt.grid((plt.xmax-plt.xmin)/gscale*(3/4),(plt.ymax-
plt.ymin)/gscale,"dash")
••plt.pen("thin","solid")
••plt.color(0,0,0)
••plt.axes("on")
••plt.labels("abscisse"," ordonnee",6,1)
••plt.pen("medium","solid")
# plot f(x) and g(x)
dX=(plt.xmax -plt.xmin)/res
x=plt.xmin
x0=x
••for i in range(res):
••••plt.color(255,0,0)
••••plt.line(x0,f(x0),x,f(x),"")
••••plt.color(0,0,255)
••••plt.plot(x,g(x),"o")
••••x0=x
••••x+=dX
••plt.show_plot()
#plot(resolution,xmin,xmax)
plot(30,-1,1)
# Create a graph with parameters(resolution,xmin,xmax)
# After clearing the first graph, press the [var] key. The plot()
function allows you to change the display settings
(resolution,xmin,xmax).

Press ‘ to display the Shell prompt

Sample Programs 51
DASH1 – Sample TI-Innovator™ Hub Program
See: [Fns…]>Modul: ti_hub module
from ti_system import *
import brightns
import ti_plotlib as plt
from time import *
plt.cls()
plt.color(0,0,255)
plt.text_at(2,"Monitoring Hub","center")
plt.text_at(3,"Brightness Sensor","center")
plt.color(255,0,0)
plt.text_at(12,"Press [clear] to quit ","right")
t0=monotonic()
plt.color(0,0,0)
while not escape():
••I=brightns.measurement()
••I=round(I,1)
••tf=monotonic()
••plt.color(0,0,0)
••tm=round(tf-t0,1)
••msg="Time = %.1f sec" % tm
••plt.text_at(6,msg,"center")
••msg="Brightness = %.1f %%" %I
••plt.text_at(7,msg,"center")
••sleep(1)

52 Sample Programs
ROVER – Sample TI-Innovator™ Rover program
See: [Fns…]>Modul ti_rover module
from ti_system import *
import ti_rover as rv
disp_clr()
disp_cursor(0)
disp_at(6,"Press [clear] to stop","center")
rv.forward(20)
while not escape():
••a=rv.ranger_measurement()
••if a<0.2:
••••rv.color_rgb(255,0,0)
••••rv.stop()
••else:
••••rv.color_rgb(0,255,0)
••••rv.resume()
rv.stop()
disp_clr()
rv.color_rgb(0,0,255)
sleep(1)
rv.color_rgb(0,0,0)

Sample Programs 53
BLNKSND - Sample TI-Innovator™ Hub Program
See: [Fns…]>Modul: ti_hub module

54 Sample Programs
SQUARE - Sample TI-Innovator™ Rover Program
See: [Fns…]>Modul ti_rover module

Sample Programs 55
STOP_GO - Sample ti_draw, ti_image, time Program
See: [Fns…]>Modul [Add-On]
from ti_draw import *
from ti_image import *
from time import *
clear()
# Pixel screen upper left (0,0) to (319,209)
draw_text(100,20,"Traffic Light")
set_pen("medium","solid")
draw_rect(120,25,80,175)
set_color(192,192,192)
fill_rect(120,25,80,175)
set_color(128,128,128)
draw_circle(160,55,22)
draw_circle(160,110,22)
draw_circle(160,165,22)
def off(x,y):
••set_color(169,169,169)
••fill_circle(x,y,22)
••set_color(128,128,128)
••draw_circle(x,y,22)
for i in (1,20,1):
# Green
••set_color(51,165,50)
••fill_circle(160,165,22)
••sleep(3)
••off(160,165)
# Yellow
••set_color(247,239,10)
••fill_circle(160,110,22)
••sleep(2)
••off(160,110)
# Red
••set_color(255,0,0)
••fill_circle(160,55,22)
••sleep(3)
••off(160,55)
••show_draw()

56 Sample Programs
Reference Guide for TI-Python Experience
The Python App contains menus of functions, classes, controls, operators and keywords
for quick pasting in the Editor or Shell. The following reference table contains the
listing of features in y N when the App is running. For a complete listing of
Python functions, classes, operators, and keywords available in this version, please see
"Selected TI-Python Built-in, Keywords, and Module Content."
This table is not intended to be an exhaustive list of Python available in this offering.
Other functions supported in this Python offering can be entered using the alpha keys
from the keypad.
Most examples given in this table run at the Shell prompt (>>>).

CATALOG Listing
Alphabetical List
• A
• B
• C
• D
• E
• F
• G
• H
• I
• L
• M
• N
• O
• P
• R
• S
• T
• U
• W
• X
• Y
• Symbols

Reference Guide for TI-Python Experience 57


A

#
Delimiter yN
Syntax: #Your comment about your program.
Description: In Python, a comment begins with the [a A #]
hash tag character, #, and extends to the end of the
line.
Example:
#A short explanation of the code.

%
Operator yN
Syntax: x%y or x % y
Description: Returns remainder of x/y. Preferred use [a A #]
is when x and y are integers.
Example:
>>>57%2
1

See also fmod(x,y).

//
Operator yN
Syntax: x//y or x // y
Description: Returns the floor division of x/y. [a A #]
Example:
>>>26//7
3
>>>65.4//3
21.0

58 Reference Guide for TI-Python Experience


[a A #]
[a A #]
shortcut is
Description: Launch [a A #] character palette. on screen at
Includes accented characters such as ç à â è é ê ë î ï ô ö ù û p in the
Editor or
Shell

a gradient; slope
Module: ti_plotlib yN
Syntax: plt.a gradient; slope [Fns...]>Modul
or »
Description: After plt.linreg() is last executed in a 5:ti_plotlib...>
program, the computed values of slope, a, and intercept , Properties
b, are stored in plt.a and plt.b. 5:a
Default values: = 0.0
Example: import
commands
See sample program: LINREGR. can be found
in y
N or in
the ti_plotlib
Setup menu.

abs()
Module: Built-in yN
Syntax: abs(x)
Description: Returns the absolute value of a number. Note:
In this release, the argument may be an integer or fabs()
floating point number. is a function in
the math
Example: module.
>>>abs(-35.4)
35.4

Reference Guide for TI-Python Experience 59


acos()
Module: math ˜ 7:acos()
Syntax: acos(x)
Description: Returns arc cosine of x in radians. yN
Example:
>>>from math import * [Fns…] Modul
>>>acos(1) 1:math… >
0.0
Trig
Alternate Example: [Tools] > 6:New Shell 7:acos()

>>>import math
>>>math.acos(1)
0.0 import
commands
can be found
in
yN

and
Keyword y:
Ops 8:and
Syntax: x and y
Description: May return True or False. Returns “x” if
“x” is False and “y” otherwise. Pastes with space [Fns…] > Ops
before and after and. Edit as needed. 8:and
Example:
>>>2<5 and 5<10 yN
True
>>>2<5 and 15<10
False
>>>{1} and 3 [a A #]
3
>>>0 and 5 < 10
0

60 Reference Guide for TI-Python Experience


.append(x)
Module: Built-in y9
List
Syntax: listname.append(item) 6: .append(x)
Description: The method append() appends an item to
a list.
yN
Example:
>>>listA = [2,4,6,8]
>>>listA.append(10) [Fns…] > List
>>>print(listA)
[2,4,6,8,10]
6:.append(x)

as
Keyword yN
Description: Use as to create an alias when importing
a module. See Python documentation for more
details.

asin()
Module: math ˜ 6:asin()
Syntax: asin()
Description: Returns arc sine of x in radians. yN
Example:
>>>from math import * [Fns…] >
>>>asin(1) Modul
1.570796326794897
1:math... >
Alternate Example: Trig
6:asin()
>>>import math
>>>math.asin(1)
1.570796326794897
import
commands
can be found
in
yN

Reference Guide for TI-Python Experience 61


assert
Keyword yN
Description: Use assert to test a condition in your
code. Returns None or if not, execution of the
program will display an AssertionError.

atan()
Module: math ˜ 8:atan()
Syntax: atan(x)
Description: Returns arc tangent of x in radians. [Fns…]>Modul
1:math... > Trig
Example: 8 :atan()
>>>from math import *
>>>atan(1)*4
3.141592653589793
yN
Alternate Example:
>>>import math
>>>math.atan(1)*4 import commands
3.141592653589793 can be found in
yN

atan2(y,x)
Module: math ˜ 9:atan2()
Syntax: atan2(y,x)
Description: Returns arc tangent of y/x in radians. Result [Fns…] >
is in [-pi, pi]. Modul
1:math... > Trig
Example: 9:atan2()
>>>from math import *
>>>atan2(pi,2)
1.003884821853887
yN
Alternate Example:
>>>import math
>>>math.atan2(math.pi,2) import
1.003884821853887 commands can
be found in
yN

62 Reference Guide for TI-Python Experience


auto_window(xlist,ylist)
Module: ti_plotlib yN
Syntax: plt.auto_window(xlist,ylist) [Fns...]>Modul
or »
Description: Autoscales the plotting window to fit the 5:ti_plotlib...>
data ranges within xlist and ylist specified in the Setup
program prior to the auto_window(). 5:auto_window
Note: max(list) - min(list) > 0.00001 ()

Example:
import
See sample program: LINREGR. commands can
be found in
y N or
in the
ti_plotlib Setup
menu.

Reference Guide for TI-Python Experience 63


axes("mode")
Module: ti_plotlib yN
Syntax: plt.axes("mode") [Fns...]>Modul
or »
Description: Displays axes on specified window in the 5:ti_plotlib...>
plotting area. Setup
Argument: 6:axes()

"mode" argument options:


import
"off" no axes commands can
be found in y
"on" axes+labels
N or in the
"axes" axes only ti_plotlib Setup
"window" window labels menu.
only

plt.axes() uses the current pen color setting. To ensure


plt.axes() are always drawn as expected, use plt.color()
BEFORE plt.axes() to ensure the colors are expected.
Example:
See sample program LINREGR.

64 Reference Guide for TI-Python Experience


B

b y= intercept
Module: ti_plotlib yN
Syntax: plt.b y= intercept [Fns...]>Modul
or »
Description: After plt.linreg() is executed in a program, 5:ti_plotlib...>
the computed values of slope, a, and intercept , b, are Properties
stored in plt.a and plt.b. 6:b
Default values: = 0.0
Example: import
commands can
See sample program LINREGR. be found in
y N or
in the
ti_plotlib Setup
menu.

bin(integer)
Module: Built-in yN
Syntax: bin(integer)
Description: Displays binary format of the integer
argument.
See Python documentation for more details.
Example:
>>> bin(2)
'0b10'
>>> bin(4)
'0b100'

break
Keyword yN
Description: Use break to break out of a for or while
loop.

Reference Guide for TI-Python Experience 65


C

ceil()
Module: math » Modul
1:math... Math
Syntax: ceil(x) 8:ceil()
Description: Returns the smallest integer greater than or
equal to x.
yN
Example:
>>>from math import *
>>>ceil(34.46) [Fns...] Modul
35
>>>ceil(678)
1:math...Math
678 8:ceil()

import
commands can
be found in
yN

choice(sequence)
Module: random » Modul
2:random...
Syntax: choice(sequence) Random
Description: Returns a random element from 5:choice(sequence)
a non-empty sequence.
Example: yN
>>>from random import *
>>>listA=[2,4,6,8]
>>>choice(listA) #Your result may differ. [Fns...] Modul
4
2:random...
Random
5:choice(sequence)

import commands can be


found in
yN

66 Reference Guide for TI-Python Experience


chr(integer)
Module: Built-in yN
Syntax: chr(integer)
Description: Returns a string from an integer input
representing the unicode character.
See Python documentation for more details.
Example:
>>> char(40)
'('
>>> char(35)
'#'

class
Keyword yN
Description: Use class to create a class. See Python
documentation for more details.

cls() clear screen


Module: ti_plotlib yN
Syntax: plt.cls() clear screen [Fns...]>Modul
or »
Description: Clears Shell screen for the plotting. Shortcut 5:ti_plotlib...>
keys are not in display when plotting. Setup
Note:plt.cls() has a different behavior than ti_system 2:cls()
module disp_clr(). [Fns...]>Modul
Example: or »
5:ti_plotlib...>
See sample program: GRAPH. Draw
2:cls()

import
commands
can be found
in y
N or in
the
ti_plotlib
Setup menu.

Reference Guide for TI-Python Experience 67


color(r,g,b) 0-255
Module: ti_plotlib yN
Syntax: plt.color(r,g,b) 0-255 [Fns...]>Modul
or »
Description: Sets the color for all following 5:ti_plotlib...>
graphics/plotting. (r,g,b) values must be specified 0- Draw
255. Color specified is used in plot display until color() is 1:color()
again executed with a different color.
Default color is black upon importing ti_plotlib. import
Example: commands can
be found in
See sample program: COLORLIN. y N or
in the ti_plotlib
Setup menu.

complex(real,imag)
Module: Built-in yN
Syntax: complex(real,imag) [Fns...]>Type>
5:complex()
Description: Complex number type.
Example:
>>>z = complex(2, -3)
>>>print(z)
(2-3j)
>>>z = complex(1)
>>>print(z)
(1+0j)
>>>z = complex()
>>>print(z)
0j
>>>z = complex("5-9j")
>>>print(z)
(5-9j)

Note:"1+2j" is correct syntax. Spaces such as "1 + 2j"


will display an Exception.

68 Reference Guide for TI-Python Experience


continue
Keyword yN
Description: Use continue in a for or while loop to
end the current iteration. See Python documentation
for more details.

cos()
Module: math ˜ Trig
4: cos()
Syntax: cos(x)
Description: Returns cos of x. Angle argument is in
radians. yN
Example:
>>>from math import * [Fns...] Modul
>>>cos(0) 1:math... > Trig
1.0
>>>cos(pi/2)
4:cos()
6.123233995736767e-17

Alternate Example:
>>>import math
>>>math.cos(0)
1.0

Note: Python displays scientific notation using e or E.


Some math results in Python will be different than in
the CE OS.

.count()
Module: Built-in yN
Syntax: listname.count(item)
Description: count()is a method that returns the
number of occurrences of an item in a list, tuple,
bytes, str, bytearray, or array.array object.
Example:
>>>listA = [2,4,2,6,2,8,2,10]
>>>listA.count(2)
4

Reference Guide for TI-Python Experience 69


D

def function():
Keyword yN
Syntax: def function(var, var,...)
Description: Define a function dependent on specified [Fns…]>Func
variables. Typically used with the keyword return. 1:def function():
Example: [Fns…]>Func
2:return
>>> def f(a,b):
… return a*b



>>> f(2,3)
6

degrees()
Module: math ˜ Trig
2:degrees()
Syntax: degrees(x)
Description: Converts angle x in radians to degrees.
yN
Example:
>>>from math import *
>>>degrees(pi) [Fns…]>Modul
180.0
>>>degrees(pi/2)
1:math…>Trig
90.0 2:degrees()

del
Keyword yN
Description: Use del to delete objects such as
variables, lists, etc.
See Python documentation for more details.

70 Reference Guide for TI-Python Experience


disp_at(row,col,"text")
Module: ti_system yN
Syntax: disp_at(row,col,"text") yK
ti_system
Description: Display text starting at a row and column 7:disp_at()
position on the plotting area.
[Fns…]>Modul
REPL with cursor >>>| will appear after text if at end of or »
program. Use disp_cursor() to control cursor display. 4:ti_system
Argument: 7:disp_at()

row 1 - 11, integer


import
column 1 - 32, integer commands can
"text" is a string which be found in
will wrap on the y N or
screen area in the
ti_system
Optional arguments for color and background shown Modul menu.
here: disp_at(row,col,"text","align",color 0-15,
background color 0-5)
Example:
Sample program:
from ti_system import *
disp_clr() #clears Shell screen
disp_at(5,6,"hello")
disp_cursor(0)
disp_wait()

Reference Guide for TI-Python Experience 71


disp_at(row,"text","align")
Module: ti_system yN
Syntax: disp_at(row,"text","align") yK
ti_system
Description: Display text aligned as specified on the 7:disp_at()
plotting screen for row 1-11. Row is cleared before
display. If used in a loop, content refreshes with each
display. [Fns…]>Modul
or »
REPL with cursor >>>| will appear after text if at end of 4:ti_system
program. Use disp_cursor() to control cursor display 7:disp_at()
before the use of disp_at() in your program.
Argument: import
row 1 - 11, integer
commands can
be found in y
"text" is a string which N or in the
will wrap on the ti_system
screen area Modul menu.
"align" "left" (default)
"center"
"right"

Optional argument shown here: disp_at


(row,"text","align","color 0-15, background color 0-15)
Example:
Sample program:
from ti_system import *
disp_clr() #clears Shell screen
disp_at(5,"hello","left")
disp_cursor(0)
disp_wait()

72 Reference Guide for TI-Python Experience


disp_clr() clear text screen
Module: ti_system yN
Syntax: disp_clr() clear text screen yK
ti_system
Description: Clear the screen in the Shell environment. 8:disp_clr()
Row 0-11, integer may be used as an optional
argument to clear a display row of the Shell
environment. [Fns…]>Modul
or »
Example: 4:ti_system
Sample program: 8:disp_clr()

from ti_system import *


disp_clr() #clears Shell screen import
disp_at(5,"hello","left") commands can
disp_cursor(0) be found in y
disp_wait() N or in
the
ti_system
Modul menu.

Reference Guide for TI-Python Experience 73


disp_cursor() 0=off 1=on
Module: ti_system yN
Syntax: disp_cursor() 0=off 1=on yK
ti_system
Description: Control the display of the cursor in the 0:disp_cursor()
Shell when a program is running.
Argument: [Fns…]>Modul or
0 = off »
4:ti_system
not 0 = on 0:disp_cursor()
Example:
import commands
Sample program: can be found in
from ti_system import * y N or in
disp_clr() #clears Shell screen the
disp_at(5,"hello","left") ti_system Modul
disp_cursor(0) menu.
disp_wait()

74 Reference Guide for TI-Python Experience


disp_wait() [clear]
Module: ti_system yN
Syntax: disp_wait() [clear] yK
ti_system
Description: Stop the execution of program at this point 9:disp_wait()
and display screen content until [clear] is pressed and
the screen is cleared.
[Fns…]>Modul
Example: or »
Sample program: 4:ti_system
9:disp_wait()
from ti_system import *
disp_clr() #clears Shell screen
disp_at(5,"hello","left") import
disp_cursor(0) commands can
disp_wait() be found in
y N or
in the
ti_system
Modul menu.

Reference Guide for TI-Python Experience 75


E

e
Module: math y 4 (above
¥)
Syntax: math.e or e if math module was imported
Description: Constant e displays as shown below.
[Fns…] >
Example: Modul
>>>from math import * 1:math…
>>>e > Const 1:e
2.718281828459045

Alternate Example:
>>>import math
>>>math.e
2.718281828459045

elif :
Keyword yN
See if..elif..else.. for details.
[Fns…] > Ctl
1:if..
2:if..else..
3:if..elif..else
9:elif :
0:else:

76 Reference Guide for TI-Python Experience


else:
Keyword yN
See if..elif..else.. for details.
[Fns…] > Ctl
1:if..
2:if..else..
3:if..elif..else
9:elif :
0:else:

escape()
Module: ti_system yN
Syntax: escape() As a program
line:
Description: escape() returns True or False.
yK
Initial value is False. ti_system
When the [clear] key on CE is pressed, the value is set to 5:while not
True. escape():
6:if escape
When the function is executed the value is reset to ():break
False.
[Fns…]>Modul
Example of use: or »
4:ti-system
while not escape(): 5:while not
In a while loop running in a program where the program escape():
offers to end the loop but keep the script running. 6:if escape
():break

if escape():break import
commands can
Can be used to a debug program to inspect the vars be found in
using Shell [vars] after running the program and using yN
this break. or in the
ti_system
Modul menu.

Reference Guide for TI-Python Experience 77


eval()
Module: Built-in yN
Syntax: eval(x)
Description: Returns the evaluation of the expression x. [Fns…] I/O
3:eval()
Example:
>>>a=7
>>>eval(“a+9”)
16
>>>eval(‘a+10’)
17

except exception:
Keyword yN
Description: Use except in a try..except code block.
See Python documentation for more details.

78 Reference Guide for TI-Python Experience


exp()
Module: math yJ
(above µ)
Syntax: exp(x)
Description: Returns e**x.
yN
Example:
>>>from math import *
>>>exp(1) [Fns…] >
2.718281828459046
Modul
Alternate Example: [Tools] > 6:New Shell 1:math…
4:exp()
>>>import math
>>>math.exp(1)
2.718281828459046
import
commands
can be found
in
y N.

.extend()
Module: Built-in yN
Syntax: listname.extend(newlist)
Description: The method extend() is a method to
extend newlist to the end of a list.
Example:
>>>listA = [2,4,6,8]
>>>listA.extend([10,12])
>>>print(listA)
[2,4,6,8,10,12]

Reference Guide for TI-Python Experience 79


F

fabs()
Module: math yN
Syntax: fabs(x)
Description: Returns the absolute value of x [Fns…] >
Modul
Example: 1:math...
>>>from math import * 2:fabs()
>>>fabs(35-65.8)
30.8
import
commands
can be found
in
y N.

See also
Built-in
function
abs().

False
Keyword y : (above
»)
Description: Returns False when statement executed
is False. "False" represents the false value of objects
of type bool.
yN
Example:
>>>64<=32
False [Fns…] > Ops
B:False

[a A #]

80 Reference Guide for TI-Python Experience


finally:
Keyword yN
Description: Use finally in a try..except..finally code
block. See Python documentation for more details.

float()
Module: Built-in yN
Syntax: float(x)
Description: Returns x as a float. [Fns…] > Type
2:float()
Example:
>>>float(35)
35.0
>>>float(“1234”)
1234.0

floor()
Module: math » Modul
1:math
Syntax: floor(x) 9:floor()
Description: Returns the largest integer less than or
equal to x.
yN
Example:
>>>from math import *
>>>floor(36.87) [Fns…] > Modul
36
>>>floor(-36.87)
1:math
-37 9:floor()
>>>floor(254)
254 import
commands can
be found in
yN

Reference Guide for TI-Python Experience 81


fmod(x,y)
Module: math » Modul
1:math
Syntax: fmod(x,y) 7:fmod()
Description: See Python documentation for more
details. Preferred use is when x and y are floats.
yN
May not return the same result as x%y.
Example:
[Fns…] > Modul
>>>from math import *
>>>fmod(50.0,8.0)
1:math…
2.0 7:fmod()
>>>fmod(-50.0,8.0)
-2.0
>>>-50.0 – (-6.0)*8.0 #validation from description
-2.0 import
commands can
See also: x%y. be found in
yN

for i in list:
Keyword [Fns…] Ctl
7:for i in list:
Syntax: for i in list:
Description: Used to iterate over list elements.
yN
Example:
>>> for i in [2,4,6]:
… print(i)



2
4
6

82 Reference Guide for TI-Python Experience


for i in range(size):
Keyword [Fns…] Ctl
4:for i in range
Syntax: for i in range(size) (size):
Description: Used to iterate over a range.
Example: yN
>>> for i in range(3):
… print(i)



0
1
2

for i in range(start,stop):
Keyword [Fns…] Ctl
5:for i in range
Syntax: for i in range(start,stop) (start,stop):
Description: Used to iterate over a range.
Example: yN
>>> for i in range(1,4):
… print(i)



1
2
3

Reference Guide for TI-Python Experience 83


for i in range(start,stop,step):
Keyword [Fns…] Ctl
6:for i in range
Syntax: for i in range(start,stop,step) (start,stop,step):
Description: Used to iterate over a range.
Example: yN
>>> for i in range(1,8,2):
… print(i)



1
3
4
7

str.format() string format


Module: Built-in yN
Syntax:str.format()
Description: Formats the given string. See Python
documentation for more details.
Example:
>>> print("{+f}".format(12.34))
+12.340000

84 Reference Guide for TI-Python Experience


frexp()
Module: math » Modul
1:math
Syntax: frexp(x) A:frexp()
Description: Returns a pair (y,n) where x == y * 2**n. y
is float where 0.5<abs(y)<1; and n is integer.
yN
Example:
>>>from math import *
>>>frexp(2000.0) [Fns…] > Modul
(0.9765625, 11)
>>>0.9765625 * 2**11 #validate description
1:math
2000.0 A:frexp()

import
commands can
be found in
yN

from PROGRAM import *


Keyword Shell [Tools]
A:from
Syntax: from PROGRAM import * PROGRAM
Description: Used to import a program. Imports the import *
public attributes of a Python module into the current
name space.
yN

Reference Guide for TI-Python Experience 85


from math import *
Keyword
Syntax: from math import * » Modul
1:math…
Description: Used to import all functions and constants 1:from math
from the math module. import *

[Fns..] > Modul


1:math…
1:from math
import *

yN

from random import *


Keyword
» Modul
Syntax: from random import * 2:random…
Description: Used to import all functions 1:from random
from the random module. import *

[Fns..] > Modul


2:random…
1:from random
import *

yN

86 Reference Guide for TI-Python Experience


from time import *
Keyword yN
Syntax: from time import * » Modul
3:time…
Description: Used to import all methods from the 1:from time import
time module. *
Example: [Fns…]>Modul
See sample program: DASH1. 3:time…
1:from time import
*

from ti_system import *


Keyword yN
Syntax: from ti_system import * » Modul
4:ti_system…
Description: Used to import all methods from the ti_ 1:from system
system module. import *
Example: [Fns…]>Modul
See sample program: REGEQ1. 4:ti_system…
1:from system
import *

Reference Guide for TI-Python Experience 87


from ti_hub import *
Keyword yN
Syntax: from ti_hub import *
Description: Used to import all methods from the ti_
hub module. For individual input and output devices,
use the dynamic module functionality by selecting
the device from [Fns…]>Modul>ti_hub>Import menu
when in the Editor.
See:ti_hub module – Add import to Editor and add ti_
hub sensor module to the Modul menu.
Example:
See sample program: DASH1.

88 Reference Guide for TI-Python Experience


G

global
Keyword yN
Description: Use global to create global variables
inside a function.
See CircuitPython documentation for more details.

grid(xscl,yscl,"style")
Module: ti_plotlib yN
Syntax: plt.grid(xscl,yscl,"style") [Fns...]>Modul
or »
Description: Displays a grid using specified scale for x 5:ti_plotlib...>
and y axes. Note: All plotting takes place when Setup
plt.show_plot() is executed. 3:grid()
Setting grid color is the optional argument of (r,g,b)
using values 0-255 with default value of gray import
(192,192,192). commands can
Default value for xscl or yscl = 1.0. be found in
y N or
"style" = "dot" (default), "dash", "solid" or "point" in the
ti_plotlib Setup
Example: menu.
See sample programs: COLORLIN or GRAPH.

Reference Guide for TI-Python Experience 89


grid(xscl,yscl,"style",(r,g,b))
Module: ti_plotlib yN
Syntax: plt.grid(xscl,yscl,"style",(r,g,b)) [Fns...]>Modul
or »
Description: Displays a grid using specified scale for x 5:ti_plotlib...>
and y axes. Note: All plotting takes place when Setup
plt.show_plot() is executed. 3:grid()
Setting grid color is the optional argument of (r,g,b)
using values 0-255 with default value of gray import
(192,192,192). commands can
Default value for xscl or yscl = 1.0. be found in y
N or in
"style" = "dot" (default), "dash", "solid" or "point" . the
ti_plotlib Setup
If the xscl or yscl values are less than 1/50th of the menu.
difference between xmax-xmin or ymax-ymin, then an
exception of 'Invalid grid scale value.'
Example:
See sample program: GRAPH.

90 Reference Guide for TI-Python Experience


H

hex(integer)
Module: Built-in yN
Syntax: hex(integer)
Description: Displays hexadecimal format of the
integer argument. See Python documentation for
more details.
Example:
>>> hex(16)
'0x10'
>>> hex(16**2)
'0x100'

Reference Guide for TI-Python Experience 91


I

"if :"
See if..elif..else.. for details. yN

[Fns…] > Ctl


1:if..
2:if..else..
3:if..elif..else
9:elif :
0:else:

92 Reference Guide for TI-Python Experience


if..elif..else..
Keyword yN
Syntax: ••Gray indent identifiers automatically
provided in the Python App for ease of use.
[Fns…] > Ctl
if :
1:if..
••
2:if..else..
elif :
3:if..elif..else
••
9:elif :
else:
0:else:
Description: if..elif..else is a conditional statement.
The Editor provides automatic indents as gray dots to
assist your correct programming indents.
Example: Create and run this program, say S01, from
the Editor
def f(a):
••if a>0:
••••print(a)
••elif a==0:
••••print(“zero”)
••else:
••••a=-a
••••print(a)

Shell interaction
>>> # Shell Reinitialized
>>> # Running S01
>>>from S01 import * #automatically pastes
>>>f(5)
5
>>>f(0)
zero
>>>f(-5)
5

Reference Guide for TI-Python Experience 93


if..else..
Keyword yN
See if..elif..else.. for details.
[Fns…] > Ctl
1:if..
2:if..else..
3:if..elif..else
9:elif :
0:else:

.imag
Module: Built-in yN
Syntax:var.imag
Description: Returns the imaginary part of a specified
variable of complex number type.
Example:
>>>a=complex(4,5)
>>>a.real
4
>>>a.imag
5

import math
Keyword
Syntax: import math yN
Description: The math module is accessed using this
command. This instruction imports the public
attributes of the "math" module within its own
namespace.

94 Reference Guide for TI-Python Experience


import random
Keyword
Syntax: import random yN
Description: The random module is accessed using
this command. This instruction imports the public
attributes of the "random" module within its own
namespace.

import ti_hub
Keyword yN
Syntax: import ti_hub
Description: The ti_hub module is accessed using this
command. This instruction imports the public
attributes of the ti_hub module wihin its own
namespace.
For individual input and output devices, use the
dynamic module functionality by selecting the device
from [Fns…]>Modul>ti_hub>Import menu when in
the Editor.
See:[Fns…] > Modul: ti_hub module.

import time
Keyword yN
Syntax: import time
Description: The time module is accessed using this
command. This instruction imports the public
attributes of the time module within its own name-
space.
See:[Fns…] > Modul: time and ti_system modules.

Reference Guide for TI-Python Experience 95


import ti_plotlib as plt
Keyword yN
Syntax: import ti_plotlib as plt » Modul
5:ti_plotlib...
Description: The ti_plotlib module is accessed using 1:import ti_plotlib
this command. This instruction imports the public as plt
attributes of the ti_plotlib module wihin its own
namespace. Attributes of the ti_plotlib module must [Fns…]>Modul
be entered as plt.attribute. 5:ti_plotlib...
1:import ti_plotlib
Example: as plt
See sample program: COLORLIN.

import ti_rover as rv
Keyword yN
Syntax: import ti_rover as rv » Modul
7:ti_rover...
Description: The ti_rover module is accessed using 1:import ti_rover
this command. This instruction imports the public as rv
attributes of the ti_rover module within its own
name-space. Attributes of the ti_rover module must [Fns…]>Modul
be entered as rv.attribute. 7:ti_rover...
1:import ti_rover
Example: as rv
See sample program: ROVER.

96 Reference Guide for TI-Python Experience


import ti_system
Keyword yN
Syntax: import ti_system
Description: The ti_system module is accessed using
this command. This instruction imports the public
attributes of the ti_system module within its own
name-space.
Example:
See sample program: REGEQ1.

in
Keyword yN
Description: Use in to check if a value is in a
sequence or to iterate a sequence in a for loop.

.index(x)
Module: Built-in yN
Syntax:var.index(x)
Description: Returns the index or position of an
element of a list. See Python documentation for
more details.
Example:
>>> a=[12,35,45]
>>> print(a.index(12))
0
>>> print(a.index(35))
1
>>> print(a.index(45))
2

input()
Module : Built-in yN
Syntax: input()

Reference Guide for TI-Python Experience 97


input()
Description: Prompt for input [Fns…] I/O
2:input()

Example:
>>>input("Name? ")
Name? Me
‘Me’

Alternate Example:
Create Program A
len=float(input("len: "))
print(len)

Run Program A
>>> # Shell Reinitialized
>>> # Running A
>>>from A import *
len: 15 (enter 15)
15.0 (output float 15.0)

98 Reference Guide for TI-Python Experience


.insert(index,x)
Module : Built-in y 9 List
8:.insert(index,x)
Syntax: listname.insert(index,x)
Description: The method insert() inserts an item x
after index within a sequence. yN
Example:
>>>listA = [2,4,6,8] [Fns…] > List
>>>listA.insert(3,15) 8:.insert(index,x)
>>>print(listA)
[2,4,6,15,8]

int()
Module : Built-in yN
Syntax: int(x)
Description: Returns x as an integer object. [Fns…] > Type
1:int()
Example:
>>>int(34.67)
34
>>>int(1234.56)
1234

is
Keyword yN
Description: Use is to test if two objects are the same
object.

Reference Guide for TI-Python Experience 99


L

labels("xlabel","ylabel",x,y)
Module: ti_plotlib yN
Syntax: plt.labels("xlabel","ylabel",x,y) [Fns...]>Modul
or »
Description: Displays "xlabel" and "ylabel" labels on the 5:ti_plotlib...>
plot axes at row positions x and y. Adjust as needed for Setup
your plot display. 7:labels()
"xlabel" is positioned on specified row x (default row
12) and is right justified. import
"ylabel" is positioned on specified row y (default row 2) commands can
and is left justified. be found in
y N or
Note: plt.labels("|","",12,2) will paste with x and y row in the
defaults, 12,2 , which then can be modified for your ti_plotlib Setup
program. menu.
Example:
See sample program: GRAPH.

lambda
Keyword yN
Syntax: lambda arguments : expression
Description: Use lambda to define an anonymous
function. See Python documentation for details.

100 Reference Guide for TI-Python Experience


len()
Module: Built-in y 9 (above
…) List
Syntax: len(sequence) 3:len()
Description: Returns the number of items in the
argument. The argument may be a sequence or a
collection. yN
See Python documentation for more details.
Example: [Fns…] > List
3:len()
>>>mylist=[2,4,6,8,10]
>>>len(mylist)
5

line(x1,y1,x2,y2,"mode")
Module: ti_plotlib yN
Syntax: plt.line(x1,y1,x2,y2,"mode") [Fns...]>Modul or
»
Description: Displays a line segment from (x1,y1) to 5:ti_plotlib...> Draw
(x2,y2) 7:line or vector
Size and style are set using pen() and color() before
line(). import commands
Arguments: can be found in
y N or in
x1,y1, x2,y2 are real floats. the
ti_plotlib Setup
"mode": When default "", no arrowhead draws. menu.
When "arrow" a vector arrowhead at (x2,y2) draws.
Example:
See sample program: COLORLIN.

Reference Guide for TI-Python Experience 101


lin_reg(xlist,ylist,"disp",row)
Module: ti_plotlib yN
Syntax: plt.lin_reg(xlist,ylist,"disp",row) [Fns...]>Modul
or »
Description: Calculates and draws the linear regression 5:ti_plotlib...>
model, ax+b, of xlist,ylist. This method must follow the Draw
scatter method. Default display of equation is "center" 8:lin_reg()
at row 11.
Argument: import
"disp" "left"
commands can
be found in y
"center" N or in the
"right" ti_plotlib Setup
row 1 - 12 menu.

plt.a (slope) and plt.b (intercept) are stored when lin_


reg executes.
Example:
See sample program: LINREGR.

102 Reference Guide for TI-Python Experience


list(sequence)
Module: Built-in y 9 (above
…) List
Syntax: list(sequence) 2:list(sequence)
Description: Mutable sequence of items of the save
type.
yN
list()" converts its argument into the "list" type. Like
many other sequences, the elements of a list do not
need to be of the same type.
[Fns…] > List
Example: 2:list(sequence)
>>>mylist=[2,4,6,8]
>>>print(mylist)
[2,4,6,8]

Example:
>>>mylist=[2,4,6,8]
>>>print(mylist)
[2,4,6,8]
>>> list({1,2,"c", 7})
[7, 1, 2, 'c']
>>> list("foobar")
['f', 'o', 'o', 'b', 'a', 'r']

Reference Guide for TI-Python Experience 103


log(x,base)
Module: math y « for log
(x,10)
Syntax: log(x,base)
Description: log(x) with no base returns the natural
logarithm x. y µ for log
(x) (natural log)
Example:
>>>from math import *
>>>log(e) » Modul
1.0
>>>log(100,10)
1:math…
2.0 6:log(x,base)
>>>log(32,2)
5.0
yN
[Fns…] > Modul
1:math…
6:log(x,base)

import
commands can
be found in
yN

104 Reference Guide for TI-Python Experience


M

math.function
Module: math yN
Syntax: math.function
Description: Use after import math command to use a
function in the math module.
Example:
>>>import math
>>>math.cos(0)
1.0

max()
Module: Built-in y 9 (above
…) List
Syntax: max(sequence) 4:max()
Description: Returns the maximum value in the
sequence. See Python documentation for more
information on max(). yN
Example:
>>>listA=[15,2,30,12,8] [Fns…] > List
>>>max(listA) 4:max()
30

min()
Module: Built-in y 9 (above
…) List
Syntax: min(sequence) 5:min()
Description: Returns the minimum value in the
sequence. See Python documentation for more
information on min(). yN
Example:
>>>listA=[15,2,30,12,8] [Fns…] > List
>>>min(listA) 5:min()
2

Reference Guide for TI-Python Experience 105


monotonic() elapsed time
Module: time yN
Syntax: monotonic() elapsed time
[Fns…]>Modul
Description: Returns a value of time from the point of or »
execution. Use the return value to compare against other 3:time
values from monotonic(). 3:momotonic()
Example:
Sample program: import
commands
from time import * can be found
a=monotonic() in y N
sleep(15) or in the time
b=monotonic()
print(b-a) Modul menu.

Run the program EXAMPLE until execution stops.


>>>15.0

106 Reference Guide for TI-Python Experience


N

None
Keyword yN
Description: None represents the absence of a value.
Example: [a A #]
>>> def f(x):
… x



>>> print(f(2))
None

nonlocal
Keyword yN
Syntax: nonlocal
Description: Use nonlocal to declare a variable is not
local. See Python documentation for more details.

not
Keyword y : Ops
0:not
Syntax: not x
Description: Evaluates to True if x is False and False
otherwise. Pastes with space before and after the [Fns…] > Ops
keyword not. Edit as needed. 0:not
Example:
>>> not 2<5 #edit the space before not yN
False
>>>3<8 and not 2<5
False
[a A #]

Reference Guide for TI-Python Experience 107


O

oct(integer)
Module: Built-in yN
Syntax: oct(integer)
Description: Returns the octal representation of the
integer. See Python documentation for more details.
Example:
>>> oct(8)
'0o10'
>>> oct(64)
'0o100'

or
Keyword y : Ops 9:or
Syntax: x or y [Fns…] > Ops 9:or
Description: May return True or False. Returns x if x
evaluates as True and y otherwise. Pastes with space
before and after or. Edit as needed. yN

Example:
>>>2<5 or 5<10 [a A #]
True
>>>2<5 or 15<10
True
>>>12<5 or 15<10
False
>>> 3 or {}
3
>>> [] or {2}
{2}

108 Reference Guide for TI-Python Experience


ord("character")
Module: Built-in yN
Syntax: ord("character")
Description: Returns the unicode value of the
character. See Python documentation for more
details.
Example:
>>> ord("#")
35
>>> ord("/")
47

Reference Guide for TI-Python Experience 109


P

pass
Keyword yN
Description: Use pass in an empty function or class
definition as a placeholder for future code as you
build out your program. Empty definitions will not
cause an error when program is executed.

pen("size","style")
Module: ti_plotlib yN
Syntax: plt.pen("size","style") [Fns...]>Modul or
»
Description: Sets the appearance of all following 5:ti_plotlib...> Draw
lines until the next pen() is executed. 9:pen()
Argument:
Default pen() is "thin" and "solid." import commands
can be found in
"size" "thin" y N or in
"medium" the
"thick"
ti_plotlib Setup
menu.
"style" "solid"
"dot"
"dash"

Example:
See sample programs: COLORLIN or GRAPH.

110 Reference Guide for TI-Python Experience


pi
Module: math y B (above
˜)
Syntax: math.pi or pi if math module imported.
Description: Constant pi displays as shown below.
[Fns…] > Modul
Example: 1:math… >
>>>from math import * Const 2:pi
>>>pi
3.141592653589793

Alternate Example:
>>>import math
>>>math.pi
3.141592653589793

Reference Guide for TI-Python Experience 111


plot(xlist,ylist,"mark")
Module: ti_plotlib yN
Syntax: plt.plot(xlist,ylist,"mark") [Fns...]>Modul
or »
Description: A line plot displays using ordered pairs from 5:ti_plotlib...>
specified xlist and ylist. The line style and size are set Draw
using plt.pen(). 5:Connected
xlist and ylist must be real floats and lists must bee the Plot with Lists
same dimension.
Argument: import
commands can
"mark" is the mark character as follows: be found in
y N or
o filled dot (default) in the
+ cross ti_plotlib Setup
menu.
x x
. pixel

Example:
See sample program: LINREGR.

112 Reference Guide for TI-Python Experience


plot(x,y,"mark")
Module: ti_plotlib yN
Syntax: plt.plot(x,y,"mark") [Fns...]>Modul or
»
Description: A point plot, (x,y) displays using 5:ti_plotlib...> Draw
specified x and y. 6:plot a Point
xlist and ylist must be real floats and lists must be
the same dimension. import commands
Argument: can be found in
y N or in
"mark" is the mark character as follows: the
ti_plotlib Setup
o filled dot (default) menu.
+ cross
x x
. pixel

Example:
See sample program: LINREGR.

Reference Guide for TI-Python Experience 113


pow(x,y)
Module: math » Modul
1:math
Syntax: pow(x,y) 5:pow(x,y)
Description: Returns x raised to the power y. Converts
both x and y to float. See Python documentation for
more information. yN
Use the built-in pow(x,y) function or ** for computing
exact integer powers.
[Fns…] > Modul
Example: 1:math
5:pow(x,y)
>>>from math import *
>>>pow(2,3)
>>>8.0
import
Example using: Built-in: commands can
[Tools] > 6:New Shell be found in
yN
>>>pow(2,3)
8
>>>2**3
8

print()
Module: Built-in yN
Syntax: print(argument)
Description: Displays argument as string. [Fns…] > I/O
1:print()
Example:
>>>x=57.4
>>>print(“my number is =”, x)
my number is= 57.4

114 Reference Guide for TI-Python Experience


R

radians()) degree 8radians


Module: math ˜ Trig
1:radians()
Syntax: radians(x)
Description: Converts angle x in degrees to radians.
yN
Example:
>>>from math import *
>>>radians(180.0) [Fns…] > Modul
3.141592653589793
>>>radians(90.0)
1:math… > Trig
1.570796326794897 1:radians()

raise
Keyword yN
Syntax: raise exception
Description: Use raise to raise a specified exception
and stop your program.

Reference Guide for TI-Python Experience 115


randint(min,max)
Module: random » Modul
2:random
Syntax: randint(min,max) 4:randint
Description: Returns a random integer between min (min,max)
and max.
Example: [Fns…] > Modul
>>>from random import * 2:random…
>>>randint(10,20) 4:randint
>>>15 (min,max)
Alternate Example:
>>>import random yN
>>>random.randint(200,450)
306

Results will vary given a random output. import


commands can
be found in
yN

116 Reference Guide for TI-Python Experience


random()
Module: random » Modul
2:random…
Syntax: random() Random
Description: Returns a floating point number from 0 to 2:random()
1.0. This function takes no arguments.
Example: [Fns…] > Modul
>>>from random import * 2:random…
>>>random() Random
0.5381466990230621 2:random()
Alternate Example:
>>>import random yN
>>>random.random()
0.2695098437037318

Results will vary given a random output. import


commands can
be found in y
N

random.function
Module: random yN
Syntax: random.function
Description: Use after import random to access a
function in the random module.
Example:
>>>import random
>>>random.randint(1,15)
2

Results will vary given a random output.

Reference Guide for TI-Python Experience 117


randrange(start,stop,step)
Module: random » Modul
2:random…
Syntax: randrange(start,stop,step) Random
Description: Returns a random number from start to 6:randrange
stop by step. (start,stop,step)

Example:
>>>from random import * » Modul
>>>randrange(10,50,2) 2:random…
12 Random
6:randrange
Alternate Example: (start,stop,step)
>>>import random
>>>random.randrange(10,50,2)
48
yN
Results will vary given a random output.

import commands
can be found in
yN

range(start,stop,step)
Module: Built in yN
Syntax: range(start,stop,step)
Description: Use range function to return a sequence
of numbers. All arguments are optional. Start default
is 0, step default is 1 and sequence ends at stop.
Example:
>>> x = range(2,10,3)
>>> for i in x
… print(i)


2
5
8

118 Reference Guide for TI-Python Experience


.real
Module: Built-in yN
Syntax:var.real
Description: Returns the real part of a specified
variable of complex number type.
Example:
>>>a=complex(4,5)
>>>a.real
4
>>>a.imag
5

Reference Guide for TI-Python Experience 119


var=recall_list("name") 1-6
Module: ti_system yN
Syntax:var=recall_list("name") 1-6 yK
ti_system
Description: Recall a predefined OS list. List length must 4:var=recall_
be less than or equal to 100. list()
Argument: "name"
For OS L1-L6 [Fns…]>Modul
or »
1-6 4:ti_system
4:var=recall_
"1" - "6"
list()
'1' - '6'

For OS custom list "name" import


commands
----- Max 5 characters, numbers or letters, starting with can be found
letters, and letters must be uppercase. in y
N or in
Examples: the
"ABCDE" ti_system
Modul menu.
"R12"
"L1" will be custom L1 and not OS L1

Reminder: Python is double precision. Python supports


more digits than in the OS.
Example:
Sample program:
Create a list in the OS.
LIST={1,2,3}
Run Python App.
Create a new program AA.
import ti_system as *
xlist=recall_list("LIST")
print xlist
Run program AA.
Shell displays output.
[1.0, 2.0, 3.0]

120 Reference Guide for TI-Python Experience


var=recall_RegEQ()
Module: ti_system yN
Syntax:var=recall_RegEQ() yK
ti_system
Description: Recall the RegEQ variable from the CE OS. 4:var=recall_
The regression equation must be computed in the OS REGEQ()
prior to recalling RegEQ in the Python App.
Example: [Fns…]>Modul
See sample program: REGEQ1. or »
4:ti_system
4:var=recall_
REGEQ()

import
commands can
be found in y
N or in
the
ti_system
Modul menu.

.remove(x)
Module: Built-in y9
List
Syntax: listname.remove(item) 7:.remove(x)
Description: The method remove() removes the first
instance of item from a sequence.
yN
Example:
>>>listA = [2,4,6,8,6]
>>>listA.remove(6) [Fns…] > List
>>>print(listA)
[2,4,8,6]
7:.remove(x)

Reference Guide for TI-Python Experience 121


return
Module: Built-in yN
Syntax: return expression
Description: A return statement defines the value [Fns…] > Func
produced by a function. Python functions return None 1:def function():
by default. See also: def function():
Example:
[Fns…] > Func
>>> def f(a,b): 2:return
… return a*b



>>> f(2,3)
6

.reverse()
Module: Built-in yN
Syntax: listname.reverse()
Description: Reverses the order of items in a sequence.
Example:
>>>list1=[15,-32,4]
>>>list1.reverse()
>>>print(list1)
[4,-32,15]

round()
Module: Built in yN
Syntax: round(number, digits)
Description: Use round function to return a floating
point number rounded to the specified digits. Default
digit is 0 and returns the nearest integer.
Example:
>>>round(23.12456)
23
>>>round(23.12456,3)
23.125

122 Reference Guide for TI-Python Experience


S

scatter(xlist,ylist,"mark")
Module: ti_plotlib yN
Syntax: plt.scatter(xlist,ylist,"mark") [Fns...]>Modul
or »
Description: A sequence of ordered pair from (xlist,ylist) 5:ti_plotlib...>
will be plotted with mark style specified. The line style Draw
and size are set using plt.pen(). 4:scatter()
xlist and ylist must be real floats and lists must bee the
same dimension. import
Argument: commands can
be found in
"mark" is the mark character as follows: yN or
in the
o filled dot (default) ti_plotlib Setup
+ cross menu.
x x
. pixel

Example:
See sample program: LINREGR.

Reference Guide for TI-Python Experience 123


seed()
Module: random » Modul
2:random…
Syntax: seed() or seed(x) where x is integer Random
Description: Initialize random number generator. 7:seed()

Example: [Fns…] >


Modul
>>>from random import * 2:random…
>>>seed(12) Random
>>>random() 7:seed()
0.9079708720366826
>>>seed(10)
>>>random()
0.9063990882481896 yN
>>>seed(12)
>>>random()
0.9079708720366826
import
Results will vary given a random output. commands
can be found
in
yN

set(sequence)
Module: Built-in yN
Syntax: set(sequence)
Description: Returns a sequence as a set. See Python
documentation for more details.
Example:
>>> print(set("84CE")
{'E', '8', '4', 'C'}

124 Reference Guide for TI-Python Experience


show_plot() display > [clear]
Module: ti_plotlib yN
Syntax: plt.show_plot() display > [clear] [Fns...]>Modul
or »
Description: Executes the display of the plot as set up in 5:ti_plotlib...>
the program. Setup
show_plot() must be placed after all plotting setup 9:show_plot
objects. The program order of plotting objects are [Fns…]>Modul
suggested by the Setup menu ordering. or [math]
For plotting template help, from File Manager, select 5:ti_plotlib… >
[New] ([zoom]) and then [Types] ([zoom]) to select the Draw
"Plotting (x,y) & Text" program type. 9:show_plot()

After running the program, the plotting display is


cleared by pressing [clear] to return to the Shell prompt. import
commands can
Example: be found in y
N or in
See sample programs: COLORLIN or GRAPH. the
ti_plotlib Setup
menu.

Reference Guide for TI-Python Experience 125


sin()
Module: math ˜ 3:sin()
Syntax: sin()
Description: Returns sine of x. Argument angle is in yN
radians.
Example:
[Fns…] > Modul
>>>from math import * 1:math… > Trig
>>>sin(pi/2) 3:sin()
1.0

import
commands can
be found in
yN

sleep(seconds)
Module: ti_system; time yN
Syntax: sleep(seconds)
yK
Description: Sleep for a given number of seconds. ti_system
Seconds argument is a float. A:sleep()
Example: [Fns…]>Modul or
Sample program: »
4:ti_system
from time import * A:sleep()
a=monotonic()
sleep(15) [Fns…]>Modul or
b=monotonic() »
print(b-a) 3:time
Run the program TIME 2:sleep()
>>>15.0

import commands
can be found in
y N or in
the
ti_system Modul
menu.

126 Reference Guide for TI-Python Experience


.sort()
Module: Built-in y9
(above …
Syntax: listname.sort() List A:.sort()
Description: The method sorts a list in place. See yN
Python documentation for more details.
[Fns…] >
Example: List
>>>listA=[4,3,6,2,7,4,8,9,3,5,4,6] A:sort()
>>>listA.sort()
>>>print(listA) #listA updated to a sorted list
[2,3,3,4,4,4,5,6,6,7,8,9]

sorted()
Module: Built-in y 9 (above
…) List
Syntax: sorted(sequence) 0:sorted()
Description: Returns a sorted list from sequence.
Example: yN
>>>listA=[4,3,6,2,7,4,8,9,3,5,4,6]
>>>sorted(listA)
[2,3,3,4,4,4,5,6,6,7,8,9]
>>>print(listA) #listA did not change
[Fns…] > List
[4,3,6,2,7,4,8,9,3,5,4,6] 0:sorted()

Reference Guide for TI-Python Experience 127


.split(x)
Module: Built-in yN
Syntax:var.split(x)
Description: Method returns a list by specified
separator. See Python documentation for more
details.
Example:
>>> a="red,blue,green"
>>> a.split(",")
['red', 'blue', 'green']

sqrt()
Module: math » Modul
1:math
Syntax: sqrt(x) 3:sqrt()
Description: Returns square root of x.
Example: yN
>>>from math import *
>>>sqrt(25)
5.0
[Fns…] >
Modul
1:math
3:sqrt()

import
commands
can be found
in
y N.

128 Reference Guide for TI-Python Experience


store_list("name",var) 1-6
Module: ti_system yN
Syntax: store_list("name",var) 1-6 yK
ti_system
Description: Stores a list from the execution of a Python 3:var=store_list
script to an OS list variable "name" where var is a ()
defined Python list. List length must be less than or
equal to 100.
[Fns…]>Modul
Argument: "name" or »
For OS L1-L6 4:ti_system
3:var=store_list
1-6 ()
"1" - "6"
'1' - '6' import
commands can
For OS custom list "name" be found in y
N or in the
----- Max 5 characters, numbers or letters, starting with ti_system
letters, and letters must be uppercase. Modul menu.
Examples:
"ABCDE"
"R12"
"L1" will be custom L1 and not OS L1

Reminder: Python is double precision which is more


digits than supported in the OS.
Example:
>>>a=[1,2,3]
>>>store_list("1",a)
>>>
Quit the Pyton App and press yd (above [ 1 ]) and [enter] on the
Home Screen to see list d as {1 2 3}.

Reference Guide for TI-Python Experience 129


str()
Module: Built-in yN
Syntax: str(argument)
Description: Converts "argument" to a string. [Fns…]
> Type
Example: 3 :str()
>>>x=2+3
>>>str(x)
'5'

sum()
Module: Built-in y 9 (above
…) List
Syntax: sum(sequence) 9:sum()
Description: Returns the sum of the items in a
sequence. yN
Example:
>>>listA=[2,4,6,8,10] [Fns…] > List
>>>sum(listA) 9:sum()
30

130 Reference Guide for TI-Python Experience


T

tan()
Module: math ˜ 5:tan()
Syntax: tan(x)
Description: Returns tangent of x. Angle argument is in [Fns…] > Modul
radians. 1:math… > Trig
5:tan()
Example:
>>>from math import *
>>>tan(pi/4) yN
1.0

import
commands can
be found in
yN

text_at(row,"text","align")
Module: ti_plotlib yN
Syntax: plt.text_at(row,"text","align") [Fns...]>Modul or
»
Description: Display "text" in plotting area at 5:ti_plotlib...>
specified "align". Draw
row integer 1
0:text_at()
through 12
"text" string is import commands
clipped if too can be found in
long y N or in
"align" "left" (default) the
"center"
ti_plotlib Setup
menu.
"right"
optional 1 clears line
prior to text
(default)
0 line doe not
clear

Example:
See sample program: DASH1.

Reference Guide for TI-Python Experience 131


time.function
Module: Built-in yN
Syntax: time.function
Description: Use after import time to access a
function in the time module.
Example:
See:[Fns…]>Modul: time and ti_system modules.

title("title")
Module: ti_plotlib yN
Syntax: plt.title("title") [Fns...]>Modul or
»
Description: "title" displays centered on top line of 5:ti_plotlib...>
window. "title is clipped if too long. Setup
Example: 8:title()

See sample program: COLORLIN.


import commands
can be found in
y N or in
the
ti_plotlib Setup
menu.

132 Reference Guide for TI-Python Experience


ti_hub.function
Module: ti_hub yN
Syntax: ti_hub.function
Description: Use after import ti_hub to access a
function in the ti_hub module.
Example:
See:[Fns…]>Modul: ti_hub module.

ti_system.function
Module: ti_system yN
Syntax: ti_system.function
Description: Use after import ti_system to access a
function in the ti_system module.
Example:
>>> # Shell Reinitialized
>>>import ti_system
>>>ti_system.disp_at(6,8,"texte")
texte>>>|
#will appear at row 6, col 8 with Shell
prompt as shown.

Reference Guide for TI-Python Experience 133


True
Keyword y:
(above »)
Description: Returns True when statement executed
is True. "True" represents the true value of objects of
type bool.
yN
Example:
>>>64>=32
True [Fns…] > Ops
A:True

[a A #]

trunc()
Module: math » Modul
1:math…
Syntax: trunc(x) 0:trunc()
Description: Returns the real value x truncated to an
integer.
yN
Example:
>>>from math import *
>>>trunc(435.867) [Fns…] > Modul
435
1:math…
0:trunc()

import
commands can
be found in
yN

try:
Keyword yN
Description: Use try code block to test the code block
for errors. Also used with except and finally. See
Python documentation for more details.

134 Reference Guide for TI-Python Experience


tuple(sequence)
Module: Built-in yN
Syntax: tuple(sequence)
Description: Converts sequence into a tuple. See
Python documentation for more details.
Example:
>>>a=[10,20,30]
>>>tuple(a)
(10,20,30)

type()
Module: Built-in yN
Syntax: type(object) [Fns…]>Type>6:type
()
Description: Returns the type of the object.
Example:
>>>a=1.25
>>>print(type(a))
<class 'float'>
>>>b=100
>>>print(type(b))
<class 'int'>
>>>a=10+2j
>>>print(type(c))
<class 'complex'>

Reference Guide for TI-Python Experience 135


U

uniform(min,max)
Module: random » Modul
2:random…
Syntax: uniform(min,max) Random
Description: Returns a random number x (float) such 3:uniform
that min <= x <= max. (min,max)

Example:
>>>from random import * yN
>>>uniform(0,1)
0.476118
>>>uniform(10,20)
16.2787 [Fns…] > Modul
2:random…
Results will vary given a random output. Random
3:uniform
(min,max)

import
commands can
be found in
yN

136 Reference Guide for TI-Python Experience


W

wait_key()
Module: ti_system yN
Syntax: wait_key()
Description: Returns a combined keycode
representing the key pressed, merged with y
and/or ƒ. The method waits for a key to be
pressed before returning to the program.
Example:
See: [Fns…]>Modul: time and ti_system modules.
See: Keypad mapping for wait_key()

while condition:
Keyword [Fns…] Ctl
8:while condition:
Syntax: while condition:
Description: Executes the statements in the following
code block until "condition" evaluates to False. yN
Example:
>>> x=5
>>> while x<8:
… x=x+1
… print(x)


6
7
8

Reference Guide for TI-Python Experience 137


window(xmin,xmax,ymin,ymax)
Module: ti_plotlib yN
Syntax: plt.window(xmin,xmax,ymin,ymax) [Fns...]>Modul
or »
Description: Defines the plotting window by mapping the 5:ti_plotlib...>
the specified horizontal interval (xmin, xmax) and vertical Setup
interval (ymin, ymax) to the allotted plotting area 4:window()
(pixels).
This method must be executed before any other ti_plotlib import
module commands are executed. commands
The ti_plotlib Properties vars, xmin, xmax, ymin, ymax can be found
will be updated to the argument values. The default in y
values are (-10, 10, -6.56, 6.56). N or in
the
Example: ti_plotlib
Setup menu.
See sample program: GRAPH.

with
Keyword yN
Description: See Python documentation for more
details.

138 Reference Guide for TI-Python Experience


X

xmax default 10.00


Module: ti_plotlib yN
Syntax: plt.xmax default 10.00 [Fns...]>Modul or
»
Description: Specified variable for window 5:ti_plotlib...>
arguments defined as plt.xmax. Properties
Default values: 2:xmax

xmin default -10.00


import commands
xmax default 10.00 can be found in
ymin default -6.56 y N or in
the
ymax default 6.56 ti_plotlib Setup
menu.
Example:
See sample program: GRAPH.

Reference Guide for TI-Python Experience 139


xmin default -10.00
Module: ti_plotlib yN
Syntax: plt.xmin default -10.00 [Fns...]>Modul or
»
Description: Specified variable for window 5:ti_plotlib...>
arguments defined as plt.xmin. Properties
Default values: 1:xmin

xmin default -10.00


import commands
xmax default 10.00 can be found in
ymin default -6.56 y N or in
the
ymax default 6.56 ti_plotlib Setup
menu.
Example:
See sample program: GRAPH.

140 Reference Guide for TI-Python Experience


Y

yield
Keyword yN
Description: Use yield to end a function. Returns a
generator. See Python documentation for more
details.

ymax default 6.56


Module: ti_plotlib yN
Syntax: plt.ymax default 6.56 [Fns...]>Modul or
»
Description: Specified variable for window 5:ti_plotlib...>
arguments defined as plt.ymax. Properties
Default values: 4:ymax

xmin default -10.00


import commands
xmax default 10.00 can be found in
ymin default -6.56 y N or in
the
ymax default 6.56 ti_plotlib Setup
menu.
Example:
See sample program: GRAPH.

Reference Guide for TI-Python Experience 141


ymin default -6.56
Module: ti_plotlib yN
Syntax: plt.ymin default -6.56 [Fns...]>Modul or
»
Description: Specified variable for window 5:ti_plotlib...>
arguments defined as plt.ymin. Properties
Default values: 3:ymin

xmin default -10.00


import commands
xmax default 10.00 can be found in
ymin default -6.56 y N or in
the
ymax default 6.56 ti_plotlib Setup
menu.
Example:
See sample program: GRAPH.

142 Reference Guide for TI-Python Experience


Symbols

@
Operator ƒT
(above Â)
Description: Decorator – See general Python
documentation for details.
yN

<<
Operator yN
Syntax: x<<n
Description: Bitwise left shift by n bits.

>>
Operator yN
Syntax: x>>n
Description: Bitwise right shift by n bits.

|
Operator yN
Syntax: x|y
Description: Bitwise or.

&
Operator yN
Syntax: x&y
Description: Bitwise and.

Reference Guide for TI-Python Experience 143


^
Operator yN
Syntax: x^y
Description: Bitwise exclusive or.

~
Operator yN
Syntax: ~x
Description: Bitwise not; the bits of x inverted.

144 Reference Guide for TI-Python Experience


x<=y
Operator »
1:math > Ops
Syntax: x<=y 7:x<=y
Description: Comparison; x less than or equal to y.
Example: yN
>>>2<=5
True
>>>3<=0
False
[Fns…] > Ops
7:x<=y

[a A #]

x<y
Operator »
1:math > Ops
Syntax: x<y 6:x<y
Description: Comparison; x strictly less than y.
Example: yN
>>>6<10
True
>>>12<-15
False
[Fns…] > Ops
6:x<y

[a A #]

Reference Guide for TI-Python Experience 145


x>=y
Operator »
1:math > Ops
Syntax: x>=y 5:x>=y
Description: Comparison; x greater than or equal to y.
Example: yN
>>>35>=25
True
>>>14>=65
False
[Fns…] > Ops
5:x>=y

[a A #]

x>y
Operator »
1:math > Ops
Syntax: x>y 4:x>y
Description: Comparison; x strictly greater than y.
Example: yN
>>>35>25
True
>>>14>65
False
[Fns…] > Ops
4:x>y

[a A #]

146 Reference Guide for TI-Python Experience


x!=y
Operator »
1:math > Ops
Syntax: x!=y 3:x!=y
Description: Comparison; x not equal to y.
Example: yN
>>>35!=25
True
>>>14!=10+4
False
[Fns…] > Ops
3:x!=y

[a A #]

x==y
Operator »
1:math > Ops
Syntax: x==y 2:x==y
Description: Comparison; x is equal to y.
Example: yN
>>>75==25+50
True
>>>1/3==0.333333
False
[Fns…] > Ops
>>>1/3==0.3333333 #equal to stored Python value 2:x==y
True

[a A #]

Reference Guide for TI-Python Experience 147


x=y
Operator ¿
Syntax: x=y
Description:y is stored in variable x »
1:math > Ops
Example: 1:x=y
>>>A=5.0
>>>print(A)
5.0
>>>B=2**3 #Use [ ^ ] on keypad for **
yN
>>>print(B)
8
[Fns…] > Ops
1:x=y

[a A #]

\
Delimiter yN
Description: Backslash character.
[a A #]

\t
Delimiter yN
Description: Tab space between strings or characters.

\n
Delimiter yN
Description: New line to display string neatly on the
screen.

148 Reference Guide for TI-Python Experience


''
Delimiter yL
(above Ã)
Description: Two single quotes paste.
Example:
yN
>>>eval(‘a+10’)
17

[a A #]

""
Delimiter ƒW
(above Ã)
Description: Two double quotes paste.
Example:
yN
>>>print("Ok")

[a A #]

Reference Guide for TI-Python Experience 149


Appendix
Selected TI-Python Built-in, Keywords, and Module Content
Keypad mapping for wait_key()

150 Appendix
Selected TI-Python Built-in, Keywords, and Module Content
Built-ins

Built-ins Built-ins Built-ins


__name__ abs -- <function> BaseException -- <class
'BaseException'>
__build_class__ -- <function> all -- <function> ArithmeticError -- <class
'ArithmeticError'>
__import__ -- <function> any -- <function> AssertionError -- <class
'AssertionError'>
__repl_print__ -- <function> bin -- <function> AttributeError -- <class
'AttributeError'>
bool -- <class 'bool'> callable -- <function> EOFError -- <class 'EOFError'>
bytes -- <class 'bytes'> chr -- <function> Exception -- <class 'Exception'>
bytearray -- <class 'bytearray'> dir -- <function> GeneratorExit -- <class 'GeneratorExit'>
dict -- <class 'dict'> divmod -- <function> ImportError -- <class 'ImportError'>
enumerate -- <class 'enumerate'> eval -- <function> IndentationError -- <class
'IndentationError'>
filter -- <class 'filter'> exec -- <function> IndexError -- <class 'IndexError'>
float -- <class 'float'> getattr -- <function> KeyboardInterrupt -- <class
'KeyboardInterrupt'>
int -- <class 'int'> setattr -- <function> ReloadException -- <class

151
Built-ins Built-ins Built-ins
'ReloadException'>
list -- <class 'list'> globals -- <function> KeyError -- <class 'KeyError'>
map -- <class 'map'> hasattr -- <function> LookupError -- <class 'LookupError'>
memoryview -- <class 'memoryview'> hash -- <function> MemoryError -- <class 'MemoryError'>
object -- <class 'object'> help -- <function> NameError -- <class 'NameError'>
property -- <class 'property'> hex -- <function> NotImplementedError -- <class
'NotImplementedError'>
range -- <class 'range'> id -- <function> OSError -- <class 'OSError'>
set -- <class 'set'> input -- <function> OverflowError -- <class 'OverflowError'>
slice -- <class 'slice'> isinstance -- <function> RuntimeError -- <class 'RuntimeError'>
str -- <class 'str'> issubclass -- <function> StopIteration -- <class 'StopIteration'>
super -- <class 'super'> iter -- <function> SyntaxError -- <class 'SyntaxError'>
tuple -- <class 'tuple'> len -- <function> SystemExit -- <class 'SystemExit'>
type -- <class 'type'> locals -- <function> TypeError -- <class 'TypeError'>
zip -- <class 'zip'> max -- <function> UnicodeError -- <class 'UnicodeError'>
classmethod -- <class 'classmethod'> min -- <function> ValueError -- <class 'ValueError'>
staticmethod -- <class 'staticmethod'> next -- <function> ZeroDivisionError -- <class
'ZeroDivisionError'>

152
Built-ins Built-ins Built-ins
Ellipsis -- Ellipsis oct -- <function>
ord -- <function>
pow -- <function>
print -- <function>
repr -- <function>
round -- <function>
sorted -- <function>
sum -- <function>

153
keywords

keywords keywords keywords


False elif lambda
None else nonlocal
True except not
and finally or
as for pass
assert from raise
break global return
class if try
continue import while
def in with
del is yield

154
math

math math math


__name__ acos -- <function> frexp -- <function>
e -- 2.71828 asin -- <function> ldexp -- <function>
pi -- 3.14159 atan -- <function> modf -- <function>
sqrt -- <function> atan2 -- <function> isfinite -- <function>
pow -- <function> ceil -- <function> isinf -- <function>
exp -- <function> copysign -- <function> isnan -- <function>
log -- <function> fabs -- <function> trunc -- <function>
cos -- <function> floor -- <function> radians -- <function>
sin -- <function> fmod -- <function> degrees -- <function>
tan -- <function>

155
random

random random random


__name__ randint -- <function>
seed -- <function> choice -- <function>
getrandbits -- <function> random -- <function>
randrange -- <function> uniform -- <function>

156
time

time time time


__name__
monotonic
sleep
struc_time

157
ti_system

ti_system ti_system ti_system


__name__ recall_RegEQ disp_at
escape wait_key disp_clr
recall_list sleep disp_wait
store_list wait disp_cursor

158
ti_plotlib

ti_plotlib ti_plotlib ti_plotlib


__name__ a grid
lin_reg _pencolor -pensize
_strtest _write _sema
escape b -pensize
_except _xytest plot
text_alt window isnan
_clipseg _mark color

159
ti_plotlib ti_plotlib ti_plotlib
show-plot line title
tilocal monotonic _xdelta
pen _ntest _penstyle
sys ymin copysign
xmin tiplotlibException gr
ymax lables xmax
yscl cls sleep
_xy sqrt auto_window
_rdelta xscl
_ydelta axes
scatter

160
ti_hub

ti_hub ti_hub ti_hub


__name__ version last_error
connect begin sleep
disconnect start tihubException
set about wait
read isti get
calibrate what send
range who

161
ti_rover

ti_rover ti_rover ti_rover


__name__ color_blink _rv
motor_right motor_left stay

162
ti_rover ti_rover ti_rover
to_angle waypoint_heading waypoint_xythdrn
to_xy _motor ranger_measurement
red_measurment gyro_measutrment left
rvmovement wait_until_done pathlist_cmdnum
gray_measurment encoders_gyro_measurement waypoint_y
_excpt pathlist_distance waypoint-x
ti_hub position pathlist_y
waypoint_prev blue_measurement pathlist_x
pathlist_time forward right
waypoint_revs waypoint_distance color_rgb
to_polar grid_origin pathlist-revs
waypoint_eta resume color_measurement
color_off path_done tiroverException
grid_m_unit disconnect_rv forward_time
path_clear backward_time pathlist_heading
green_measurement zero-gyro
waypoint_time _rv_connected

163
ti_rover ti_rover ti_rover
motors stop
backward

164
Keypad mapping for wait_key()

165
General Information
Online Help
education.ti.com/eguide
Select your country for more product information.

Contact TI Support
education.ti.com/ti-cares
Select your country for technical and other support resources.

Service and Warranty Information


education.ti.com/warranty
Select your country for information about the length and terms of the warranty or
about product service.
Limited Warranty. This warranty does not affect your statutory rights.

166 General Information

You might also like