probability & simulation
We began a unit in math called 'Probability and Simulation'. The students of course have to solve many typical problems involving dice and coins. This provided a perfect opportunity for incorporating Python in a way that didn't freak the kids out. Remember, I have been trying to weave Python into a math environment where programming is seen as something alien and scary. Bizarre. The 'choice' function in the random library provides an excellent way to create all kinds of simulations very easily. I used this as an example in class:
coin = ['Heads - I win', 'Tails - you lose']
tosses = [choice(coin) for toss in range(1000)]
It was great. Very easy to understand. This combined with the 'count' method in a list, and I could go ahead and assign them a little HW project to create a frequency table for throwing 2 dice 10,000 times. I told them to just experiment, copy and paste their Shell session and email it to me. It worked very well. Even a lot of the kids who have been resistant to this Python stuff could handle it. Didn't require having to write functions - purely interactive. Then the next day we explored tetrahedral and other kinds of dice. Very simple, and it seemed to work well. There's a section at the end of the chapter that describes creating simulations using BASIC. Ha! We did this on the very first day! - Michel
participants (1)
-
michel paul