 Okay, welcome to Python for Java coders part five in this lesson. We're going to take a look at Conditionals which are comparisons again not trying to teach you programming here I assume that you already know what's going on in Java And I'm just going to show you how to do the equivalent code in Python talk a little bit about the differences So again, we don't need classes. Okay. We don't absolutely have to have a method We can just go ahead and start writing code. So it does three Equal three what a great question. Okay So in Python watch what we do here now This is where this is where we start seeing some Significant differences in the way that Python is structured and I'll talk about that here in a second. So I'm going to say if three equals three colon Enter notice how it was already indented Actually, I'm going to go ahead and fix the indentation on here But in Python the indentation size is four That is the default indentation size So I'm using the tab key, but notice how it's automatically converting to spaces Hey, this is one of the things that people don't like about Python. It's because the spacing counts Over here in Java if I do this this is perfectly valid Java code We just do do it like this so that it you know, it's just visually easier to understand, but I can actually write this line Exactly like that. The only thing that matters is these braces Now Python does not use the curly braces. Okay, this is this is from this is what we call a C type language And it looks if you look at seeds, well, it's very very similar although they function quite differently so in Python When we have an if statement at the end we need a colon the next line must be indented That tells us that this line is part of this if statement Okay, so I'm gonna go ahead and say print And it's a print true So I'm gonna go ahead and run that Just three equal three now notice. I didn't put parentheses. So let's take away the parentheses here and see what happens Okay, so you can see how we got an error So Java requires that you put the parentheses here Python does not although you can Now in some cases you absolutely need them, but in a simple case like this you don't yes We should see the exact same output So it's up to you really which style you want to stick to if you have a habit of putting parentheses Go ahead and put them in okay now notice my next line is Not indented Okay, so I'm gonna say this is outside the if statements So I'm gonna go ahead and run this and this is I say print inside the if statements So in Java it's very clear because we have these curly braces to tell us the starting and stopping but in Python the what it's called white space the white space controls what is inside and what is outside So now if I change this to two It still prints this because it's outside of the statement outside. So in this case, they're lined up vertically But these are inside and Java you course you would have had curly braces, but in Python We don't use those okay, so one other thing in Python 3 you cannot mix tabs and spaces Now as a convenience most editors will convert your tabs of spaces So you don't have to hit space space space space. Okay. Now if I put an extra space there Let's see what happens So you can see how we got an error because there is one little extra space there You'll see what it says indentation error. It did not expect an indent there Now if I do this And run it we'll also get an indentation error So here it expected an indent because after this colon after this if statement We have to at least have one indented statement To say that this is part of the if and conditional structure Very interesting differences So I had print when I move on with the next part Again, so I do not have to type. I do not declare the variable type So I can just type x equals 3. I can take y equals 2 And I'm gonna say print Is and again back to Python formatting format So again, this stuff that came from the previous videos x comma y now again because of the order Okay, x will go into the first one y will go into the second one Okay, so let's go ahead and try it. So if x is greater than y colon print True Do it back else Okay, I also need a colon there print false The reason I can print true and false and not put quotation marks is because they are booleans They're an actual variable type and the computer automatically fixes that and prints it out for you as a string Okay, so is three greater than two Yes, it is If I switch that around We'll see false Okay, so again these types of things work very very similarly So you can see that there's a parallel structure going on here It's just that the syntax is is quite a bit different in Python Python syntax is much much simpler Okay, so we're gonna go ahead and Try this again Now you see I just kind of switched it here did it but I could I could go ahead and rewrite that So let's go ahead and just do it. I did the first one. I'm gonna go ahead and copy that So I'm gonna go ahead and change x to 2 and Two to three and go ahead and run it Let's go to run that again. So we have something to pair it to so it's three greater than two yet true is two greater than three false All right, so so far so good Okay, next up we're gonna do a quick kind of just some rock paper scissors code and learn a little bit more about conditionals okay, so again remember in Java you must declare the type and the string type here so player a equals rock Also, remember in Java it uses camel casing So it starts with a lower case and then when there's a boundary to another word we make it uppercase and But in Python we use snake casing. So I'm gonna say player underscore a equals rock and Player underscore B equals scissors Again, I didn't need to declare it Python. Oh, this is a string. So now this is a string easy peasy so if Player a Now in Python, we don't use dot equals. We don't use that. We just use equals a rock And here we've got or That is or in Java over here in Python. It's just or Player B equals rock Colon notice it's automatically indented for spaces and say print someone chose rock Okay, so let's go ahead and test that again, this is online. So it takes a little bit of time to To compile and run I guess so someone chose rock and that's what we see now So there's also the if else if L if and else if an L structure Let's take a look at that and see what that looks like in Python. So if player a equals rock Okay, so again in in Java use two ampersands for and in Python. We just use English player B equals scissors Colon enter again notice it's two equal signs not one equal sign So we can print here player a Because rock of course beats scissors Now in Java we have else if in Python we got L if same thing just slightly shorter so player a equals rock and Player B Equals paper We print in this case. We said player B wins and then finally Here's else You say print tie Again, I know this this isn't quite the correct rules for This wouldn't work in a real Paper rock scissors game because you still have if player a has scissors player a has paper You have to program all of those and then your else statement your tie But for this this limited case we can test that Okay, so player a wins. So I'm gonna go ahead and test that I'm gonna change that to paper And run it Now player B wins. I'm sure why that's doing it over there and then we'll go ahead and we'll do rock and rock And then we've got a tie So you can see over here. There's there are some significant differences in the syntax And the way things are done, but essentially the structure is the same It's just it's just you again. You can just see how much cleaner Python is than Java and how it just You know, it looks yeah much simpler to at least get back your head around especially as a beginner So coming from Java, I think, you know, Python's fairly simple to pick up in a lot of ways But coming from Python to Java would be much more more difficult because it Java's a much stricter language has a far far far more rules Okay, so we've got greater than less than all those things are the same as they are in Java So we got greater than less than not equal Equal greater than or equal to and less than or equal to all those things are the same in Java and they are in Python, which is nice and We did that and then you can see some differences here string comparisons are very very different So it's string dot equals method but in Python and we don't do that We just use two equal signs. Okay, just like we do with integers and floats So and then if is the same but it's L if instead of else if and then else is the same Again, the the convention for variable names is again snake casing versus camel casing so that's important and Finally or is these two lines but in Python's just English and in Java and and But in Python it is and okay, so hopefully that'll get you started with comparisons and conditionals in Python. Good luck