It’s Yearbook Day!

Yearbooks are here and will be distributed later today.

Didn’t order one? It’s not too late! See the flyer below or click the link to sign up at Tree Ring and order yours today for delivery in 2-3 weeks straight to your home. Softcover books are $20 and hardcover are $6.95. Shipping is approximately $8.

You will have the option of creating 2 personalized pages using your own photos, but you may also opt to order a standard, non-customized book. You will need an Adobe Flash enabled browser to create custom pages.

Late Yearbook Flyer

Join Repl.it

You’ll need to join my repl.it classroom for the next few class sessions. You may use this tool the rest of your lives… It’s extremely handy and allows you to run code in most programming languages and even build web pages for testing!

To join, click me! If you already have an account, just sign in. If you don’t have an account, I STRONGLY suggest using Google log in and using your @dallasisd.org Gmail account. That way, you can’t forget your password! If you want to keep your account after you leave Dallas ISD, you can always add a username and password or change your email address later.

Day 3 Program

Today we wrote our Nspire version of a dice roll simulation. Here’s an example of the function that simulated 1 or more trials of 6 dice.

Define dice(trials)=
Func
 Local i,roll,counts,total_rolls
 total_rolls:=6*trials
 counts:={0,0,0,0,0,0}
 For i,1,total_rolls
 roll:=randInt(1,6)
 counts[roll]:=counts[roll]+1
 EndFor
 Return counts
 EndFunc

And here’s the program that ran multiple trials to determine the experimental probability of rollling 1,2,3,4,5,6 each the same number of times.

Define rollsim(trials,c)=
Prgm
 Local i,counter,roll
 counter:=0
 For i,1,trials
 roll:=dice(c)
 If roll={1,1,1,1,1,1}*c Then
 counter:=counter+1
 EndIf
 EndFor
 Disp "all the same: "&string(counter)
 Disp "EP:"&string(((counter)/(trials))*100.)&"%"
 Return ((counter)/(trials))*1.
EndPrgm

Day 2 Program — Guess!

Here’s at least one way to make the program from class. I’ve added some spaces to make it more readable, but they’re NOT required on the calculators.

Define guess()=
Prgm
 Local num, trial, guessed, guesses

 guesses:=0
 guessed:=false

 num:=randInt(1,10)
 Disp num

 While not guessed
   Request "Guess (1-10)?",trial,0
   guesses:=guesses+1
   
   If trial=num Then
     guessed:=true
   ElseIf trial<num Then
     Disp "Too low!"
   ElseIf trial>num Then
     Disp "Too high!"
   EndIf
  EndWhile

  local prt
  prt := string(guesses)
  Disp "You got it in" & prt & " guesses."

EndPrgm

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