Assignment 6 example
This presentation is the property of its rightful owner.
Sponsored Links
1 / 6

Assignment 6 Example PowerPoint PPT Presentation


  • 80 Views
  • Uploaded on
  • Presentation posted in: General

Assignment 6 Example. 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.

Download Presentation

Assignment 6 Example

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Assignment 6 example

Assignment 6 Example


How do we generate random number in python

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


Random function

Random Function

  • Random model has many different functions to generate random numbers

  • I introduce

  • random.choice(<ordered object>) here

  • In this function, it will randomly choice a object from the given ordered object


Random function example

Random Function Example

  • random.choice([1,2,3,4,5])

    (ordered object)

  • random.choice(‘asdfghjkl;’)

  • random.choice(range(1000))


References

References

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


Assignment 6 example

  • Demo

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


  • Login