In this video, Kathyrn shows you how to use Python's random module to create random values and generate random choices.
- [Instructor] The random module allows you to create…random values and generate random choices.…And so, to start off, as we do all of these module videos,…we're going to go import random.…Then we're going to go ahead and access the random function…in the random module,…and so to do this, we'll go print, random.random,…and this is just going to give us a random number…between zero and one,…but sometimes this isn't really useful,…but there are other functions inside of the random module…that also have this random functionality.…
So, let's create a variable called decider,…and it's going to have the value of random.random…range, and the input is going to be two.…And so, decider is either going to have the value zero or one.…Which one it will be, that is completely random.…However, we do know the value will not be two,…because this function is exclusive,…and so the only two possible values…that are going to be returned, are zero and one.…If we had three here, then the possible values…would be zero, one, or two;…
- Working with logical and comparison operators
- Getting a list of numbers with the range() and list() functions
- Using mathematical functions such as round(), abs(), and pow()
- Calculating a given input's length
- Importing and using the math module
- Reading a user's command-line arguments
- Getting the current time
- Formatting dates and times with datetime
- Creating a timer
- Using urllib to get content from the Internet
- Using the JSON module to decode content
Skill Level Intermediate
Learning the Standard PHP Librarywith David Powers3h 24m Intermediate
1. Python: What's Built-In?
2. Python: Math
3. Python: Input/Output
4. Python: Date & Time, HTML Parsing, and HTTP
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.