1 of 50

Python on Your Calculator?

OAME 2021

Chris Atkinson

chris@tkinson.net

@chrisatk

https://tkinson.net

2 of 50

Teacher Software - 90 day free trial

3 of 50

education.ti.com/Canada

4 of 50

Tom Steinke

Your Texas Instruments Educational Technology Consultant for Canada

  • tsteinke@ti.com
  • 613-601-6535
  • education.ti.com/Canada

5 of 50

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.

https://bfy.tw/PfPV

6 of 50

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.

7 of 50

10 minutes of code

Python edition

8 of 50

Input / Output

9 of 50

Creating Our Python Program

Home-> A Add Python -> 1 New

10 of 50

Creating Our Python Program

Give the program a name and select Random Simulations for the Type

11 of 50

Output Something

Menu -> 4 Built-ins -> 6 I/O -> print()

12 of 50

Output Something

print(“Hello #YOUR NAME#”)

13 of 50

Run the code

CTRL-R

14 of 50

New Python Shell

You should see a new python shell appear with the result of your running code

15 of 50

Output Something More Interesting

Menu -> 4 Built-ins -> 6 I/O -> input()

16 of 50

Output Something More Interesting

Collect the user’s name and welcome them

17 of 50

Run the code

CTRL-R

18 of 50

Randomness

19 of 50

Generate a Random Number

Menu -> 6 Random -> 4 randint(min,max)

20 of 50

Generate a Random Number

Assign your random number between 1 and 100 to a variable and print that number

21 of 50

Run the code

CTRL-R

22 of 50

Random Seed

Menu -> 6 Random -> 7 seed()

23 of 50

Random Seed

Use any random integer to seed your program

24 of 50

Run the code

CTRL-R

25 of 50

For Loops

26 of 50

Control Structures (Loops)

Menu -> 4 Built-ins -> 2 Control -> 4 for index in range(size)

27 of 50

Control Structures (Loops)

Print the first 10 values

28 of 50

Run the code

CTRL-R

29 of 50

Control Structures (Loops)

Modify your code to print 1 through 10

Modify your code again to print 10 through 1

30 of 50

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

31 of 50

Die Rolls

32 of 50

Roll Two Die

Menu -> 6 Random -> 4 randint(min,max)

Store results in variables die1, die2 and the sum in diesum

33 of 50

Roll Two Die

Menu -> 6 Random -> 4 randint(min,max)

Store results in variables die1, die2 and the sum in diesum

34 of 50

Quirks of Randomization

Repeated running of the code will yield the same results. You may need to randomize even your seed.

35 of 50

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

36 of 50

Type Casting

Basically...make user input a number

Menu -> 4 Built-ins -> 5 Type -> int()

37 of 50

Type Casting

Basically...make user input a number

38 of 50

Store Lists

39 of 50

Collect the Data

Start with an Empty List/Array

Menu -> 4 Built-ins -> 4 Lists -> 1 []

40 of 50

Collect the Data

Add to the list with each Die Roll

Menu -> 4 Built-ins -> 4 Lists -> 6 .append()

41 of 50

Share the Data

Store/Save/Share the data

Menu -> A More Modules -> 3 TI System -> 1 from ti_system import *

42 of 50

Share the Data

Store/Save/Share the data

Menu -> A More Modules -> 3 TI System -> 5 store_list(“name”,list)

43 of 50

Run the code

CTRL-R

44 of 50

Analyze the Results

Home -> ->Data and Statistics

45 of 50

Analyze the Results

Home -> ->Data and Statistics

46 of 50

Analyze the Results

Menu -> 1 Plot Type -> 3 Histogram

47 of 50

Next Steps

48 of 50

What Next?

Sound or light on die roll

Light sensor triggers die roll with Innovator Hub

49 of 50

stemsupports.ca

Coding and STEM Activities

50 of 50

Thank You

Chris Atkinson

chris@tkinson.net

@chrisatk

https://tkinson.net