In this lesson, you take the boolean variables that you learned about in the last video, and combine that with a new type of programming pattern called a conditional to help a computer make decisions. This will let us write some really cool programs where the outcome depends on the data. So depending on the data it might do "A" or it might do "B". One of the examples we see in this video will be using this to help prioritize what things to do first on your to-do list. Let's take a look. Let's go through the example with a more sophisticated to-do this or task list. I'm going to define the tasks with here for tasks. First task, is compose a brief email to my boss, and so on. And that will take me about three minutes to compose it using an AI large language model, and then takes a few minutes to send it off and then create an outline for a presentation on remote work and beyond the outlines of clean it up. Edit it, send it to some people. So let's say that takes me 60 minutes. Write a 300-word review of the movie "The Arrival". 30 minutes. And lastly, create a shopping list for a meal with a tofu and olive stir fry with my friends Tommy, Isabel and Daniel. And that shopping list would take me five minutes to put together. So, structuring the tasks will let us do more sophisticated things with it. Let's say it is nearly lunchtime and you're about to head out the door to lunch, but you have just a little bit of time to do any quick tasks. Here's how you can use a new type of programming pattern called a conditional, to go through your tasks and decide whether or not to do each one. So firs,t let me set tasks equal task list zero and let's print out, like others. So maybe not surprisingly, that is that first task up here, your task list. And if you're on your way out the door to lunch, one thing you might want to do is check of the task can be done in less than five minutes. And so let's see if this task has a time to complete that's less than or equal to five minutes, because if it's a quick task, we will just get it done quickly before we head out to lunch. And this turns out to be true. So, let me just go ahead and show you the code to make a program do a task only if it takes five minutes or less. It's going to look like this. I'm going to say if the task at the time to complete this task is to five. So what I've highlighted here would be a boolean value that would be either true or false, and then a colon. And one thing you'll see in Python is whenever there's a colon almost always the next line is indented. So indented four spaces here. But this says if the task takes less than or equal to five minutes to complete, then let's set task to do to a description of the task, and then let's get the LLM to process that task to do as a prompt and print the response. So, in this case when task is to zero, because the time to complete is less than equal to five, that's true. If I run this it will take the task to do and then print the LLM response like so. Let's go on and repeat this with the next item. So instead of item zero let's look at item one on the list. Item one takes 60 minutes. Is an outline for representation. So if I were to run this, what do you think will happen when I run it, nothing happens. Which is exactly what we wanted because tasks time to complete less than equal to five as equal to false. And so it decided not to run this code. It did not print LLM response because this says if it takes less than five minutes, then do this. But because it's not true, that takes less than five minutes. It did not do the task. And if you want to go through your entire task list, then the next item was write a review of the movie which takes 30 minutes and you run this. It does nothing again, which is exactly what we wanted. And finally, let me do this one last time. The final task was to create that tofu, an olive stir fry shopping list, which takes exactly five minutes. So if I run this, it calls you large language model. And it does do this final task. Let's take a look at what just happened an "if" statement in Python is a control statement that lets you define different ways for the program to behave depending on the Boolean condition to use. For the if statement that we use, what we said was check of the task we completed in less than or equal to five minutes. If true, then do the tasks print the LLM response to that task, otherwise in this example we don't do anything. And we'll see later how to write code to tell it to take some other action if this boolean value turns out to be false, we'll come back to that in a little bit. Let's walk through the key components of this piece of code. There's the "if" statement. And then there is a Boolean condition which has got to take on either true or false value. And then colon and indented and after that is a code to execute if a Boolean condition is true and this code is indented. So what you just saw me do was walk through the four tasks, one at a time, and write a little snippet of code like this, where for each of the tasks to zero, the task one and task two, then task three. It would check at the time to complete is less than equal to five minutes, and then if so, it will set the task to do to be in description and print the LLM response to that task. To do this is a pattern that we saw when we went through for loops, and we saw that instead of having manually write this code four times, in this case, there's a more efficient way to do this, using a single for loop to tell the computer to just do the step to every one of the four items on the task list. Let me just show you what the code to do that looks like. I'm going to say for task in task list. And now notice this is indented. And we're going to repeat the same code that we had before. If the task time to complete the task is less than five. And if I hit enter again, notice something funny has happened. Instead of being indented four characters, my cursor is indented eight characters now and then I'm going to have the rest of this code over here. So notice that what we did was take this code that we wanted to run four times, and we indented all of this code another four spaces to the right, resulting in this block of code that's inside the folder. And what this folder will do is for task zero, task one, task to task three. Remember we start counting from zero. It'll run this snippet of code will repeatedly check if the task can be done this equal to five minutes, and if so, then it will print LLM response of that task to do, which is description of the task. Let's go ahead and run this and see where result we get. So decides to do the first task and the final tasks, and then ignores tasks two and three, which is exactly what we want it. If you want to tell your code to do one thing, if the boolean condition is true and do a different thing at the Boolean condition is false, here's how you can modify the code. You could say if task time to complete five minutes, then do the task and then else and colon again and you see this a lot in Python. Whenever there's a colon usually the next line is indented. So if this is true do it. Otherwise, or else, if it's anything but true, this false print one will do this task later. Let me modify this code to demonstrate the else condition. So here's what we had just now. And I'm going to write else. And remember the colon. To complete later. Time to complete. Some other tasks. So if I run this now it does the first task lets me know there's a task I'll do later that takes 60 minutes and other tasks. It takes 30 minutes and then it does the fourth task. And I know that this doesn't print out the task to complete later. And the query was weight. But if you want, feel free to pause this video and modify this if you want. Maybe over here you could tell it task to do equals the description. And have a printout, a description of the task that you are saving to complete later. So feel free to pause the video and try to modify the code to make this printout a more detailed guide for on what exactly we're saving to do later. Now, what we've done so far is for the task of prioritizing for some of the day. We're just printing out the message, say, well, we do this later. It turns out that there's a nifty way to use something that you had learned about early in this course to save those future tasks in a better organized way. Here's what we can do. You might remember the coding pattern of where we start off with an empty list, so I'm going to start off with no tasks on my to-do list for later. And now here's a piece of code that will go through my task list. And if it takes less than five minutes, which is do it now. Otherwise, it were not doing before lunch. Then we appended to task for later. So let's run this and see what we get. So we will do the first task. We will do that final task. And now ,if we print tasks for later went up with that task to create an outline is going to take a 60 minutes and is that review of the movie The Arrival that takes 30 minutes, that will save for some other day. So you're nearly all the way to the end of the section. The materials on all the weightng tasks with Python. Before we wrap up, there's just one more quick video. I'm going to go over with you to talk a little bit about working with files. Let's go on to the next video.