(* The following examples illustrate how the function "Table" works.*)

Table[i^2, {i,1, 10}]

(* The folliwing simulates 10 coin flips (0=tails, 1=heads):*)

Table[RandomInteger[], {i, 1, 10}]

(* The following flips a coin ten times and then sets "myflips" equal to the result:*)

myflips=Table[RandomInteger[], {i, 1, 10}]

(* myflips never changes *)

Table[myflips, {15}]

(* If I want to do many independent 10-coin flips, I need to define a function, not a constant.  The symbol ":=" accomplishes this.*)

xxflips:=Table[RandomInteger[], {i, 1, 10}]

Table[xxflips, {15}]

(* I can make a function that flips n times, depending on what n you demand.*)

flip[n_]:=Table[RandomInteger[], {i, 1, n}]

(* I can repeat the experiment of flipping three times as many time as I please---say 20 times:*)(*Note that I've used an abbreviated specification in Table.*)

Table[flip[3], {20}]

(* Or 100,000 times.  Here, we record the result as "xxx".*)

xxx=Table[flip[3], {100000}]

(* Let's use the Mathematica function "Tally" to find out what we have:*)

Tally[xxx]

(*This says that {0,0,0} occurs 12572 times in the list xxx.*)

(*************************************************************)

(* Exercise: modify the above to create a list yyy of 1600000 instances of flip[4].  Then tally the rsults.*)

(* Exercise: Look up the function RandomInteger in the Mthematica Help Utility.  What does the following do?:*)

RandomInteger[6]

(* Project:  Modify the above exercises on coin flips to model the experiment of rolling n dice.  Perform 100000 repetitions of the experiment of rolling 2 dice, and tally the results.  *)