 Welcome back everyone. So this week we're going to talk about starting Python programming and our goal is to write a Service that can run on your computer. So we've already talked about business services and now we're going to talk about actually how to create them by writing your own program and Python is just language that you can use to write or program your computer And there's lots of different programming languages out there But Python is relatively easy to get started with and last week you saw how to install Python on your computer So before we get started this week, the first thing you need to do is make sure that Python is running The easiest way to do that is to open a terminal or in Windows It would be a command line, but it's basically this black window here where you can type commands in and If you type Python Then you should get something running. So here it just says Python Is running and then I know that it's running correctly because it actually started up If nothing happens or it says that the command cannot be found then you haven't installed Python correctly then you need to go back and look at the video last week about how we install Python now the second thing to Check is the version of Python that you have installed. So if I type Python dash dash Version into the command line so Python version into the command line Then by default I have Python 2.7 installed and in Linux and OS X it might have two different versions installed What we want is the newest version Python 3 So if I type Python 3 dash dash version Then you can see that I also have Python 3.6 installed so by default in Linux you'll have At least for a while you'll have Python 2 installed and Python 3 installed Make sure any new programs that you're starting with you're using Python 3 to run them That way you're always using the newest version So I would have to type Python 3 but for most people especially today whenever we're just getting started It doesn't really make a difference. We can type Python or Python 3 if you're on Windows, which most people are Whatever program you chose to install that should be the only Python version on your computer Normally Windows doesn't come installed with Python installed. Okay So now the next thing I Am in a folder right now and if you look in the folder I have one file called hello dot p y this dot p y is a File extension that means it's a Python script or a Python program So I have a file called hello and then dot p y means Python program And I just have something kind of like notepad or memo opened up a basic text editor It's nothing special. You don't need special tools to start programming. You can do it pretty much with anything so I Yeah, open up Python or sorry open up notepad and then we can just start programming directly before we Get any any special programming tools? Okay, so I have a File called hello dot p y and that lets the computer know that This is a Python program And I'll show you how to run that in a second, but then I have the empty file up here. Okay, so I'm getting started with your first program Python is a really simple language. So Normally the way that we begin is just by printing something on the screen so if we run the program then we want something to Show on the screen in the terminal. Okay, so if I just want to print something on the screen All I have to do is type print and then we'll say hello world Okay, so here this is the entire command we have something to do which is usually a verb like I have the command here print as in Display something and then inside quotes double quotes. I have a string that I want to print So we have some action that we want to do and then what to do or what should go into the action So here print in quotes double quotes. Let's see if I can Yeah, okay So print and then in double quotes hello world and that's it So anything that's inside these double quotes should run so I'm gonna go ahead and save that and Then go back to my command line There's my file so now I want to run the program and you might think That's not very much code to be in a program, but that's actually all we need to start program so now I can just type Python and Then hello dot py and that basically says use Python to Run this script Okay, so use Python to run this script. So what do you expect to happen? Well, the only thing that we're asking it to do is to print out the text hello world So that's hopefully what we expect So I hit enter and then notice that it does print out hello world But it does not have the double quotes. So print printed everything inside These double quotes and I can change this to be whatever I want. So hello Python So instead of hello world change it Save the script run the program again, and then we have hello Python printed instead of hello world So whatever is inside these double quotes is what will be printed onto the screen? Okay So that's a very basic program and honestly, it's not very useful unless you just want to give messages a Single message to someone over and over again. You can just keep running that So let's do something a little bit more Normally whenever we are printing something or we want to run a program the program should Change Depending on some sort of input Okay, so every time we run the program depending on the state of the system or depending on Something that's going on we want to change what we do or change the output So if I just type hello Python or if I print hello Python over and over again, it's not very useful but if I For example change the name Depending on who's running the program then I could say hello Joshua and that might be interesting Depending on what you're trying to do. So the way that we do that is to use something called a variable and just like in your math classes You've probably gone through variables where for example X equals Something right and X the value of X can change over time. Well programming really relies on variables a lot too So for example the name example we can have a variable called name Okay, so this variable is a container that holds some value And we make it a variable by saying name equals and I'll just I'll just do it like this Joshua So name equals Joshua. So now we're basically saying This variable this container called name has a value of Joshua inside these quotes So everything inside the double quotes, okay? And then if we want to print now we can go back to our print statement print and then let's say we want to print hello Well, how do we print? Some sort of text like we always want to print hello and that's not going to change But we want to change this variable. Maybe every time or every so often we can just do plus name Okay, so now we're printing hello Plus whatever is in the variable called name What's in the variable called name? Joshua, so what if we run this program? What should happen? First it will print out hello Python And then it will print out hello and then whatever the value of this variable is so let's go ahead and run that So hello Python that was this first text that printed and then we have hello Joshua Which is the second text that printed notice In the second line There's no space between hello and Joshua. Why is that? Well, Python doesn't actually know that these are two different words It could just be any text that you're trying to put together this plus sign Whenever you're talking about text or strings is Concatenation or putting two things together. Okay, it's not math where we're doing some sort of math on the two different strings It's concatenating both strings together, but Python doesn't know what the values of Hello Joshua mean like it doesn't know English basically, okay So we have to explicitly tell it that we want a space in the middle of it Now there's a couple different ways to do it But the easiest way is just go to our string hello and then put a space at the end So now we're adding a space character to the string and then keeping our name strings. So if we run it again Now we have our space. Okay, so whenever the variable is a string, which is a collection of characters If we are using the plus sign we are adding two strings together So name will go at the end of hello and we can keep going. We can add something like exclamation point Okay So now we'll have hello a space and then the name whatever our variable contains and then an exclamation point So we can concatenate as many different times as we want and there we go. So there's the Joshua is the contents of the variable and then we have the exclamation point at the end Okay So You might be thinking well, that's exactly the same. Why don't I just type Joshua? Well, the easy thing is I don't have to change this entire string or find the entire string and now I can change it to Say Jill okay, so I can just change the variable one time and what do you expect to happen? Instead of hello Joshua it prints out hello Jill so what we can end up doing Let's say I have something Like this where I have name equals Joshua and then name equals Jill and then I print what do you expect to print out? To be the contents of name Well, if we run it again, we can see it says hello Jill and the reason is we first Assign Joshua to the variable and then we overwrote the variable with Jill So we've removed Joshua and added Jill to the variable and then print it out So if we copy this printing line So now we have name equals Joshua and then we have print and then we have name equals Jill and then we print So now we have three lines. Hello Python. Hello Joshua. Hello Jill Now notice the variable has been changing. So the result of printing out is also changing and later in a later Class will be talking about how to ask the user for their name and actually get an input or get the input from somewhere else Okay For now, just know that we can create a variable called basically anything we want As long as we say the variable equals and then in this case, we are assigning it the value of a string Okay So just like we're talking about strings Since we're using plus signs, you might have thought that we might be doing math and you definitely can do math That's a big part of Programming you might need to do different math calculations sometimes. So let's go ahead and add a little math Basic math in here. So let's do x equals one and y equals two, okay now notice Whenever I say x equals one, I'm not putting one inside double quotes. So one is actually a number instead of a Variable, okay And that'll come in handy or that'll be that'll be important later because Sometimes or at least for numbers you might want to do math on them So we have to treat them a little bit differently if something is a string We don't need to do math on it. So think of your phone number for example your phone number You're probably not doing math with a phone number, but you want to make sure you keep it as an entire string of numbers Yeah, so we'll talk about more about data types later, but Strings basically we don't do math on and numbers we do math on so in this case We have x equals one and there's no quotes around it. So I know that this is a Integer value Y equals to that's also an integer value. So I have two integers that I could do math with okay, so let's do z equals X plus y X plus y Okay, now just like before we have X plus y just like hello plus name But because these two values are integers then x plus y should work like a normal addition problem And z should equal what these should equal three because we're just adding two plus one. Okay, so let's go ahead and print Z Save that so what we should get is hello Python. Hello Joshua and then Three just the number three Okay, and that's what we get. So hello Python hello Joshua and then the number three now to kind of illustrate what I'm talking about here Basically, if you don't use quotes it Python treats the number like an actual number if you do use quotes it treats it like a string. So Let's try real quick x equals one in quotes and y equals two in quotes z equals Equals x plus y Print see okay, so now I'm treating both of these as strings instead of numbers. Let's see what happens Okay, so here we have 12 and 3 in the first case we had 1 But it's a string and a 2 and it's a string and we're using the plus sign which is concatenation So it's saying 1 concatenate with 2 equals 12 And then in the second case we're actually treating them as the real values or the real numbers integers So we're actually doing math with this x plus y so One of the most difficult things and actually most programming languages is thinking about the types of data that you're working with and how that affects What you can do with them. So basically you can let's say at the most basic level If something is a string You can't do math on it, but you can concatenate it and treat it like text if something is Not double-quoted then it's most likely an integer and you can do math with it. Okay, right? So that's about what I wanted to show you today So we have first printing just basic text you can print anything inside the double quotes Next is creating a variable so anything name equals and the variable definition is always on the left So name equals that means that name is the variable. So you cannot write it for example in quotes Joshua Equals name this does not work right you have to say the variable name first Equals and then whatever the value you want to assign it So the variable name is always on the left of the equal sign and the contents are always on the right okay, and then Again, we're just printing the plus sign with printing if something is a string is concatenation and Then if we don't have double quotes so we have a number value then Python treats that as an integer and We can do basic math on integers and then You can do all sorts of calculations if you want to so for example What you might want to do is ask the user for their name and Then we can save their name value into a name variable And then you might want to ask their age and then we can save their age into an integer value So let's say that they're you know 20 and then we can do Some sort of math calculation like in 10 years This is how old you'll be of course if they're 20 then you can just add 10 to 20 And then you would get 30 and then you can print out that value Not terribly useful, but it might be interesting for some different types of Services if you're wanting to write that okay, so what I want you to do this week is play around with Assigning values Creating variables and assigning values to those variables and then printing out Something with concatenation and then also doing basically anything with your math calculations Here we've done Addition, but there's also all of the usual suspects for math, so I could do x let's say z equals x times and that's asterix y or z equals x minus Minus y or z equals x divided by y so Everything that you would expect there's lots of different types of Math calculations that are built into Python And that's why people like it a lot because there's lots of different ways that you can do different calculations using This program which comes in very handy for things that I'll show you later Okay, so this week I want you to play around with that and make a small program and that will be it for this week So, thank you very much