 Here's how to use SageMathCell. Open a modern web browser and go to the address htdps colon slash slash sagecell dot SageMath dot org. What you'll see is a single input box that's ready to accept your code. Now, by default, this is using the Sage language, which is great if you want to abstract mathematics, but if you look in the lower right is a drop-down box that offers other languages. For example, you could use octave if you want to use MATLAB light code, or R if you're going to use do pure statistics, or a singular if you want to work on computer algebra. However, for basic numerical programming, we're going to use pythons. Let's select that. The input-output system here is very simple. I can type in some code, like say 2 plus 2, and hit Evaluate. And in this case, I don't see anything. The computer will only print things if we ask it to print. You can keep going back to the box, typing, and either hitting Evaluate or Shift Enter has the same effect. Now I want to demonstrate some of the features and syntax of the Python programming language. So I'm going to go to my box and clear its input, just with backspace or control and delete. And let's do a basic loop. One of the key things that computers do for us is they can do the same thing repeatedly. And the loop syntax in Python is extremely convenient, but a bit unusual if you're used to programming language like C or Java. So the basic idea here is we want to talk about ranges. So for example, suppose I want to count from 0 to 9. I could say something like this. For I in range 10, print I. And notice it prints 0 through 9. So there are a couple of things to deconstruct here. First of all, we declare a local variable I, which inside the for loop, right, for each set up of the for loop I is defined. And notice also that the interior of the for loop is not designated with curly braces or anything like that. It's actually designated by the fact that it's spaced in with four spaces. So this is a feature of Python which irritates some people, but it ends up being extremely convenient in the long run, that interior blocks of code, such as the inside of a loop or the inside of an if statement and so on are designated by being spaced inwards. Now range 10 is the command here, which is going from 0 to 9. So let me actually just demonstrate that. For example, maybe instead of going from 0 to 9, I want to go from 100 to 300. So notice that range 100-300 starts at 100, so it starts at that first number. And it goes down to 299. So the effect here is that we start at the starting number and we end one before this. And therefore, when we typed, for example, range 10, that's actually a shorthand for range 0, 10. If you don't give it a starting position, it assumes that it's 0, of course. So we can count from 0 to 9, that is count through the first 10 numbers starting at 0 with range 0, 10. Now we can also count by, let's say count all the even numbers. We can say 0, 10, 2 in our range command. And now it counts starting at 0, stopping right before it hits 10, and counting by twos. So we have start, stop, and the step size, 0, 2, 4, 6, 8. So for example, we can say let's go from 1 to 27 by 3. We go 1, 4, 7, etc., and we stop at 25. The reason we stop at 25 is if you add 3 to 25 or at 28, which is bigger than or equal to 27, the stopping point. So this is how we do loops in Python. We can do multiple loops also. So for example, you might want a second loop. Let's go for i in range 0, 10, and for j in range 3, let's print. And now we're going to do a little bit of demonstrating some syntax here for printing. So there's two things to see here. i is blank, j is blank. So here, notice I have a nested loop. So we're going to count from 0 to 9. And then for each of those, within each of those, we're going to count from 0 to 2. That's range 3. And now inside that second loop, we're going to print what i and j are. This curly brace syntax is quite useful for printing out numerical answers. So here's the output of this. So we know that we're going to actually have 30 lines of output. i is 0, j is 0, i is 0, j is 1, i is 0, j is 2. So that's in the first step of i here and the three steps there. And then we run through in blocks of 3 inside the over running from 0 to 9. Okay, so with that done, the next thing I want to do is demonstrate lists. So let me say, let's say l, and we're going to use square brackets for lists. So this isn't going to be an empty list, if I say print l, I see an empty list. Now I could also do things like this. I could say l is 1, 2, 3, 4, and I could say print l, and that's my list. Now the thing that's nice about the Python loop system is that anything you can count through, say a list, can be used as something to loop over. So let me make this list a little more interesting. Let's say 1, 2, 3, dog, fish, elephant, 4, a list can actually contain any sort of object at all, a number, a string, another function, whatever you might want to do. So say for i and l, print i. So this first line of output is printing the entire list, print l. And it of course prints exactly as we expect. It's a list, distributed by square brackets, separated by commas of the objects on the side. Now what we're going to do is loop through the list, so for each item in the list, we're going to print that item, 1, 2, 3, dog, fish, elephant, 4. So this is actually very similar to the range statement, right, so compare these two statements. So this statement here, range 4 is acting just like lists. So range 4 is essentially creating a list, technically it's actually an enumerator object, but it's essentially creating a list of the numbers designated by the range command. So looping is very simple in Python. You make a list or a range of whatever size and whatever content you'd like, and you just say for variable name in that object, do whatever you want to do. So there's one more thing I want to say about lists, and that's list comprehension. So let me make a nice simple list here, let's just say 1, 2, 3, 4. And I could do it, say on a square each of these numbers, I could say for i in L, I could say print i times i. So of course that's 1, 4, 9, 16. But maybe I want to make a list out of that, there are two ways to do that. Just sort of the slow way, let's call this my list k, and let's make an empty list. And what I want to do is for each item in the list L, square it and place it inside the list k. So instead of printing that number, I'm going to append it to the list k. So I'm going to use the syntax, which looks a little strange at first, but I'll explain it in just a moment, k dot append i, or i times i. And now once that's done, let's print the list k. So you see what's happening here is we've made a list manually, we created an empty list. For each item in the old list, we're going to append that number times itself to the new list k. And then once that entire thing is done, again, we know we're done with the loop because we're no longer indented here, we're going to print the new list. There's one more way to do this in Python, which is very, very slick. Let me call this list k2. And we can actually say it all in one line. So let's say I'm going to make a list of i times i for i in L. So you see we've sort of embedded the for loop inside a list statement. And of course, we get the same results. This is called list comprehension in Python. And it lets you sort of write things when you think about them mathematically. So I have a list of numbers one through four. For each thing in that list, I want to square it and make a new list. So this is sort of like the sequence syntax we use all the time in math where we say like let's make a list k, k sub i is equal to i squared, for example. I want to talk a little bit about the syntax I was using for this dot notation. So what I'm about to type is not actual code, but again, okay, so my name is Abe. So I'm some sort of object, right? And you might want to say grammatically, I want to eat a bagel. So this is how you would write that in the object-oriented language Python. So Abe is sort of the active player here, the object under consideration. And the thing it's going to do is it's going to eat and what is the input of the eat command it's bagel. So object dot function name or command name or method name is a very common way to write things. Some commands don't have inputs, for instance, Abe dot sleep would presumably mean I should go to sleep. And there's no sort of input to the sleep command. It's simply an operation that this object would do. So in this sort of analogy, by the way, if you put a pound sign in front of something, it comments it out. So you can sort of leave it there and it won't be the other way to encode. So to demonstrate this, let me again do L is one, two, three, four. And I can say L dot append, 27, then I'm going to print L. So right now L is one, two, three, four. So the L object, this list object, it's going to do something, it's going to append. What is it going to append? It's going to append the number 27. And now our list is one, two, three, four, 27. So we've seen loops. We've seen indentation. We've seen how to print things. We've seen how to do basic operations and objects. The last thing I want to do in this demonstration is show you how to import packages. So the key things we're going to use inside of the computing are the NumPy package and the SciPy package. And occasionally the Scikit-learn package. So these packages are not part of sort of basic Python. In order to use them, we have to import them, right, bring a library into our programming environment. And the command is reasonably enough import. So we just say import NumPy. And whenever you import something, you can actually run help on it. And it gives you sort of a brief summary of what that package can do.