Python on Your Calculator?
OAME 2021
Chris Atkinson
chris@tkinson.net
@chrisatk
https://tkinson.net
Teacher Software - 90 day free trial
education.ti.com/Canada
Tom Steinke
Your Texas Instruments Educational Technology Consultant for Canada
What is Python?
Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. ... Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse.
What is the TI Npsire CX II?
From the keyboard and computer-menu interface to the ability to save and share work with built-in apps, the TI-Nspire™ CX II models retain the features and functionality that make TI-Nspire™ CX graphing calculators ideal for math and science from middle grades through college.
10 minutes of code
Python edition
Input / Output
Creating Our Python Program
Home-> A Add Python -> 1 New
Creating Our Python Program
Give the program a name and select Random Simulations for the Type
Output Something
Menu -> 4 Built-ins -> 6 I/O -> print()
Output Something
print(“Hello #YOUR NAME#”)
Run the code
CTRL-R
New Python Shell
You should see a new python shell appear with the result of your running code
Output Something More Interesting
Menu -> 4 Built-ins -> 6 I/O -> input()
Output Something More Interesting
Collect the user’s name and welcome them
Run the code
CTRL-R
Randomness
Generate a Random Number
Menu -> 6 Random -> 4 randint(min,max)
Generate a Random Number
Assign your random number between 1 and 100 to a variable and print that number
Run the code
CTRL-R
Random Seed
Menu -> 6 Random -> 7 seed()
Random Seed
Use any random integer to seed your program
Run the code
CTRL-R
For Loops
Control Structures (Loops)
Menu -> 4 Built-ins -> 2 Control -> 4 for index in range(size)
Control Structures (Loops)
Print the first 10 values
Run the code
CTRL-R
Control Structures (Loops)
Modify your code to print 1 through 10
Modify your code again to print 10 through 1
Control Structures (Loops)
Modify your code to print 10 random numbers
Modify your code again to ask the user how many random numbers they want
Die Rolls
Roll Two Die
Menu -> 6 Random -> 4 randint(min,max)
Store results in variables die1, die2 and the sum in diesum
Roll Two Die
Menu -> 6 Random -> 4 randint(min,max)
Store results in variables die1, die2 and the sum in diesum
Quirks of Randomization
Repeated running of the code will yield the same results. You may need to randomize even your seed.
Repeated Rolls of a Die
Use what you learned about For Loops to roll the die 10 times
Use what you learned about User Input to roll the die x times
Type Casting
Basically...make user input a number
Menu -> 4 Built-ins -> 5 Type -> int()
Type Casting
Basically...make user input a number
Store Lists
Collect the Data
Start with an Empty List/Array
Menu -> 4 Built-ins -> 4 Lists -> 1 []
Collect the Data
Add to the list with each Die Roll
Menu -> 4 Built-ins -> 4 Lists -> 6 .append()
Share the Data
Store/Save/Share the data
Menu -> A More Modules -> 3 TI System -> 1 from ti_system import *
Share the Data
Store/Save/Share the data
Menu -> A More Modules -> 3 TI System -> 5 store_list(“name”,list)
Run the code
CTRL-R
Analyze the Results
Home -> ->Data and Statistics
Analyze the Results
Home -> ->Data and Statistics
Analyze the Results
Menu -> 1 Plot Type -> 3 Histogram
Next Steps
What Next?
Sound or light on die roll
Light sensor triggers die roll with Innovator Hub
stemsupports.ca
Coding and STEM Activities
Thank You
Chris Atkinson
chris@tkinson.net
@chrisatk
https://tkinson.net