课程: Hands-On Advanced Python: Data Engineering Basics

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Random values

Random values

- [Instructor] In this chapter, we're going to take a look at some common statistical operations and we're going to start with random number generation. So let's open up our random numbers example here. So random numbers are used for a variety of scenarios from simulations to machine learning to games and even software testing. In Python one of the ways to generate random values is to use the random module from the standard library. And you can see that I've imported that here. So let's try it out and see what we can do with it. So to generate a random floating point number between zero and one, we can just use the random functions. So I'm going to print out random dot random and that is a function but that's not usually what you want to do. Typically, you want to generate a number that is within a range of values and we can use randint and randrange for that. Alright, so for example if I want to generate a random number…

内容