[MUSIC] Okay, welcome to this week's programming tips. As an aspiring Python scripter, one of the key skills that you're going to learn is how to scour the web to find existing Python code that solves your particular problem. Our goal really is not to learn how to write lots of code, it's to learn how to find existing code and then pull that code together to solve your problem. So to understand what somebody else's code does you're going to need to read the documentation attached to that code. What's documentation? Just an English description of what a piece of software does. You've already seen this. When we define a function in Python, we always attach a doc string, right after the death statement, and that says in English what the function does. Now, there's a great quote that I've seen about the importance of documentation. The quote says, documentation is like sex, if it's good, it's very very good and if it's bad, well, it's better than nothing at all. So, you're going to see this in this specialization. For example, when we ask you to do a programing project, we're going to provide a very important piece of documentation, the project description. You need to read it extremely carefully. When you're learning a new language feature, you're going to read several pieces of documentation that describe the behavior of Python. If the answer to your question is there, great. If it's not, at least you looked in the right place to get started. So let's move on to lecture and we'll look at two big pieces of documentation for Python, the CodeSkulptor docs and the docs at python.org. Okay, let's start off by looking at the documentation that's available with CodeSkulptor. If you move over here on the various tabs, you have around this one, you can see, read about the documentation, about how to use Python and CodeSkulptor. So if you click on that button, I think it's very worthwhile. It's going to load the documentation for CodeSkulptor, there's a ton of it. And what this has, is it has a very nice concise description of the capabilities of Python, and it also has information about how to use CodeSkulptor. The things you should look at here, there's various tabs here that you can click on that bring information corresponding to how Python behaves. Under each tab, these are accordions, so you can actually click on one, and it will expand out. Notice that all these links are clickable, these links go to documentation of python.org, these go to examples we’ve created to demonstrate some of the features. Probably the most important tab here is Types & Operations, this describes all the various kinds of data you can work with with Python and how you can manipulate it. This is worth kind of moving, looking through, clicking on. For example, strings, here's an example of all the methods we have for working with strings. Here's some examples, some tutorials, all kinds of nice stuff. I want to point your attention, if we go back up to the top, that there's also a tab over here that talks a little bit about CodeSkulptor. If you look in lecture I do all these fancy keyboard shortcuts. They are listed here under one of this accodrions. And then the final thing is, that there is very handy-dandy search box up here. So again, there's a lot of information in the documentation and we can use search to locate it. So let's go in and do an example. Okay, let's use an example of finding some useful information in the CodeSkulptor docs. So the sample problem that I want to talk about for the rest of the lecture, is the idea of trying to understand if we can compare strings. So In Python we can easily compare numbers. One is less than two, three is equal to three, four is not equal to five. Kind of the question I have a mind, is can we do the same thing with strings? Python loves to take operators that work on numbers and have them work on strings, so the answers is probably yes. So let's see if we can find some information related to that. So I'm going to go up here and I'm going to type in string, and I'll look through here, and I see stuff. Let's try stringing compare, wait a second, okay I did this, comparison operators. Let's look at that. And I go down here and I see here all the various comparison operators that Python supports, and then I look at the examples, and I go look at that. Look, there's an example right there of comparing two strings. I'm going to copy that, I'm going to paste it back over inside my CodeSkulptor tab and I'm going to run it. And it worked. It did something. Let's go back and read what it does. So let's scroll down and read, remember, you've got to read the documentation to understand here, so. [SOUND] Strings can be thought as by using alphabetic order, although that doesn't capture the whole truth. More accurately, strings use lexicographic order with the ASCII character values. Hm, okay, well that's interesting. So it looks like we can compare strings. All right, let's go do some more explanations, explorations and see if we can figure out, how string comparison works. Okay, let's look at a second important source of information about Python. So here I am at python.org this is the home page for the Python language. There's tons of information on this page. You can see here all the various links if you scroll down. There's downloads, docs, anything you want. So let's actually go over and look at the documentation, so I'm going to click on that. And if you scroll down, you can see all kinds of various different things, things for beginners, moderate, advanced, more general. Under the Python 3.x resources, there's something kind of nice here, there's a tutorial, which is probably worth your time to kind of bang through here and try to understand a little bit of kind of the features of Python 3. I'm not going to go through it right now, but that's something you can look at. I'm more interested in going through and finding information about, what are we looking up? String comparison, let's go through and just search here and find, string comparison, see what we can come back with. So one other thing you going to see here, is the information contained in the Python docs is not necessarily beginner friendly. It's very dense and it can often be very advanced. For example, when we ask about string comparisons we get all of kinds of things. This first one looks, maybe a little bit helpful. Rich comparisons, although I'm not sure what a rich comparison is. And I will hit it here, and it's some document that talks about rich comparisons. And you can see, it's kind of more of historical document than maybe kind of a technical language document. But let's try one thing real quick, let's do a Ctrl+F, we can search the page and let's look for string. So we can see that there is kind of one instance of the word string in here. And it says, when called with one of the strings the third argument is. Okay I don't think this is what we're looking for. But if you kind of scroll down a little bit more, you see something else that's very interesting here, chained comparisons. So this is one of the fun things about actually browsing the docs, is you learn about new language features you weren't aware of. So I'd actually been using these chain comparisons for a long time, x < y < z, but I didn't know what they were called. So actually when I was shooting this video I discovered they were called chained comparisons. So there's things that can benefit you by just looking through the docs, even if you're not looking for anything specific. But I didn't find much about string comparison that it was helpful, at least in this kind of superficial glance. So let's kind of look at one final way you can find information out about basic Python questions. Okay, I want to finish off by talking about a third source of information on Python, and that's just the web. The advantage of the CodeSkulptor docs and the python.org docs are that you can trust them. They were put together by people that know what they're doing. On the web, the reliability of the information out there is sometimes iffy. But my kind of attitude in the web is, trust but verify. In other words, if they tell you something, check to see if it's true. So I'm interested in basically string comparisons, and most particularly this term lexicographic order. So I'm just sitting here, I'm going to just do a Google search on Python. And in fact, you can already see all the searches that I've done previously in preparing for this lecture. And there's a bunch of stuff here from Python.org, that's great. That makes me think we're on the right track. And actually at the bottom here, I have it, lexicographical order, and if you see here, I have a bunch of different links on here. Let's do the following here, let's go through and maybe do, see if we can find a Wikipedia page here. Okay, there's one, lexicographical order, let's hit that one. Okay and it's basically here, it talks about what lexicographical order is. And essentially it says at the end of the day it's just, what was mentioned in the CodeSkulptor docs. It's the alphabetical order of words. So I could sit here and read about this, learn a little bit more, do a little bit of web searching. But the critical thing is, when you're learning how to code, the most important thing is leaning how to teach yourself. Learning how to use search tools on the web and finding trusted sources to gather information and further your own programming education. I think that's one of the valuable skills that hopefully will help you hone in this class, in this specialization.