Nspire Programming notes

To create a new program:

  • Create a new document
  • Insert a program with
    • Add Program Editor
    • New
  • Name your program (no spaces or symbols)
  • Choose Function or Program

Remember that you must  pick function or program correctly as you cannot change it later.

Useful functions

  • Disp — displays output — Menu,  6, 1
    ex: Disp “Hello, world!”       Hello, world!
          Disp x                                42
  • Mean — calculates the mean of a list of values
    ex: Mean({3,4,5})                     4
  • Abs — calculates absolute value of a number or members of a list
    ex: abs({-3,4,-5})                   {3,4,5}
           |{-3,4,-5}|                        {3,4,5}
  • String — converts a number to a string to allow concatenation
    ex: String(42)              42
    Disp “It took ” & string(guesses) & ” tries.”

Variables

  • Variables must be declared before use
  • Variables can be global or local, but we will only use local
  • Local variables exist only inside your program
  • Don’t confuse the assignment operator, := , with the comparison operator, =

Parameters/Arguments

  • Your program may accept parameters
  • Parameters can be
    • Numbers
    • Lists
    • Text
  • If the parameter is the wrong type (or missing),
    your program won’t execute.

Lists

  • Lists are created using curly braces {}
  • Lists can contain other objects like text or numbers
  • The calculator has a number of functions like Mean, Median, etc. that operate on lists
  • To access a specific member of a list, use listname[position]
    ex: x := {5,6,7,8}                                       {5,6,7,8}
    x[2]                                                          6

Leave a Reply

Your email address will not be published. Required fields are marked *