Hello Python | Rob Merrill | Skillshare
Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
28 Lessons (2h 27m) View My Notes
    • 1. Welcome

      1:58
    • 2. Comments

      2:41
    • 3. Multi-line Comments

      2:39
    • 4. Print

      2:27
    • 5. Print Multiple Lines

      2:59
    • 6. Strings

      2:02
    • 7. Strings with Quotes

      2:58
    • 8. Errors

      4:29
    • 9. Numbers

      5:03
    • 10. String concatenation

      3:13
    • 11. Number concatenation

      5:29
    • 12. Multiply equals

      3:33
    • 13. Import math

      3:18
    • 14. Fahrenheit to kelvin

      8:04
    • 15. Cat age convertor

      10:28
    • 16. Function syntax

      4:25
    • 17. Function syntax p2

      3:21
    • 18. Function whitespace

      3:31
    • 19. Arguments and parameters

      5:57
    • 20. Bear human gun

      17:04
    • 21. Calorie calculator

      12:01
    • 22. Lesson lists one

      3:31
    • 23. Lesson lists two

      7:46
    • 24. Lesson lists three

      4:02
    • 25. Lesson lists four

      10:21
    • 26. Lesson lists five

      4:17
    • 27. Lesson lists six

      3:42
    • 28. Lesson lists seven

      6:02

About This Class

Each Python video has a PDF document that goes with the video. Please try completing the PDF document and then when you are done you can compare it to the corresponding video. You can find these challenges under the "Your Project" tab then look under the resources section.

If you have no coding experience and want to begin coding in Python for the first time then this is the course for you!

Hi, I'm Rob. I know what it is like to have no coding experience and desire to code professionally. I started coding in 2016 and landed a full time development shortly thereafter. It was hard but it was worth it.

That's why I'm here. To help you make that transition yourself.

In Hello Python you will immediately begin to learn the language of Python. We’ll learn the basic syntax of how the Python language works. 

After that we are going to apply what we learn to mini projects. That will allow us to take what we have learned and put it into practice. Some courses teach you to build some sort of large application while you haven't mastered the basic syntax of Python.

This course will give you opportunities to build mini applications step by step in a way that makes sense to someone learning programming for the first time or still learning the basics of programming.

This isn't the only Python course you should take but it should be your first!

Transcripts

