Presentation is loading. Please wait.

Presentation is loading. Please wait.

Homework 4 Example Bernard Chen 2007. How do we generate Random number in Python Random is a very important method in math and statistics, how could we.

Similar presentations


Presentation on theme: "Homework 4 Example Bernard Chen 2007. How do we generate Random number in Python Random is a very important method in math and statistics, how could we."— Presentation transcript:

1 Homework 4 Example Bernard Chen 2007

2 How do we generate Random number in Python Random is a very important method in math and statistics, how could we generate random number in Python? We have a build-in model called Random If we want to use it, we need to “import” the model first >>> import random

3 Random Function Random model has many different functions to generate random numbers I introduce random.choice( ) here In this function, it will randomly choice a object from the given ordered object

4 Random Function Example random.choice([1,2,3,4,5]) (ordered object) random.choice(‘asdfghjkl;’) random.choice(range(1000))

5 References http://docs.python.org/lib/module- random.html

6 Demo Try to come up with an interesting example to use it.


Download ppt "Homework 4 Example Bernard Chen 2007. How do we generate Random number in Python Random is a very important method in math and statistics, how could we."

Similar presentations


Ads by Google