# The following code is one method for simulating the average score from 3-pt shots that the basketball player # from our classroom example earns. This method simulates the score directly rather simulating the individual # shots number_simulations := 1000: #Comments follow the pound sign and are ignored by MAPLE scores := array(1..number_simulations): # Note the use of := to assign values # and the use of colons on the ends of the lines for i from 1 to number_simulations do u := rand()/10^12; if (u < .85975) then scores[i] := 0 elif (u<.99050) then scores[i] := 3 elif (u<.99975) then scores[i] := 6 else scores[i] := 9 end if; end do: # the colon at the end of the "end do" statement suppresses all output from the entire loop evalf(add(scores[i], i=1..number_simulations)/number_simulations); #evalf gives the numerical answer (in digits) #add computes the numerical sum rather than #trying to give a formula.