1. Welcome: All right. Welcome to hello, Python. Hello. Python has a goal of making python ridiculously simple. The Python language, like all development languages, can be incredibly challenging and complex. However, learning the basics for beginners shouldn't be all right. As you've seen for each tutorial, we'll have a printed version that you can follow along on your own. And then following that, we'll have a video in which I walked through that tutorial as well. So let's get comfortable with the editor we're going to use to learn python syntax. When you click the link in this lessons article, it should have opened up this page for you. This is gonna be our coating sandbox further along in the course, I'll show you how you can set up Python in your own development environment on your own computer. But for now, so he could jump right into learning Python. We're gonna go ahead and use this and box so we can start coating right away. Okay, So what I want to show you is that on the left hand side of the screen, we have our python code. You may not understand what any of this code means, and that's okay, if you don't. What I want to show you is that when we have our python code on the left hand side of the screen, when we click this play button, our code will be run and we'll see the results on the right hand side of the street. So in this case, the result of our code is welcome to the course. Hello, Python. Now, in this lessons tutorial, I gave you the challenge of changing the text Hello, Python and replacing it with the text of your name. So I'll go ahead and put my name in here. And after I've done that, we can see that there aren't new results on the right hand side of the screen. That's because we have to press the play button. When we do that, we see the result. Welcome to the course, Rob. All right, that's all we need to know for how are coding sandbox works. So let's jump into our next lesson. 2. Comments: all right, So in this tutorial, we learned about comments. Comments aren't needed for the computer to run your program. Comments are for you and for others who will be looking at your coat. Any text that is written but not run by the computer. It's called a comment. So we saw in our tutorial. Creating a comment is a simple as using the hash symbol Severin. Some text after I've used the hash symbol. If I go to run the code, nothing will happen because anything after the hash symbol will be interpreted as a comment . So in the tutorial, we looked at a few ways in which you might want to use comments, and this example were explaining why something is written the way that it ISS we've credited Variable is going to count the number of words that are written in all caps. In another example, we're using comments for faster understanding of what the code is intending to do. So, for instance, this comment isn't at this code, will calculate the odds of your team winning the championship, and we're saying this comment above a function and so we can assume that this function had lots of code to go with it instead of having to read through all of that code, we can simply look at this comment and know what that code is going to dio to know. If that's an area that we need to investigate, Ah, bug or adding a new feature. Another example could be using a comment to make sure that code doesn't run. So in this example, you could comment out a line of code and see how your program runs without it. Okay, so those are just a few quick examples in which you might find yourself writing comments on the tutorial. I asked you to go to this link, and I want you to simply write a comment that describes what you want to build. And I thought so. There is absolutely no wrong answer to this challenge. Well, I guess there ISS if you're comment doesn't begin with the hash symbol, that would be the only wrong answer. It's all right, hash. And then what do I want to build with Python? I want to build and application that makes a lot of money or makes a lot of people happy, all right. And then we could just go ahead and double check and make sure that this is really a comment. When we click the play button, no code is ran and there are no results. All right, great job in this lesson and we'll see you in the next. 3. Multi-line Comments: Well, hopefully you're not tired of learning about comments. We got one more quick tutorial on How did you comments with multiple lions? Let's say you went three lines of comments. We could use the hash symbol comment line one past symbol comment line to hash symbol comment. Line three. We run our code, and as we would expect, nothing happens. But that seems a little unnecessary to have to use the hash symbol to start each line of our comment when we're gonna have multiple lines. So fortunately, Python has a really simple way to make this happen. So let's look at the falling. Here's three lines of text that I want to be comments now. If I pressed the play button, we're going to get an air because the Python interpreter is trying to run this code because they aren't commented. So now, instead of putting a hash symbol in front of each line, well, we can simply dio And before that, I'm gonna clear out this mess to make her environment look a little cleaner. No, what I could do, instead of a hash symbol for each line, is I can use three single quotes at the beginning of our text and then three single quotes at the end of our text. So now when we run this no airs, the Python interpreter is accurately seeing this as a comment and then one quick alternative to using three single quotes. It's actually used three double quotes. So when we run this code again, it's interpreted as a comment. But here's a little trick that won't work. You can't mix double quotes with single quotes. If you do, and you're on your code, you're going to get an air because the Python interpreter is trying to run this as code rather than seeing it as a comment. Okay, so let's go ahead and jump into the link that I asked you to open and to finish this challenge to convert these three single line comments into a multi line comment. Hopefully, that was a pretty straightforward task for you. Well, simply start off by removing the hash symbols. I mean, clean up this space, then I'll simply just use single quotes. You could use double quotes if you would like at the beginning and start of the text. Once we've done that, we run our code. We can see that our code doesn't run because our text has been successfully converted to a multi line comment. All right, great job in this lesson and we'll see when the next. 4. Print: in this lesson, we're gonna learn about the print function. We're gonna be using this a lot. We'll go further in depth about functions in the future section. For now, we'll look the print function and the instant feedback he gives us. The print function prints the specified message to the stream or other standard output device. The message could be a string or any other object. The object will be converted into a string before ridden to the screen. So basically the print function is used to tell the computer to talk. We have our print keyword, and then we have the prince. Whatever we pass into the Friends is opening and closing parentheses is going to be what you print. In the case of text, we will want to surround our text with the single or double quotes to make a string. We'll explain what the value type string is in a future lesson. So for now I'm grabbing a quote from the book The Giving Tree. I have some text that have surrounded with double quotes. Come boy, sit down, sit down and rest and the boy did and the tree was happy. So let's go ahead and run our code and see what happens. Results come, boy, sit down, sit down and rest. And the boy did, and the tree was happy. So in this example, we directed our program to print an excerpt from a notable book. The printed words that appear as a result of the print function are referred to as output. The output of this example program would be this text here. So now for our challenge, go ahead and open up the link that provided you. And hopefully this was pretty straightforward. I simply wanted you to print the greeting Hello World. So let's go ahead and do that together. So let's use the print keyword. And if by any chance you did print with a Capital P, you would have gotten an air. But we'll talk about that in our lesson on airs. That's coming up soon. So we use the print keyword and then we're gonna pass in the strain Hello world. So you single or double quotes and then we run. Our code will have the output on this side of the screen, so let's go ahead, run our code and there we go. Hello, world. All right, great job in this lesson and we'll see you in the next 5. Print Multiple Lines: All right, so in this lesson, we're looking at the print function again. In a previous line, we looked at a quote from The Giving Tree by Shel Silverstein, and when we use the print function to print it, we can actually see that's attempting to print on one line. If we had more space than this line would go across the whole screen. But because this is poetry, output should actually look different. We went the first line to say, Come boy, sit down, sit and rest. The second line should be and the boy did. The third line should be and the tree was happy. But we can see that as we expand and shrink the space, we're not actually able to determine those line lengths or the number of lines using the print function as we're using it. So in our notes we saw that maybe one solution you might try to take would be to simply use the return statement to match how we want our text to display. But when we run that code, we can quickly see that we get a syntax there and we'll look at errors in a couple of lessons from now, so we don't need to understand what this air message means. Currently, we just know that this isn't working. So in our notes we saw that the solution is actually quite simple, and it's a little bit of a callback of how to do multi line comments. We simply start our string with three single or double quotes, and when we do that and we run our code, it actually runs our code. And when we have a full width of the screen available, we can see that it's gonna format our code to fit as we would expect. So that's all it takes. So go ahead and let's open up our challenge and our challenge. I want you to take this text, which again is poetry, and I want you to print to the screen three lines. The first line should be two roads diverged in a wood, and I the second line should be. I took the one less traveled by and then the third line should be, and that has made all the difference. So hopefully this is pretty straightforward. You know, the first thing we need to Dio is to start with three single or double quotes and A and R string with a matching set of three single or double quotes. Now, once we've done that, what has hit the return key? Wherever we want our new lines start, I'm gonna go ahead and open up some space right here and now we're ready to run our code. And the result is three lines of our tax displayed as we would expect. All right, great job in this lesson and we'll see in the next. 6. Strings: all right. In this lesson, we're gonna go ahead and look at the data type strengths we've already been using them often on, but having address them in any sort of detail. So let's go ahead and do that now, okay? All we have to do to create a string is to take a block of text and surround it with single or double quotes. So here we have two lines of text. They both say, Hooray around the first line of text one ad, a single quote and then around the second line of text, I'm gonna add double quotes, both of these air valid strings and python. So let's go ahead and print these out. And in both cases, that print out parade python Let's try this one more time. And this time we're gonna mix single and double quotes, and I'm gonna add her a python as our texts. Now again, we see the outside has a single quote and a double quote. Let's run our code and see what happens. We get an air. So while we can use either single quotes to wrap our text or double quotes to wrap our text , we can't mix the two, All right, So now let's go ahead and quickly jump into our challenge for the lesson. We're simply want to use the print statement French, our favorite color to the output. Well, say print blue. I run my code and it runs is we would expect next. If we used single quotes, which used double quotes or if used double quotes, you should use single puts. So my go ahead, just have a new line and I'll put our text blue with in double quotes and run the code and they both thrown just fine. All right, great job in this challenge will see you next time. 7. Strings with Quotes: Okay, So in this lesson, we're gonna look at strings that include quotes already. What happens if we have the following text that we want to convert to a strength three of Sarah said name, comma. And then we have a quote, cause this is what Sarah is saying. I would not do that if I were you. And that's surrounded by this opening quote and this closing quote. Let's see what the python interpreter does only run our code. We get an air, this is invalid syntax. And so this is gonna happen whenever you have the outer quotes matching the inner quotes of a strength of a text that you're trying to provide to the output. So if we change these outer quotes that are double quotes to single quotes and only run it , you find that our code runs just fine. Now, as you can imagine, if you find yourself another situation that's similar in which you have a contraction with the word I'm and the single quote matches the outer single quotes, then if we run our code, we're gonna have an air again. So the way that we can remedy this as we can make the outer quotes double quotes instead of single quotes so that they do not match what is inside in our strength. So if we run our code, we can see that our text appears in the output, as we would expect. All right, we have to print functions that are resulting in syntax airs. Please fix these errors that both strings air printed to the screen. Let's go ahead and start with their first example. We have double quotes surrounding a text that is using double quotes. So the way that we can fix that it will change that to a single quote to surround our text . Let's run our code and we can see that we're getting an air online, too. This means that Line one is not creating an air, So let's focus on line two. We have a string with a contraction in it for the word what's in that single quote matches the surrounding single quotes so just fixed that by changing this to a double quote, and when we do that, we run our code Anderson text Air is gone and both of our strings air printing to the street. All right, great job, and we'll see in the next lesson 8. Errors: All right. Well, programming in Python, you're going to make mistakes. In fact, we've already seen a few errors occur already. Throughout are lessons we've just skipped over them and this lesson going to slow down a minute and take a look at some errors. So in line one, we have a print function, and when we run it, we can see that we're getting an error on the output side of the stream. Now, Python is gonna help us figure out what's going on. One item that you want to pay attention to is this upwards carrot symbol. It's gonna point to the location where the air is a great We can see that the air is pointing to this closing Ferentz down below. We're getting the type of air that we're getting in this case, a syntax air. So there's something wrong the grammar of our code so we can see that this syntax air is ul end of line, while scanning strain literal as so Python is telling us there's something wrong with our strength that we're hitting the end of the line before we should. So if we take a deeper look at this, friends will see that it's not necessarily the parenthesis that's the issue. It's that we have a closing single quote and an opening double quote inside of our print function. Our prime function, because it begins with this double quote, is expecting to end with a double quote before encountering this friends. So if we go back to our line of code on line one, that would change the single quote to a double quote and then we run our code. We'll see that we're no longer getting a syntax air. Now let's look at another type of air. We're gonna look at a name error online. One. We have a variable greeting, and we have said it equal to the string. Hello, Python, then online to were attempting to print our greeting variable. So when you run our code, we get an air we can see that's occurring online, too, which is the line that says print greeting. Chances are you see what the air is already, but in case you're missing it, we see that the type of errors is a name error, and it says name greeting is not defined. Now, if we take a closer look, we can see that this isn't the word greeting with two e's, but grunting G r E T I and G and gritting doesn't match our variable name greeting. This is important to note regarding programming. Python is not going to try to read your mind. However, fortunately, it will give you direction where and what type of problem you're having so that you can fix what isn't working. Okay, let's go and take a look at her challenge. We have two lines of code online, too, and online five online to we're gonna have a syntax air that we need to fix and online five . We're gonna have a naming air that we need to fix. Let's go ahead and run our code and see what hints Python gives us so we can see that our first airs on Line two, where the variable weather is set equal to this string. The weather today is cloudy and we can see this carrot is pointing upwards at this closing single quote, and so we can quickly identify that while we open with a double quote. We should be closing with the double quote, So let's go ahead and fix that. And now Let's run our code and we can see that line, too, is no longer creating an era for us. We can see that our error is now online. Five where we're printing Hi. And what we can see is that hi is not defined. So our print function is actually looking for a variable. Hi. So if we say hi is equal to hello and then we run our code, it runs just fine and there's no longer a naming air. Another way we could have solved this is we could remove this variable high set to the string. Hello. And we could put high within single or double quotes. So we're no longer looking for the name high, but we're just printing the string high. All right, great job in this challenge and we'll see you next time. 9. Numbers: All right, let's go ahead and get started with a data type. Numbers Numbers are quite often using programming to keep scoring games, represent data and visualizations and store information and Web applications, just to name a few uses. Python actually has a few numeric data types in a way of storing numbers. The data types depends on your purpose. For the number you are saving. Let's go ahead and take a look into jurors and in injures, a whole numbers such as 123 or four as well as their negative values. Native one negative too negative. Three. Native four and zero and teachers are often used account. For example, the number of guests coming to dinner. You're not gonna have 2.5 people. You're gonna have three people coming for dinner or how many cups you have on the table. You're not gonna have 2.5 cups on your table. Your enough to cups or three cups. You can add, subtract, multiply and divide enters with python. Lest you a few quick examples. Print two plus three. We can print three minus one. Forgive us, too. We can print three times two, which should give us six. Okay, now, let's go ahead and look at floats. Python calls any number with a decimal point afloat. This term is used in most programming languages, and our first, the fact that a decimal point can appear in any position and a number. Every programming language must be carefully designed to properly manage decimal numbers. So numbers behave properly no matter where the decimal point appears. And don't worry too much about managers and floats because for the most part, you can use decimals without worry about how they behave. Simply enter in the numbers you want to use, and Python will most likely do what you expect. So let's take a look at a few examples. All right, in our first example were able to add to floats together, which should give us 0.5 and our second example. We see that we can multiply an integer by a flow three times 30.2, and in our third example, we can see that we can taken manager and we can divide it by a float. So we go ahead and run our code and see the python Interpreter has no problem running this coat cover you can see in our output online, too. A little bit of a python. Gotcha. Floating point numbers could behave in some unexpected ways due to how computers store them . For more information on that and a deeper dive, you can click on the link in our notes that refers to Python's documentation on floating point limitation. Be sure to check that out. Now Let's go ahead and check out our challenge for this lesson. We're pretending that you're a fan of baseball and your favorite player is a picture. We're going to use an integer to track your favorite pictures strikeouts for a specific year, so we're gonna go ahead and credit Variable called Baseball Season Another variable strikeouts. Now let's go ahead and just choose a random baseball season. I might go ahead and pretend that I'm tracking the strikeouts from my favorite picture from the year 20 10 and they're strikeouts for that year. Well, say 220 for all right, so there really is no wrong answer to that challenge. We just want to make sure that we know how to sign numbers. Two variables. Those are examples of using imagers. Let's go ahead and take an example of using afloat in our second step. We're supposed to capture the e R A. Over favorite picture. Now turn around average is just the average amount of runs given up over nine innings. And because pitchers don't always pitch nine innings, they pitch a variety of innings and give up a variety of runs. Over the year, we're gonna have to capture an average, which is most likely going to be afloat value and not simply an integer value. So I'm gonna go ahead and declare a variable earned run average, and I'm going to go ahead and set it to 2.94 as my float. Alright, if you're not familiar with baseball and you'd rather come up with the variable of inches rained per year or average temperature per year, you could go ahead and do something like that. All right, great job in this lesson, and we'll see next time 10. String concatenation: in this lesson. We're gonna go ahead and look at stream contamination. Now we're used to adding two numbers together. But did you know then Python? You can add two strings together when we had two strings together. This is something called string Concatenation, so let's go ahead and look an example. We can declare a variable strain one and set it equal to the string. Hello. We can then have another variable of string to and set it equal to the string. If I thought Now we can go ahead and use the print function and we can say strain one plus string to and the result when we run our code is an output of pelo python. Now chances are, we noticed, with our output, that there's no space between the O and the P of python. When we add strings together, you have to pay extra attention to make sure that our spacing is correct. Let's go ahead, take a look at a few different ways. We can do this. So our first approach is to put the space before the peak. So we go ahead and print hello and we add another string. And we started with a space passed on. And then we run our code and we get hello python with space before the peak. Our next approach would have the space after the O. So you say hello, Space plus python without a space in front of the peace only run our code, we can see that we're getting the output would expect again. And the final approach we can take is to contaminate a string that already has a space in it. So we could print hello, plus a string with the space plus pipe on. And that gives us the same result as well. All right. Now, with this introduction to string concatenation, let's go ahead and take a look at the challenge You're taken candidate string one through strength six and save the message they form in the variable paragraph, then print the results. So we're gonna say paragraph is equal to string one plus strange to plus string three plus strain for us. Strange five and then finally plus strain six. Now that we've done that, we'll go ahead and trench and we dio And when we're done, we get the output, which is the opening paragraph to Charles Dickens. A tale of two cities. All right, great job in this challenge and we'll see you next time 11. Number concatenation: All right, so in this lesson, we're gonna look at what happens when we want to contaminate a string and a number together . So let's imagine this scenario. We have a variable, a lucky number, and we've set it equal to seven. Then we have a message, which is strange, that says, my lucky number is then a space. And then we'll add another variable called period and was set equal to a string of a period . Now we simply want to Prentice instance that says, my lucky number is seven. We would think that if we use the print function, we pass in our message variable, which is the string. My lucky number is, and we add to it are variable lucky number, which is the value of the number seven plus period in which we add the string of a period to close our sentence, that when we run our code, we would think that this would run just fine. But it doesn't. Instead, we get a type air. This is our first type air of the course. We see that our air is occurring online for with a line print message, plus lucky number plus period and our type error message says Must be str for string, not int for integer. Well, what's the only integer we used? It was the lucky number. It was the seven that we signed to a variable lucky number. So we can see is adding a string and an inter is a problem. Fortunately, there's a simple solution. It's using the string function. When you use into just with strings like this, you need to stay explicitly that you want python to use the integer as a string of characters. So let's go ahead and use that what the string function and we're gonna pass into it our lucky number, which is an insecure. So now when we run our code, we can see that our output is my lucky number is seven. Now there is an alternative. There's a way around this in which we don't have to use the string function in python. If you're trying to print a numeric variable, you can use commas to pass it as a different argument. Rather than converting it to a strength, we don't need to convert a number to a strain for to be an argument in a print statement so Let's take a look at this. Let's say we have a variable called guests, and we've said it equal to the integer five. We have a start. Message equals to the string. There are and noticed that I don't have a space after the letter e. We next have a variable end message, and we've set it equal to the string. Yes, coming to dinner now. Finally, we want to print a message that says there are five guests coming to dinner so we can do that with the print method instead of using string contamination. Well, it's a start message, comma guess, comma and message. So we're simply doing is they're printing start message, which is there are and then guess and there's going to be a space between our and guests and between guests and end message because of these Calmus. So when we run our code, we get the string. There are five guests coming to dinner. All right, let's go ahead with what we know about contaminating numbers. Two strings and let's take on our challenge. Our challenge. Weaken. See Online's five and six is different. A string that says a marathon is 26.2 miles. So we start off. We have a variable message, Start said. Equal to a strange that says a marathon is space. A message finish, which is Space miles, period. And then we have a marathon distance variable set to the float 26.2. So to print this, we would simply say Message start. Plus, you might say Marathon distance Roma she really quickly. Why, that doesn't work again, plus message finish. And when we run this code again, we're going to see that we get that type. Air must be string, not float marathon distances afloat. And so we just need to pass that into the string function. No. When we run our code, it runs just fine. A marathon is 26.2 months. All right, great job in this challenge and we'll see you next time. 12. Multiply equals: all right. And this lesson. We're gonna go ahead and take a look at updating variable values. If we have a number saved to a variable, and I want to multiply the current value of the variable you can use, the multiply equals operator. Let's go ahead and take a look at this. Let's say we have a variable for earnings in a month that variable earnings is equal to the integer 2000. Let's say we want to discover salary for the year so they get the salary for the year. We could take earnings and we could send equal to earnings times 12. That's because earnings this 2000 we're now saying that earnings is equal to earnings, which is 2000 times 12 which is 24,000. So let's go ahead and print this out, and we get 24,000. So that was a lot of code. More succinct. Way to get the same results is to use the multiply equal operator, and when we do, we see that we don't have to type in the variable earnings again. We could just said that earnings is equal to earnings times 12 so we run our code again. We get 24,000 now. This can also be used for strings as well. So let's imagine we have the variable laughter and we set it equal to the string. Huh? We can now use the multiply equals operator to say laughter times equals four. So this means that laughter which is equal to the strain a former we're gonna multiply that by four. And when we do, if we print laughter, we should get ha ha ha ha. And we do okay in this fictitious example you're gonna take the initial income you earn per hour and multiply that by the hours you worked that day and print the results. So let's imagine on lines four and five you have a part time job in which you earn $10 per hour. This integer 10 is assigned to the variable income and then online seven. We have a comment that says the hours you work today and so we have a variable hours work today said equal to the integer of five for the number of hours worked. So let's go ahead and figure out our income for the day by using the multiply equals operator and then print income output. So income times equals five. And now let's go ahead and print. Thank God. When we do this, it should be pretty straightforward. We should get the number 50 our income for hours $10. And so now we're setting income equal to income times, five hours of work, and that gives us the number. All right, great job in this challenge and we'll see you next time. 13. Import math: all right. And this. Listen, we're gonna go ahead and look at importing libraries. Specifically, we're gonna look at importing the math library on our screen. I have an example of how we import a library and use it. So let's go ahead and look at our code and what we're doing and our first line of code were importing the math library to give us access to the floor method that we can see online for . We'll talk about the four Method in a moment. In our next line of code, we have a floating point value of 82.12 and we've assigned the variable dollars. In our next line of code. We can see that you are variable whole dollar. We're assigning the value of dollars, which is our floating point value of 82.12 Passed into the math up floor function. The math out floor function automatically finds the largest imager less than or equal to the current value. And then finally, on the last line, we simply French the value of whole dollar. So we run our code. We should see that 82.12 for dollars passed the math floor method should be 82. So let's run our code and the value is 82. Now, let's go ahead and comment out. This first line of code important will run our code. And when we do, we confined that we have a name error. Math is not defined. So this occurs online six because we don't have access to the math library because we haven't imported it. We don't have access to the floor method as well to pass dollars, too. Okay, There will be a lot of importing of libraries into files as we go on to this course. So this was just a soft introduction to the concept. Let's go ahead and take a look at her challenge in our challenge. We're gonna go ahead and use the math dot seal property and the math dot steal property. As you might go to guess from its name. Seal a short first ceiling. So we're gonna take whatever number that we have, and we're going to round it up to the nearest integer so we can look at the code that we already have online to. We've imported in the math library online. Five. We have a variable money in the piggy bank, equal to the flow of 42.75 Now, in our challenge were saying that if this is the money that's in your piggy bank 42.75 your parents are going to give you money to round up to the nearest integer. And that's where we will use the math, that steel bullshit. So we're gonna go ahead and use the print function, and we're gonna print the value of math that seal, and we're gonna pass in money and picking. So let's go ahead and run our code and we get the number 43. All right, great job in this challenge and we'll see you next time. 14. Fahrenheit to kelvin: in this many application. We built a Kelvin to Fahrenheit converter in this video. I'm gonna go ahead and walk you through the steps I listed in the tutorial to build this together with you in case you got stuck anywhere at the end of this lesson. Also show you how you can share your projects code in this lessons, Q and A if you needed any help, or you might have got stuck somewhere, all right? And to get started, I'm gonna go ahead and open up a new sandbox, and I'm just gonna go ahead and call this Kelvin to Fahrenheit. Okay? Now we're ready for step one. We went the temperature and Kelvin stored to a variable called Kelvin 10. So what type? Kelvin temp. And it's step one. We said, Let's go ahead and set it to 301. Okay, now step two. We noted that funding the temperature in Celsius is similar to Kelvin. The only difference is that Celsius is 273.15 degrees less. And Kelvin. So you convert Kelvin two Celsius by subtracting 273.15 from the Kelvin temp variable value , and we're gonna store the result in another variable named Celsius temp to a set. So see us, Tim, equal to Kelvin temp, which we know is 301 and we're going to subtract 273.1 five. And at any point, if you want to check on the values that you're creating, we can simply use the print command agency. Currently that my temperatures air 301 for Kelvin and 27.85 for Celsius. Okay, I'll go ahead and delete those. Okay. Our next step is to use an equation to determine our Fahrenheit temp and save it to the variable Fahrenheit. I'll go ahead and open up the screen right here. So we'll say Fahrenheit temp is equal to, and the formula is Celsius Times nine divided by five plus 32. So I'll say Celsius temp times nine, divided by five and in the final part of the formula is plus 32. Okay, Now our next step is to use the print function to check the temperature of Fahrenheit tempt . All right. And the result is 82.13 Okay, so Hopefully, that's where you're at. If that's not the number you're getting, you'll want to make sure that your type in the code just as I am here. Okay, I'm gonna go ahead and remove this print command. Now, the next thing we want to use is we want to use the floor method from the math library and his good practice. We're going to go ahead and do that at the top of our program, all right? And from our previous lessons, we've learned how to import the math library. We'll just use the key word import and then math, because that's the library. Wanna have access to? So the next thing we want to dio is we want to pass to the floor method, the value for Fahrenheit temp. So we round down to the nearest number. Okay, so our next step is going to be round the value of Fahrenheit temp down and a sign for a variable Fahrenheit. So we'll simply type in Fahrenheit temp again, and we're gonna set it equal to math that floor. It will pass in Fahrenheit. So I'm gonna go ahead and print the value. A Fahrenheit temp previously was 82.13 But because we've pass it into the math out floor method and assign that value to Fahrenheit temp again, we should get 82. So my go ahead and run my code, and the result is 82. Great. I'm I Go ahead and clear out that print function now. Our last step is the use string concatenation to leave a message. The message to say the temperature is Fahrenheit degrees Fahrenheit and the value for Fahrenheit should come from our variable Fahrenheit temp. So let's go ahead and use string contamination. To print this to the screen is the print keyword, and then we're in a pass in what we want to print to the screen within these prints. So let's say the temperature is that I'm gonna add a space plus, all right, and we'll have to remember that because Fahrenheit temp is a number and we want this to be a string that we have to put that variable within this str Fahrenheit temp, plus the remainder of our strange degrees Fahrenheit. All right, let's go ahead and run our code and see if we get the results. We would expect the temperature is 82 F. Okay, let's just quickly walk through our coat to get access to the math dot floor method, we imported the math library on Line one. We then started with a Kelvin temperature of 301 degrees. We then learned the Celsius temperature a declaring a variable Celsius temp and said in an equal do Kellman temp minus 273.15 degrees. Next week is from the Fahrenheit temperature by saying it equal to our Celsius temp times, the Formula Nine divided by five plus 32. The result was not a whole number. And normally when you're watching the news and they give you the weather, they don't give you any decimal points. They just get you whole numbers. So we have reassigned the value provided to Fahrenheit temp by using the math dot floor method on our value for Fahrenheit attempt, changing it from 82.15 degrees to 82 and then finally we use string contamination to leave a message. The temperature is Fahrenheit degrees Fahrenheit, so we use the print method and then the string the temperature is, and then we also wanted to have in our string the value for Fahrenheit temp, which is a number. So we had to use str and then the opening and closing Peron's and passed in our Fahrenheit temp variable value. And then finally we added the remainder of our string and we got the results of the temperature is 82 F. All right, And if for any reason you're code did not work, as you would expect, you can simply click on the share button and grabbed the link. You can then go to the Q and A of this video or the step by step lesson, walk through and provide this link in the Q and a All right, great job in building out this many application will see you in the next twist. 15. Cat age convertor: we're gonna go ahead and walk through our cat age converter. Many app. Hopefully, this challenge is pretty straightforward. Well, go ahead and walk through this challenge step by step, in case you got stuck anywhere. Okay, I'll go ahead and open up a new coding sandbox environment. And we were given the challenge to convert your age the cat years and we're giving the formula to convert her age to cat years. We need to keep two things in mind. The 1st 2 years of a cat's life count is 25 cat years each. They growing maturity quickly than each additional year equates to about four cat years, which means that their rate of growth slows down quite a bit. Now, these are just some general stats and you can argue back and forth whether those are accurate or not. But they do give us the parameters for our project. So let's go ahead and get started with step one. We're going to begin by creating a variable named my H, and we're gonna go ahead and set it equal to rage. I'm gonna go ahead and just pick the number 25 because if I pick my actual age than for sure this cat will be dead. So I'm gonna start with the younger H now for step two. We want to create a variable named early years and save the value to to it. So early years is equal to two. And the reason we need to know this is because cats age 25 years for each of those 1st 2 early years. So that's what takes us to step three. We're gonna use the multiplication assignment operator times equals to multiply the value saved early years by 25 reassign it toe early years. This will account for the 1st 2 years of a cat's life where the experience accelerated growth so early years times equals 25. No one go ahead and Trent the value of early years to see if we're getting what we would expect. The number 50 so early years is too. And then Q times equals 25 equals 50. Now, if we wanted Teoh, we could have just put the value 50 here in our head because we know if the cat grows 25 years for the 1st 2 human years, we know that number is 50 but we're learning to it. Python do the work for us. My delete This line of code Let's move on to Step four. Since we've already accounted for the 1st 2 years, let's take the my age variable and subtract two from it and we're gonna set the result equal to Variable called later years. So later years equals my age, which we have set to 25 subtract to. So now let's move on to step five. We're gonna multiply later years, variable by four to calculate the number of cat years accounted for by your later years, we're gonna use the multiplication assignment operator again to multiply in a sign in one step, I will say later years times equals four. So now this is a good time to check to see if we're getting the values that we would expect . We've already printed the value of early years and we know that's 50. So let's go ahead and print the value of later years. When we run that code, we get 92. And so we know that later years was my age, which was 25 minus two, 23 and then 23 times four, which is 92. Okay, so are variables were producing the values that we would expect OK, on to our next step. We're gonna add the value of early years and later years together and store that in a variable named my age in cat years to my age and cat years is equal Teoh early years plus later years. All right, we're almost done. Let's move on to our next step. We're going to go ahead and send the value of whatever your name is to a variable called my name. So my name and I'm go ahead and set this sequel to a string of Rob Okay, that sets us up for our last step. We want to print a string that says my name is name and name will be the value over variable My name I am human age, years old and human age will be set to the value provided by my age years old in human years which is cat age which is the value of my aging cat years years old in cat years. And so we're gonna use drinking. Can't nation to put all of this together so we'll go ahead and start off with a keyword print. This is the printer function, and we'll start a string with my name is the value of my name, which we know is the string rob, plus a period that's going to go after my name. I'm going to continue the string. I am no, have a space plus and we want to contaminate the value of my age, which is the number 25. So you have to do str and then within the prenda my age. Then we'll continue the contamination years hold in human years, which is and it will contaminate the value of cat age, which is a number cat age, which is my aging cat years. And this is a number to use str and pass in my age and then we'll continue our string years old and cat years to make sure that my print function has a closing perent. And let's go ahead and run our code. My name is Rob. I'm 25 years old and human years, which is 142 years old in cat years. So apparently even at the age of 25 in human years, you're still gonna wind up with a really old cat. All right, let's go ahead and just quickly walk through this code. We created a variable called My Age Toe Hold our age. We then created a variable early years instead of equal to two. And we did this to account for the accelerated growth of a cat, which is 25 years for each of the 1st 2 human years. So we set early years and use the times equal operator to multiply, too by 25 to get the number 50. We then needed a later years variable to determine how much a cat is going to age after those 1st 2 years of accelerated growth. So we took our my age in this case 25 subtracted to you wind up with number 23 and so we had to multiply our later years, which is the number 23 by four, because that's the rate of growth for a cat after the 1st 2 years of accelerated growth. Finally, we were in a position to determine our age and cat years, so we created variable my age in cat years, and we said it equal to early years, which was 50 plus later years, which was 23 times for which I believe is 92. Then finally, we created a variable called my name and assigned a string value of whatever your name is. And then the final part of the challenge was to print a string that says My name is name. I'm human AIDS, years old in human years, which is cat age, years old in cat years. So we used the print function we passed in the string. My name is plus my name, which was already a string. And then we added to that another string with the period I am. And then we added my age, which is a number, so we had to convert it to a string. And then we added the string years old in human years, which is and then we added the value of my aging cat years that we had to convert to a string. And then finally, we close this off by adding by contaminating on the string years old and cat years. All right, that's it. Great job in this challenge. If he struggled with any part of this challenge, go ahead and give your coding, sandbox and name, and then you can go ahead and save it. And then you can share the link in this mini APS Q and A or in the previous walk through lesson, and I'll take a look at your code. All right, great job, and we'll see you next time. 16. Function syntax: Okay, so we've already taken a brief look at functions. Let's imagine that you work with the weather warning alert team in your city. Let's imagine that you need to put up winter warnings for when the weather turns back. Let's imagine that we want to print this message right here. Winter warning temperatures will be below zero. Make sure to bring your pets inside. Now. We could accomplish this with print statements we could print Venture warning Prince Temperatures will be below zero and then finally print. Make sure to bring your pets inside. When we run our code, we get the exact results so we would like. But let's imagine that we had to print these warnings for several different locations throughout your city. Well, one way to do this as we could copy all this code, we could paste it in again, tested and again and paste it in again to place this sign all throughout your city. And we do get the results that we would like What is taking a lot of code that we're repeating ourselves with it? Functions are great for the coating principle of dry. Don't repeat yourself so there's a better way to do all this. We're going to create a function. So I'm gonna go ahead and delete these repetitive lines of code up above line five. I'm gonna go ahead and create a function. I'm gonna use the key word death. This lets the Python interpreter know that we're creating a function. Then when a name, our function winter, whether alert. Then I'm going to use open and closing Torrens that I'll leave empty and then close this out with Colin. Now, we'll look at the syntax more in depth in a future lesson. But for now, we're gonna make sure that we in dent all of these lines of code to let us know that these lines of code belong to this function. So now if we run our code, what we find is that nothing happens because we need to tell our Python interpreter that we actually want to run this function that prince thes strengths. So the way that we do that is, we type in, we'll name our function winter, whether alert and then to call our function, we use these opening and closing prints. This was the python interpreter. Know that we want to call or run dysfunction. Click run! We see what your warning temperatures will be below zero. Make sure to bring your pets in sight. Remember, I said you might want to print out multiple of these science and post them throughout your city. We can do that by simply typing winter weather, color quencher, weather alert and then finally, winter, whether alert and so we can see that we're calling our function four times. And when we run our code, it runs our code four times in a lot less. All right, now that we know this, let's go ahead and take a look at our challenge. This one should be pretty straightforward. We're gonna call the song function once, and then when I call this song function again just to get used to this principle within our song function, we have four prints statements that we're going to print. So it's a song, and then we call our function with these opening and closing Torrens. So let's run our code and we can see that it prints are songs we would expect one time. Now let's go ahead and call our song a second time and we can see that it has called our function one time and then a second time. All right, great job. Let's go ahead and move on to our next lesson where we work on writing our first function. 17. Function syntax p2: all right. And this. Listen, we're gonna take a deeper look at function, syntax and running your first function. So previously we looked at a song function and learned how to call it. Now let's learn how to build functions are cells. Here's the basic syntax for a function. Notice that we start with the death keyword. This leads python interpreter know that we're creating a function. Then we provide a function name. In our last example. It was the name song. You follow the function name with parentheses, opening and closing parentheses. These can be filled with parameters, which we'll talk about later. And then finally, after the parentheses, we have a colon. This next part is important. In the following lines. We have the code that belongs to our function. It's important that this code is indented. This is how the Python interpreter knows that this code belongs to this function. And so you may have to be careful. If you're copying and pasting from the notes of this course into this input, you may wind up with some spacing issues that may create some syntax errors for you, so you'll just have to keep an eye on that, and you may have to type things by hand. If you feel like copying and pasting into this input is creating any sorts of theirs for you. Let's go ahead and review functions in tax for more time. Looking at her function from last lesson, we have the deaf keyword again this. Let's Python know that we're creating a function. Then we have a named function in this case, Winter weather alert. Been opening and closing prints. Then finally, we have a cooling and our next three lines. We have invented print statements again. This lets the Python interpreter know that these lines of code belong to this function. Then finally, to call our function, we name it and then we use the opening and closing Prentice's to tell python toe. Run this All right. Now, with that review in place, let's go ahead and take on our challenge. In our challenge, you're going to read a function called Neighborhood Greeting that prints the string. Welcome to the neighborhood, and then you're gonna make sure to call your neighborhood greeting to print that to the output. Okay, so we're gonna use the death keyword to declare our function to the Python interpreter, and we're gonna name this neighborhood greeting. And then when the user opening, closing prints and then the corn. Next, when we hit the enter key because you that were indented on the next line and we're gonna print this string. Welcome to the neighborhood. Now, if we run our code, nothing should happen because we haven't called our function yet. So to do that, we simply Neymar function. And then we use the opening and closing parentheses to call our function. We click run. We see that we get the string. Welcome to the neighborhood. All right, great job in this challenge and we'll see you next time. 18. Function whitespace: all right. And this lesson, we're gonna continue talking about the topic of a white space. We briefly brought this up when we talked about the concept of inventing your code within a function you can think of. The white space is the space between characters. Some programming languages, for the most part, pay no attention to white space. However, in Python, when we're dealing with functions, white space is incredibly important. So let's imagine that we have this winter weather alert function that we've created, and we've added 1/4 line. Keep everyone wants online. Seven. We call our function. It prints these four statements. Once you're warning, temperatures will be below zero, make sure to keep your pets inside, keep everyone or so now, let's go ahead and take a look at what happens when we on indented a line of code, and we have removed its white space. Now when we call our function, what we find is keep everyone warm. The fourth print line of our function actually printed independently in the output. It's sitting on top, so it printed first. The Python interpreter started online one and said, OK, we have a function that's going to print these statements. Great. Next line of code line five buds print. Keep everyone wore. So there it ISS and then we get to line seven. That says, Oh, OK, let's go ahead and call this winter weather alert from line one and run these three prints statements. Once you're warning, temperatures will be below zero, make sure to bring your pets inside. All right, now that we've taken another look in regards to how white space works, let's go ahead and take a look at this lessons challenge. All right, we're going to call a function Words that start with B. This already exist. When we run it. We see that we run for print functions bears, beets, Battlestar Galactica and oranges. One of those prints statements doesn't really belong this function. Let's go ahead and un invent that code and then call our function again. When we do, we see that oranges moves the top of her output, which means that it's not being printed inside of our words that start with B function again just to show you how the Python interpreter thinks a sees line one that says Cool. We have a function called words that start with B and by looking at the in debt that knows that these three front lines belong to that function. So it stores that. Then in Line five, we see that python. It's the message trying to oranges. So it does. Then online. Seven. We see words that start with B. Python sees this named Function and the opening Closing Friends, which tells it that it's now time to run this function. Words that start with B and we run or three print functions to produce, bears, beats and bolster Galactica. All right, great job in this challenge, and we'll see you next time. 19. Arguments and parameters: Okay, So we've looked at in the past imagining that you worked on the Winter Weather Alert team in which you wanted to alert your city if there any bad winter weather conditions. Let's suppose we wanna have a little bit more flexibility in this signs that we create because maybe we don't want to just alert our city of winter weather problems. But any weather problems? So it's do that. Let's go ahead and let's create a function called any whether alert now within our friends , we're going to go ahead and do something different. We're gonna pass in parameters. We're in the past in parameters of season temp and action, and this is gonna help to give our sign that we print some flexibility. So now let's go into our code that we went to print. When are any weather alert function is called? So we're going to print, and instead of saying Winter, summer, spring or full as a string, we're simply going to say season, and we're gonna let the user provide this season that we want to display. Plus, and then we'll have the stream warning so our next line of code will say print and want to say temperatures will be instead of saying zero degrees Celsius for a winter warning or over 100 degrees for a summer warning, let's simply say, Champ, and let that temp be provided. And then finally, in our third print statement, we're going to say, Make sure Teoh, instead of saying, Bring the dogs inside or drink lots of water Well, simply add action, which will get its value from the action parameter. So we have three parameters season Tim in action, and we can see where each one of them is being used within our code. This means that when we call any, whether alert if we don't provide any values, we're going to get an air because it's now expecting these. Now. These values that we pass in are oftentimes called arguments. The arguments are what fill in the values for these parameters. So our first argument is going to be summer, which is now going to be our argument for the season parameter. Our next argument is going to be the string above 100 degrees. That's going to be the argument we passed into the temp parameter and then finally the strain go swimming. This is the argument passed into the action parameter. So when we run our code, we get summer warning. Temperatures will be above 100 degrees. Make sure to go swimming. Awesome. Let's go ahead and call this again. Let's imagine it's spring time. So it passed in the string spring. That's our argument for season, and then we'll pass in an argument of a pleasant 75 degrees. That's our argument for a temperature. And finally, an argument for our actions will be not panic. As you only run our code, we get spring warning temperatures will be a pleasant 75 degrees. Make sure not to panic. All right, now that we've had some experience with arguments that we pass into our parameters, let's go ahead and take a quick look at a challenge. We have a function my favorite color, and it needs a color parameter added to it to print the string, my favorite color IHS, And then we're going to call the function with a string passed in as an argument for the parameter. So the first thing we need to do is add a parameter, and I'm just going to say color this could be X. It could be it could be easy. It could be whatever. But we want to make our code human readable. So I'm gonna just say color as the parameter. And then whatever color is, we want it contaminated to our strength. So my favorite color is, and then we print our color. So now if we try to run our code right now, we're going to get in there because we're missing one required positional argument color. So now if we say brown, this is our argument that we're passing in your parameter color we should have. My favorite color is bring That's right code Great. Let's try this again with blue and run our code and then orange and run our coat and it works every time is we would expect All right, great job in this challenge and we'll see you next time 20. Bear human gun: all right in this lesson, we're gonna go ahead and look at the bear. Human gun. Many applications. If you have any troubles with that challenge, that's fine. We'll go ahead and walk through this step by step so you can begin with me in the beginning . Or you can afford in the video to the place where maybe you got stuck trying to implement this application on your own. Now the bear human gun is just like rock, paper, scissors. Each player chooses other bear, human or God, the items air compared. Each player chooses either bear, human or God items air compared and whichever player chooses the most powerful item wins, so the possible outcomes are bare malls, human, human disarms, gun or gun shoots bear. If there's a tie in, the game ends in a draw. All right, so let's go ahead and get started. With our many application, I might go ahead and just create a new environment, and I'm gonna call this there versus human verses you got. You call this whatever you like. You can save it so you can make sure that you can share this code. If you did get stuck anywhere so we'll go ahead and get started. I'll go through this step by step according to what was in the challenge. So let's go ahead and start with. Step one were to create a function named get User Choice, and it's to have the parameter of user input. So we'll go ahead and start with the death keyword. They won't name or function, get user choice and will pass in a perimeter of user input. We put our seven Colin, and now we can go ahead and go into the body of our function, and that takes us to step two. Since the user can pass in a parameter such as bear with a capital B or bear with the lower be, we want to make sure that Python sees those as the same thing. So the way that we will do that is we will go ahead and say that user input, whatever has been passed into the parameter user input, is going to be equal Teoh user input and then we'll use the lower function on it. So that means capital B bear is the same as lower case. Be there. Okay, that takes us on to step three, we're still gonna be in the body of this function verifying that the user has submitted their human or gun. If they have, we're going to return that user input which will be available to use. If the user hasn't provided bear human or gun, then we're gonna print than error has occurred. Before we do that, I'm gonna go ahead and add a comment to this line that says that we're going to turn future user input to lower case. Okay, Now will say if there is a match return user and put else return a message that says something like, Please enter a valid option. Who will say if user input equals bear or user in play equals human or user input equals gun. If any of those air true that, we're going to go ahead and return user input. If that's not true, we use an else statement and we'll simply return. Please enter a valid option. Okay, so now we'll go ahead and test our function. We'll test it with valid and invalid inputs. So it's a print animal. Passen get user choice and then my passing a bear, which is a valid option and run our code and we get there. If we do bear with a capital B, this should work as well, because user input should be turned to lower case and we get there again. Okay, Now, let's try printing an invalid option. So instead of there will spell this b a r e a different kind of bear and run our code and we see that the output is please enter a valid option. Okay, so it looks like our function is working as you would expect. Let's go ahead and move on to step five. Now, we need to have the computer make a choice. To do that, we're gonna have to pick a random number, and then we're gonna create a function that will provide a random computer choice for each round. We're going to create a new function named get Computer Choice, death yet computer choice. And we're not going to give it any parameters. The first thing we're going to do is we're going to get a random number, and this random number is going to be between zero and two. Now, let's go ahead and take a look at how we can do this for step number five. We see that we should import the math and random delivery. Someone go ahead and do that real quick before we forget. Now, let's go ahead and import random library import random. Okay, I'm gonna go ahead and just opened a new sandbox environment, and we're gonna look how to use. Both libraries did choose a random number between zero and two. So first, let's get a random number. We can do that by using the random library. I might go ahead and print all of my results so we can see the output that we're getting. So if we use the random library and we use that uniform method and we choose a range of zero and three, what's gonna happen is, every time we run this code, we're gonna get a number between zero and three. Now it's going to be a decimal, and we need a whole number. We need 01 or two. So the way that we can do that, as you've seen before, is to use the math dot floor method, the math that floor method is gonna find an insecure that is less than or equal to the current value So if we say math thought floor and then we pass into it our random thought uniform method that we passed in June and three. When we run our code, we see we get to one zero zero zero to and so this has given us a random number of 01 or two. So this works just fine. So I'm gonna go ahead and copy this code, and we're gonna go ahead and declare a variable random number and set it equal to that code the math 0.4 method that we've passed in math that uniform with the numbers zero and three . Okay, so now it depending on the number, we're going to return either bear, human or gun. We can simply use if statements for this logic, we can say if random number equals zero, then we're going to return there. We can say if random number equals one return human. If random number equals two return gun. Okay, so our next step we can go ahead and test this function by printing it out. So say, print, get computer choice. We'll make sure to call the function there. Now let's run our code. Be a human gun there. They're human. So it seems to be working as we would expect. I'm gonna go ahead and delete this line of code and we're on to step seven. We're now going to determine the winner. We're going to create a function determined winner and passing parameters. Use your choice and computer choice so my go ahead and create some space. Well, say death, determine winner, and we're passing our parameters of user choice and computer choice. And this function is going to compare two choices and then return if the human player one lost or type. So let's deal with that tie condition first. Within the determined winter function, we're going to write an if statement that checks of user choice parameter equals the computer choice parameter. If it does, we're simply going to return. It is a tie. Next, we're gonna look at what happens if the user selects human. If the user selects human. If this happens, then if computer choice equals bear, then we're going to return. You have been mauled by a better else, which means that gun has been chosen. We're going to return. You have disarmed a gun. Okay. Next, we're gonna look, if user choice equals bear, if that's true, then we're going to say if computer choice equals gun, then we're going to return. You have been shot by a gun else, which means the computer choice was a human. We're gonna return. You have mild a human. Okay, now, we're gonna look at the last possibility if the user selects gun. So if either choice equals gun and that scenario, we're going to say if computer choice is human, we're going to return. You have Ben disarmed by a human else, which means the computer choice was a bear. We're going to return. You have shot a Okay, let's go ahead and see if this function is working, as we would expect, we'll go ahead and print out some results. So let's print determined winner, and we're gonna pass in a user choice in a computer choice. So the user choice will say is a string bear. And then we'll say that the computer choices a strain gun. Now we know in our scenario, we expect the gun to beat the bear. So let's run our coat. There we go. You have been shot by a gun. Let's test out another scenario. Well said the user choice was a human. Now, when a human takes on a gun, the human should disarm the gun. What's ruin our code? You have disarmed the gun. Okay, so it looks like our function is working as we would expect. Okay, so everything is set up as we would expect. Now, we just need to create our play game function to play our game. So credit function, death play game. It's not to take any parameters. The first thing we need to do is to prompt the user to make a choice. So we're gonna create a very bull called trumped user choice, and we're gonna go ahead and set it equal to input. Please choose bear, human or gun. Now, the next thing you want to do is we want a format user choice to lower case and check for a valid word. The great thing is, we've already created this function. So we're just going to create a variable user choice. And we're gonna set it equal to get user choice, which is what lower cases and checks for valid words. And we're gonna pass in prompt user choice. What the user has provided. Next we're gonna call, get computer choice and assigned to a variable computer choice. So computer choice is equal to get computer choice and will make sure that we call that function. That's what's going to give us. They get. Computer choice is going to be what gives us bear human or gun. Now I want to make sure that those were working as I would expect. So I'm going to go ahead and print user choice, and I'm gonna go ahead and print computer choice now just call the function, and when we run it, we can see that it's asking for bear, human or gun. So I'm just gonna type in there and then we can see that it is printing user choice and computer choice as bear there. But we don't see any results, and that's because we haven't called The Determined Winner function yet, So we'll jump back into our play game function that we're defining, and we're simply going to print, determine winner and we're gonna pass in user choice and then computer choice, which we know is you ran our code earlier was bear there last time we ran our code which would have resulted in a type. But because we're gonna allow the user to input a new choice and the computer is going to make a new choice, it will be new results each time. So let's go ahead and run our code. We can see that's asking for a human input. So my go ahead and type in gun in all caps, which should be about term. And we can see that user choices gun computer choices bear you have shot a bear. Great. Let's go ahead and run our code again and I might put in invalid term. We'll put in Rocket and we could see that we got please Interval adoption for user choice. Computer choice was bare and we had no results to print for determine winner function. All right, that's it to this challenge. Great job, and we'll see next time 21. Calorie calculator: All right, so in this lesson, we're gonna walk through our calorie calculator. Many up this money app is gonna be based on the calorie recommendation of about 2000 calories a day. I'll show you within the app where you can actually change that number. If you'd like it to be more or less to customize it to your needs and this money up, we're basically going to calculate whether the calories you A all week were greater than what is recommended. If you eat, just the right amount will print out a message that says you wait just the right amount. If you ate too many calories, we're going to send a message that suggests getting a good workout in. And if you didn't eat enough calories, we're gonna recommend that you go get seconds. All right. So I'm gonna go ahead and walk through this challenge step by step. Okay. Step one is going to be to create a function named input calories by day, with the single parameter of day. This is gonna return any givens days, number of calories consumed. It will accept an argument of day and return a number. So say death input calories by day and, as we said, accepts a single parameter of day. Now step to the function should accept the day as an argument and return the number of calories you consume. So, for instance, if you consumed 3500 calories on Monday night, calling input calories by day and passing in the string Monday should return 3500 so we can use if else statements to accomplish this. So we'll say if Day equals Monday, if that's true, and in this example we're going to return 35 100. So now let's go ahead and accounts for Tuesday. If day equals Tuesday, then we're gonna go ahead and return, and you can choose how many calories you have bus Tuesday so I might say, 1800. Now let's move on to Wednesday. F Day equals Wednesday. Then we're gonna return. I'll say 1500 calories. Maybe I look ate a little less. F Day equals Thursday. Gonna go ahead and return 1700 calories, and if day equals Friday, I'm gonna go ahead and say return 2100 calories. FDA equals Saturday that I'm going to return 2400 calories and then Finally, if Day equals Sunday return 1400 calories. If none of those values are passed in as the day, then we'll simply say else return, please submit. Invalid. Okay, okay, So now let's go ahead and let's test out our function to make sure it's working as we would expect. So we're gonna front input calories by day and let's pass in Monday. So our argument of Monday is being passed into the parameter of day, which should match this if statement. So let's run our code. Oh, and we could see a couple quick syntax errors that I made didn't have a double equals for Saturday or Sunday. So now let's run our code again and we get the number 3500. So let's try this again on Tuesday. We run our code 1800 when this day we're in our code and get 1500 Justus, we would expect. Okay, so that function is working great. Let's move on to our next step. We're going to write a function, get total calories that returns the value of total calories consumed in a week. So it's a death get total calories, and within that function, we're gonna call input calories by day for each day of the week, and then we're gonna add the results together and return the some of those. Now. Chances are you could do all of this in your head, but we're just learning how Python works, So this is an exercise worth doing. Two will return input calories by day. It will pass in Monday, plus input calories by day and will pass in Tuesday. Plus, So I've gone ahead and added all of our calls to input calories by day function and passed in our days of the week, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday, and those are all now being returned. So let's go ahead and make sure function is working as we would expect. It will print get total calories, and we have to make sure to call our function. And when we run this, we get 14,400 calories. That's how many calories we recorded as consuming during the week. Now you can go ahead and change is hard coded values, if you would like. So now that we know this function is working as we would expect, let's go ahead and move on to our next step. We're going to create a function called get ideal calories, and this is going to return the value of the total ideal calories consumed in a week. So we're not gonna pass in any parameters. We're going to create a variable called ideal daily calories, and we're gonna hard code this value to 2000. This is a common number. We could create this as an input that allows the user to input the ideal daily calories and have that value be a little bit more dynamic. But for the sake of this mini application, we're gonna go ahead and skip over that possibility. Oh, for the sake of this money application, we're gonna go ahead and leave this as it ISS, and then to get a weekly ideal calorie count. We're going to return ideal daily calories. Times seven is going to give us 2000 times seven. Okay, now, let's go back and make sure everything is working as you would expect, So let's print are get total calories function, and then let's also print our get ideal calories function. When we run both of these, we get 14,400 which is the total calories that we consumed and that deal weekly calories of 14,000. So we know both of those. So now it's time to move on to our next step. We're gonna check if what we ate was equal to more or less than what we should have. And then we're going to respond with what the person should do more of next week. So we're gonna create a function called Calculate Health Plan. I'm not gonna pass in any parameters, and we're going to set actual calories equal to get total calories function, which we know is 14,400. And then we're gonna say ideal calories is equal to get ideal calories as a function which we know was 14,000. And now it's time to create some. If statements, we're gonna ask if the amount we ate was equal to them out that we should have eight. So we'll say if actual calories is equal Teoh ideal calories. If that's true, then we're going to print you a just right amount of food. However, if the actual calories was greater than the ideal calories, which means that you ate too much, we're going to print time Teoh head to the gym. And then finally, we're gonna say if ideal calories was greater than the actual calories, which means you ate less calories than you consumed, then we're gonna go ahead and print time for seconds. Okay, now our last step is simply to call or calculate health point. Okay, so let's run our code, and we get time to head to the gym. This is because, as we looked at earlier, our calories consumed was 14,400 and the recommended calories was 14,000. Now, if you think you're someone who burns more calories than 2000 day, you can change his heart code in number from 2000 to 2500 and we could run our code, and we can see that it's actually time for seconds that you didn't eat as much as you should have. Now, if you want to add more interaction to this many application, instead of hard coding the daily calories consumed, we can create an input for the user to provide that information to excite input. Please provide daily recommended calories. Now the only thing we need to now do in our return statement whatever value was provided in this input. If we put in the number 2000 it's actually going to become a strength. And so if we say 2000 ideal daily calories equals the string 2000 in the string 2000 times seven is 4000 2000 4000 in a row. It's a string. It's not a number, so we need to return. And so we need to use the int method and passing our ideal daily calories. They'll take that string of 2000 and convert it to the number 2000 ton seven, which is 14,000. Okay, so let's go ahead and run our code. So please provide daily recommended calories. Well, say 2000 and we get a message time to head to the gym because we know that we consumed 14,400 calories from earlier. If we switch that and we say that our daily recommended calories are 4000 and then we run our code, we can easily see that it's time for seconds to about of that extra flexibility of user input. All right, great job in this many application and we'll see you next time 22. Lesson lists one: alright in this tutorial, we're gonna go ahead and look at list. A list is a dad destruction python that is immutable or changeable ordered sequence of elements, each element or value that, instead of a list is called an item just the strings or defined characters between quotes less or defines having values between the square rackets. Let's are great to use when you want to work with many related values. They never you to keep data together that belong together condenser code and perform the same methods and operations on multiple values at once. When thinking about Python List and other data structures that are types of collections, it's useful to consider all of the different collections you have on your computer, your assortment of files, your song playlist, your browser bookmarks, your emails, the question of videos you can access on a streaming service and more so let's go ahead and get started. Let's create a list that contains items with the strain data type, so I say, see creatures we're gonna set it equal to. And remember, A list is gonna have value between these opening and closing square brackets, and we'll add our strings for sea creatures. What a shark, cuttlefish, squid, Mantis, shrimp and finally would do in an enemy. All right, so that's our list sea creatures. And we know it's a list because we're these opening closing brackets, and inside the brackets we have elements. In this case, each element is a strength. So let's go ahead and print sea creatures. And when we dio, we see that we have short cowfish. Would Mattis, shrimp and an enemy, so to review as an ordered sequence of elements, each item in a list could be called individually through indexing. Well, look at this in the future. Lesson lists are compound data type made up of smaller parts and are very flexible because they can have values added removed and changed. When you need to store a lot of values or iterated over values and you want to be able to readily modify those values, you'll likely want to work with list data types. And those are all things that will do in future lessons. Okay, so let's go ahead and take a look at this lessons challenge. All right, we're going to declare a variable land creatures and has a list we're gonna add the strings cat, dog, monkey, bear and dress. So let's go ahead and say the land creatures. I'm gonna set it equal to being an array. So we have these opening and closing square brackets, and then we're gonna fill the elements with strings in this case, chat dog monkey there and then finally dress in. Our last task is simply just to print our list of land creatures. And when we run our code, we can see that we've printed our list successfully. All right, great job, and we'll see you next time. 23. Lesson lists two: in this lesson, we're going to go ahead and look a indexing list. Each item in a list corresponds to an index number, which is an integer value, starting with the index number of zero. So if you need a programming, this might be a little bit unusual to you. As you're used to starting to count with one both computers and programming languages, you'll see that the counting begins with the number zero. So shark, The first item in our list is that index zero cuttlefish. The second item in our list is an index one squid. The third item is that index to Mantis shrimp. The fourth item is that index three and then finally an enemy. The fifth item is that index, for because each item in a Pathon list has a corresponding index number, were able to access a manipulate lists in the same way we can with other sequential data sites. Now we can call an individual item of the list by referring to its index number. So let's imagine that we want to print cuttlefish. Let's go ahead and use the print function, and within that, we're gonna say see creatures, and this means we're referring to are sea creatures list, and we're going to use these opening and closing square brackets and we want to train the cuttlefish. Where's the cuttlefish in our list? It's our second item, But remember, we're thinking like a computer. So shark is that Index zero cuttlefish is that Index one? So go ahead and use the number one and we'll print our code and we can see that cuttlefish is the results. So let's look at this a couple more times. I might go ahead and copy and paste to feel these and let's go ahead and switch this to zero. And then I'm going to say, Shark, the shark should be sea creatures at Index zero because it's the first item in our alright . If we wanna print cuttlefish, which we already looked at, it was a sea creatures at Index one squid. It's sea creatures at index to because it's our second item. Next we have Mantis Trump that's gonna be sea creatures and index three because it's the fourth item. And then finally, the fifth item, an enemy is that index of four. And so I'm gonna go ahead and just type in an enemy and let's print our results. And we were able to successfully print shark cuttlefish squid matches trip in an enemy as we would expect. So what would happen, though, if we try to print, see creatures and we'll say at Index five because maybe we made a mistake and we forgot to think like a computer. We saw an enemy was the fifth, you know, item in our list. And so we decided to put the number five in here, said the number four. If we're to do that, the responses we get an air list index is out of range because there's no item at the fifth Index spot. Another way that we can access our values is by using negative numbers. Let's say we wanted to print out a squid. Now we've seen that we can do that by saying Sea creatures list index to, but if we were to use a negative number, it's a little bit different. Good. Start counting at the end. Instead of starting to count with zero at the end, we actually start to count with one. How you normally think of counting so an enemy would be negative. One. Mantis shrimp would be negative two, and then squid would be negative. Three. So let's go ahead and try replacing the number two with negative three. And when we run our code, we see that our squid is still a squid. Okay, I'm gonna go ahead and delete this line seven because we don't need it. And so really quickly. If you want to access the shark, I would say it's negative. One nighter to negative three. Negative four. Negative. Five. The cuttlefish is gonna be negative for We've seen that the squid is negative. Three. The Mantis shrimp is gonna be negative too. Then finally be an enemy in the first spot is gonna be a negative one. So when we run our code, we get the results that we would expect. Let's go ahead and take a look at one more thing. Well, you can. Katyn ate a string item in a list with other strings using the plus operator so we could print. Sammy is a then we'll closer string. Well, can cabinet on our list, see creatures and will say our first element at index zero. So we can now run our code. Now we can see that this works just fine. Sammy is a shark. All right? With that knowledge, let's go ahead and jump into our challenge for this challenge. We're simply going to follow the directions in the comments. So now we want to print on Lee the cat in our land creatures list. Short cat, is that index zero the first item in our array. So you can print land creatures at index zero. We can run our code and we can see that we have our cat. Next, we want to print our dog. That's gonna be at land creatures. And it's the second item in our array, which is index of one, and we can run our code. And now to speed things up, go ahead and copy this and paste it a couple times. And to reach our monkey, which is our third item, which is our second element, we use the number two to get our bear, which is our fourth item. But our third element use index of three. And then finally, to get our giraffe, which is our fifth item, it's gonna be a index afford so we can run our code and we're getting everything that we would expect. Now, finally, we want to print the sentence. My favorite land animal is the dog. So use the print function. And within that a string. My favorite land animal is the and I'll add a space right there. And they were in the Cabinet on our dog from our lists. So do that by saying land creatures. And we're to know from Line seven that we can access this with an index of one. So go ahead and run our code. Now we get my favorite land. Animal is the dog. All right, great job in this lesson and we'll see you next time. 24. Lesson lists three: All right, so in this lesson, we're gonna go ahead and look at modifying items in lists. Working is indexing, which we just learned to change items within the list by setting an index number equal to a different value. This gives us greater control over lists as you were able to modify an update that items that they contain. Let's imagine we want to change our second item at index of one from Cuttlefish Octopus. Here's how we might do that. We will name our list and then we want to modify cuttlefish, which is that Index one. And we want to change it to the value of part of us, and it's just that simple. Index one previously was cuttlefish, and now we're setting index one, the Octopus. So now if we go ahead and print sea creatures and we run our code, we see that octopus is now Index one. Now, as we learned in last, listen, we can also access an item using negative numbers for the index. So let's imagine we want to change squid. Just something like blob fish. I would say sea creatures, and we know that squid is that index 012 using positive numbers, but we want to use negative numbers. So we started the end. And remember, when we start the end, we don't start with zero. We start with negative one. So negative one negative, too negative. Three. So I say, negative three. And now we'll set our value to love fish. Okay, so now let's go ahead and print our list. Sea creatures. And when we run our code, we see our octopus that we change from cuttlefish, the octopus index of one. Then we see our blood fish index of negative three. Being able to modify items and lists gives us the ability to change an update lists in an efficient way. Now, let's go ahead and take on this lessons charge. We're gonna go ahead and just follow the directions in the comments, and we're gonna change index values in the land creatures list so we can see that land creatures. We have our list of cat, dog, monkey, bear and giraffe. And our first task is to change dog to pig and print land creatures to make sure that our change has taken place. So I'm gonna go ahead and say the land creatures and we want to change a dog, which is that Index zero one. And we're gonna set equal to the string. Hey, now, go ahead and print land creatures. And when we do, we see that dog has been replaced with pig. Okay, Our next challenge is gonna be to change, bear to Lyon and then to print our list to make sure that our changes taking place. So it's a land creatures. And there is the fourth item in our array, which is 0123 or counting from the end. It's negative one native to so just to change things up And when I go ahead and say negative too, and we're gonna set that index item to Lyon. So go ahead and print land creatures. And when we dio, we see that in our second array, that bear has been swaps with Wyatt. All right, great job in this lesson and we'll see next time 25. Lesson lists four: all right. And this. Listen, we're going to go ahead and look at slicing list. We've seen how we can call our items on individual basis. Let's say we want to access multiple items at once. We can do this by creating a slice. We can call multiple values by creating a range of index numbers separated by a colon. X indicates the first item that we want to access. Why indicates the item up to what we want to access, but not including that item itself. So let's say we want to access cuttlefish, squid and Mantis trip if you go ahead and use the prime function and we could say sea creatures and we want a print Cuttlefish squid in Mantis shrimp. So they're opening closing brackets. Cuttlefish Index one is the first item in our range, and then we also want to print Mantis shrimp. So is zero one to three. It's that index three. I'm gonna show you the wrong way to do this. We could put in the number three, and when we run our code, we're not going to get matches shrimp, because this Y value means that up to, but not including so when we said three one or 0123 we're saying up to, but not including matches shrimp. So instead, we want to say four up to, but not including an enemy. And now, when we run our code, we have cuttlefish squid in magistrate were able to print items at index 12 and three. If you want to include either end of the list, then we can simply omit the number in the X or Y side of our syntax. So, for instance, um, I go ahead and delete this line. And if we did print, we said, see creatures put in our square brackets instead of putting in 012 or three to where we want to start accessing our elements in our lists, we put a colon. If we do that that we know we're automatically starting with the first item. If we don't put anything there, and if we put the number three, that means that we're saying we want to include everything up to, but not including index number 30123 So not including Mantis shrimp, which means this should print shark, cuttlefish and squid. Let's run our code great. Now let's go ahead and switch this around. If we do provide a first number, let's say we want to start by accessing our squid. That is, that index 012 to put into because our first item actually includes that item is not too. And then we'll leave this value empty, and that means we're going to go to the end of our list. So if we run our code, we should get squid match a shrimp and an enemy. So when we run our code squid matches shrimp and an enemy, and now let's quickly look at what we've also learned that we can use negative numbers and slicing our lists. So if we're just saying negative four and negative too, what do you think would happen? We're saying Negative four is where we want to begin slicing our array. So negative one negative to negative three negative four. So we're starting with cuttlefish, and we're ending with native 19 native to which means up to, but not including our Mantis shrimp. So we should get cuttlefish and squid, run our code cuttlefish and squid and the same deal as before. If we leave either side of this empty than in this case. We're gonna access everything that comes after a negative three. If we leave our first option empty and then we fill in our last item, that means we're going to begin with the beginning of our list and print everything up to, but not including our item at the index of negative, too. Okay, now let's go ahead and switch things up a bit. Let's imagine we have a list of numbers. 0123456789 10 11 12 And let's say we want to you get a slice of our numbers list, but we don't want to print all the numbers. We just want to print every other number. We can do that by adding another number. Tour Square Index. So here's what that looks like. We could print numbers, which is the name of our list. Can we ever square brackets and we can put in the number one, which means we're gonna begin with the item at the index of one. So zeros index of 01 is index of one, and then we're going to say we want to include all of our elements up to, but not including our element at index of 11. So 0123456789 10 11. So up to. But not including 11. Let's run this code. And when we do, we see that I forgot an S in numbers. So it's runner code again and we get 123456789 10. Now let's imagine that we want to print every other number from that slice. We would simply do that by adding an extra colon and to soon only run our code instead of one through 10. We get one, 357 Nice if we changes to three and run our code 147 and 10. Now let's say we didn't want a slice our code and just start at a certain point or industry in point. We could actually leave these 1st 2 items blink, and when we run our code, we start with 0369 and 12. We get every third number, okay, armed with this information, let's go ahead and jump into our challenge. We have a list of letters that goes all the way through our alphabet from a dizzy, so we'll go ahead and follow the directions in the comments. Initially, we want to print letters a through D, so we'll go ahead and take a look at a couple ways to do this. The first is we could say print letters and then we'll start with zero because A is the Index zero and then we want all the way up to the letter D, which is index 0123 And then we went up to, but not including E, which is that index for. So go ahead and do that and run our coat and we get A, B, C and D. And here are two other alternatives you could take a look at and implement on your own. If you want to test those out there to other ways, we've learned of using slices. Now, in our next challenge, we want to print letters, see through us. So print letters and then see is that index to so we'll say to and then F is an index 012345 So we went up to, but not including G, which set index six. We'll go ahead and run our code, and we can see that we get C, D. E and F. Now, if you like to you composite video and see how we could do that with negative index numbers , our next challenge is to print M through Z. I will do that by saying print letters and M is a induction 12 and we're gonna go all the way to Z. And so we'll say up to, but not including Index 27. Let's run our code and we can see that we've accessed M Through Z. If you'd like, you could pause the video and take a look at these other two implementations of this online . 15. I mentioned using the negative index numbers for each of the challenges above which I've listed so you can pause the video and go over those to make sure that you understand that correctly. And finally, online. 17. We're gonna print a d g J m p sed White. Now, how might we do that? A. Is the first element in our list, which is that Index zero de is an index. Four g is a index 56 seven Jay is a index 89 10. So it looks like we're beginning at the start of our list and then accessing every third element. So we can simply do that by saying print letters. We name our list and then within square brackets, we're starting with our first element in our array. We could simply just use this corn. We don't need to start with a zero, but we'll go ahead and do that. And then we could say, We want to go all the way up to, but not including Z, which is an index 26. And then we want every third. I don't. So if we were in our code, we get a D g J M P S V. Why, as we would expect, another way we could have quickly pulled this office I mentioned, is to simply remove those 1st 2 inputs, run our code, and we get the same results as well. All right, great job in this lesson, and we'll see next time 26. Lesson lists five: all right in this lesson, we're going to go ahead and take a look at modifying list with operators, the plus operator to be used to contaminate two or more list together. In this example, we have a Sea creatures list, and we have an ocean's list. And so let's go ahead and use the plus operator to bring those two together so you can use your print function and we can say sea creatures. And then we'll use our addition operator oceans. And when we run our code, we could see that we no longer have to list being returned or just one. But that one list contains the content of both of these lists sea creatures and oceans. Now, because the plus operator can be used to contaminate, it could be used to add a single item or several in list form to the end of another list. We just have to remember to place the item in square brackets. So let's say we have our sea creatures list and we want to add an element to it. We'll do this by saying an equal to see creatures, and if we want to add a yeti crab, we have to be sure to put this within square brackets. Now let's go ahead and print our sea creatures. And when we do, we should see that we have now added Yeti crab to our sea creatures west. Now let's go ahead and take a look at the multiplication operator. This could be used if you need to make copies of all the files in a directory onto a server or sharp playlist with friends or something like this, in which case you would need to multiply collections of data. So let's go ahead and take a look at multiplying or sea creatures list. We can do that by simply saying sea creatures. In this case, we can go ahead and multiply it by two. And when we do that and we run our code, we see that we get a single right back. Yeah, it's occupied with two sharks, two octopuses all the way through the end of our list. So, armed with that information, let's go ahead and get into this lessons challenge. We're simply gonna follow the directions that are in the commands online, for we can see that we want to add laying creatures are list and creature foods are other. List together and print the results. So let's say print as our keyword to use the print function land creatures plus creature foods. When we run our code, we can see that both of those lists are now within one list online. Seven. We have some directions to add mouse toe land creatures and print results. So to do this will say land creatures and we're gonna set it equal to our land creatures list. Plus, and I'm gonna do this incorrectly. First mouse, This isn't going to work because we need to be sure to have this within square brackets. No, we'll go ahead and print land creatures. And when we dio, we can see that mouse has been at it. Okay, let's move on to line 11. We're gonna multiply land creatures by two and print the results. So use the print function, no pass in land creatures and then multiply it by two. And while we're here, we'll take on our directions in line 14 which is simply to print the results of our Creatures foods list 53 So we'll go ahead and run our code, and when we do, we can see that our land creatures was multiplied by two as we have two cats, two dogs all the way to the end of having a mouse to mouse or to mice. And then we can see our creature foods. We have milk repeated three times, all the way through leaves repeated three times because we multiply either of us by three. All right, great job in this challenge and we'll see you next time. 27. Lesson lists six: in this. Listen, we're going to go ahead and look at removing an item from a Less items can be removed from a list by using the Dell statement short for delete. This will delete the value at the index number you specify within a list. So let's go ahead and work with our sea creatures list. Let's remove the item octopus. This item is located in the position index of one, the second item in our alright. To remove this item, we used the Dell statement, then call the list variable an index number of that item. So it's a Dell Sea creatures and then is that index of one. So now that we've done that, let's go ahead and print sea creatures, and when we do, we should see that are octopus is no longer in our list. We can also specify the range of elements in a list that we want to delete. So if we wanted to also remove blob fish and Mantis shrimp, we can do that as well all at once. On my go ahead and remove this statement deleting only the Octopus. And so instead I'll type in del sea creatures instead of removing just the octopus. Open the number one because we want to remove the element at index one. Now use a colon for because we want to remove elements up to, but not including the element and index for so zero 1234 So we wanted delete octopus up to , but not including an enemy. So when we run our code, we get shark an enemy yeti crab. By using a range with the Dell statement, we were able to remove the items between the index number of one, which is inclusive, and the index number of four, which is exclusive, leaving us with a list of three items following the removal of three items. So armed with that information, let's go ahead and jump into the challenge. We'll go ahead and follow the comments. The first thing you want to do is remove monkey from land creatures. So we use our del key word. They won't name our list land creatures and we want remove monkey monkeys that index zero 12 So it passed in the number two. I'm gonna go ahead and print black creatures, and when we run this code, there's no longer any monkeys in there. Now, online seven. We see that we want to delete arrange to remove dog and bear. So say, del land creatures. And the first item we want to remove is dog, which is that Index one. And we want to remove their now. Remember this original Ray has already been altered online for so we can look at the current value of our array right here on the right hand side of the street. So dogs that index one and bears that index to and so we're gonna use a colon and then a three because we want to delete up to, but not including our item index three. So before we run our code, let's go ahead and make sure we use our print function and passed in land creatures. And when we dio, we simply get cat and giraffe for our final. All right, All right. Great job in this challenge and we'll see you next time 28. Lesson lists seven: in this lesson, we're gonna look at constructing a list with list items. List can be defined with items that are made up of lists within them, with each bracket a list enclosed inside the larger brackets of apparent list. So here we can see that we have our outer list of see names. Contains an inner list containing the elements with strings. Shark, octopus, squid meant a shrimp and then separated by a comma is another list of Sammy, Jesse, Drew and Jamie. These lists within list are called Nested List to get access to items of that unless we have to use multiple indices. So what happens if we want to get Shirk The first element and the list? Let's go ahead and try this can print see names. And if we want to grab the first element in our list, you might just think it's a simple as entering zero for the first item. But if we do that, we see that we get the whole list because the sea names list contains nested lous. So we're just grabbing the 1st 1 before this comma separates them. So if we now want to get the first item in this list. Well, we know how to do that. We can simply just with square brackets, passen zero for the first item in that list. And when we run our code, we see that we get shark. So let's go ahead and do that just a couple more times before we move on to our challenge. Let's imagine that we want to get the Value octopus so we can use the print method. And I'm gonna go ahead and put in quotes octopus. So it's a little bit clear what our results are and will Target are See Names List, and we know it's in the first item of see names. So is this first list and looks like octopus is that index of one. So we'll go ahead and shoot square brackets passed in the number one and run our coat, and we get octopus. Now, let's try this one more time in the second array. Let's imagine we want to get the string Jesse, so we'll just simply print and then we'll access R C names list. Now we don't want this first list at index zero. We want this list at index one. So if we run our code. Now we get this whole array. And so Jesse is not the same thing as Sammy, Jesse Drew and Jamie. We want to make sure that we just get one element. So go ahead, not square brackets. And Jesse is that index of one. So when we run our code, we get Jesse. All right, great. Now armed with that information, let's go ahead into our challenge. We have a list called Land Creatures, and this list contains two nested lis. This first list is that index zero Cat dog and Monkey. The second list is that index one. They're giraffe and count. So, as the comments say online three go ahead and print each item in land Creatures list individually. For example, Let's go ahead and look at how you would print kind. I'd go ahead and use the print function, and then I would just put in this extra texts on the results. I know that what I'm intending to output actually matches what is being output. And so we name our list Land creatures. We're looking at the first item in our A list at index zero just right here. And then we want the first element in our list, which is cat at Index zero. So if we run our code, I gives us cat. So now let's go ahead and grab dog. We'll print dog. I will say Land Creatures is the first Meston list and Index zero, and then within that list, it's that Index one. So let's run our code and we get a dog. Let's go ahead and print monkey that's gonna be in our land Creatures array again. We're still gonna be at Index zero because it's in our first list and it's that index to within that first list to run our code and there's our monkey. Now I'll just go ahead and do one more with you. We're gonna go ahead and try to reach our bear. We're gonna print there, and this is in our Land Creatures list, and it's no longer in our first index cat dog and zero, it index zero. It's in our second index, so it's no longer index of zero in our first list, but it's that index of one in our second list. So go ahead and say one and then within this list, it's the first element in the array. So it is that Index zero. So go ahead and pass it in and run our code. And we targeted the bear as we thought we would now go ahead and provide how we can access draft and cow. And so if you have any problem with grabbing those two values, you can take a look at this code. All right, great job in this challenge and we'll see you next time.