Hi, welcome to this new video. We're going to be switching gears a little bit and talk about ways in which we could actually produce information with randomness. We have learned how to, let's call it hard code information, just by typing exactly the numbers we want. We also learned how to create sequences, numbers that follow a sequential order. In the last video, we started to learn that there are certain math equations that allow us to create numbers through math. Those may be areas of interest that each one of those might take you further into areas of research and exploration. But there's a different one as well, especially within computing of how we could actually start considering things that might be random or a pseudo random. As you could see, you'll see that the computer has its own way of creating a sense of randomness, even if it's not at a fundamental level, a true form of randomness. But let's understand randomness as we can actually use it within our programming environment. Randomness creates a value that doesn't appear to have any pattern or predictable behavior. If you have a range or let's call them all the possibilities for a value between here 1 and 8, selecting a random integer from within that range, we'll yield one of those, in this case five. But if we run that function again, it will not be the same number. It could be five, again, there's nothing excluding that old entry. But we will actually get a new number every time. Within a loop, for instance, if we think about it, if we use a random function within a loop, every time that we iterate over that loop, we will get a different result. That's quite interesting. What we will call all these possibilities, we could actually start thinking is the domain, We're creating a range, a domain in which these variables are, we're sampling from. Let's see the syntax of how do we use the random method. The first thing we actually need to do is import the random module. We're introducing something that is not by default part of our programming environment, we will need to include the import random. This is the very first module that will start expanding upon the capabilities of this environment, and you'll see that there's many more as we go along. Now we can actually print, let's print the variable random.random. This might feel confusing, but from the module random we access the random function, and we will get this very long decimal place number. But from that random module, we actually have a few different versions or methods that we can use within that module. For instance, from the very same module random, we could use the randint module. We could give a domain specifically here between 1-10 and we will get 10 or a random integer from within that domain. We can do some variations to specify, do we want a floating odd number, do we want an integer? Let's just see how we could actually implement this within our programming environment and give some caveats for some of the ways in which some of these random calculations actually work. Here we are back in processing. We're not going to need a draw loop in this example. Let's just go ahead and write this within the set up. Let's just create a for loop to start for equal in range. Let's do a 0-5, just a small number of numbers. Let's just create our random numbers. Let's be specific. Let's just start with a random integer number. Again, might take you a little bit of time to write a long variable like that, but it's worth remembering that this is in fact being randomly generated and it's an integer, random.randint. Let's do an experiment here. Let's just do 0 and 1. Let's print this value. We're going to just copy paste that. As you can see here, we have a for loop that is repeating five times. We are printing to the console down here, the console will print the value of that calculation. Let's just find a mistake. If you remember, we have to import random. Make sure that you import the module, otherwise you're going to run into errors as I'm doing here. Here we go. We have the module imported. Now, the window. We're not going to be drawing anything for a moment. Let's look at our window and our console. Let's just try to navigate here. As you can see, we have the numbers from 0 and 1, both of those appear. We have it five times. Randomly, this could be a 0 or a 1 because it's an integer. Everything seems to be working well. If we increase the range of this integer, you'll get values that go all the way up to 10. But what I wanted to do is between 0-1 because I wanted to talk about inclusivity, meaning 0 and 1 are both represented in the sequence. We might get unlucky if we do a small sequence, but in general, both of those numbers should appear in the sequence when we have a long list. But let's look at a different way of calculating random. I'm just going to copy this line and comment the previous one out. Let's call this one random number. Here instead of using a random integer, we're going to say randrange. A random range between 0 and 1. We are going to print the second version of our random. Notice that what we're actually getting here are all zeros. Why is that? Because, well, if we look at the documentation of the randrange module, it uses an exclusive, meaning that between these two values you will exclude the second value. Meaning that it will operate within the range determined by, let's say we do a 5, between 0 and 4 here. But it will exclude the number 5. It's important sometimes when you start using some of these functions that you understand reading the documentation, is it inclusive or is it exclusive of the values that you're using? Specifically in the random integer here, 0 and 1, this is an operation that you might want to do a lot, let's say if you have two conditions and you might want to calculate if something is on and off, maybe using a random integer, you might want to have maybe half of your values on and some of your values off. Knowing if you're creating inclusive or inclusive random might make the difference between all your cells or all your flights being off, or just half of them, randomly. We're going to be using these tools in the future. I just wanted to not only use it, but show you that sometimes you might run into bugs or issues by implementing perhaps the wrong module or the one that is not appropriate to the thing that you're actually looking for, But again, this module is very useful and feel free to kind of look into the documentation of Random and see what other functions are available for you for your specific case. So yeah, I'll see you in the next video.