 Okay, welcome everybody to lessons one and two of Python for Java programmers So this is basically something I'm putting together for my students and I'm going to put some Java code on the left I'm going to put some Python code on the right and I'm going to show you basically how to make that Transition from one language to the other at least with the basic structures. So let's get started first. I'm using Repel it and this is the link I'll put this in the video link down below and So you can find that and I'm also using the same thing for Python 3 and we'll be taking a look at that So watch what I do here. I'm gonna go over to help you get set up when I go to settings and where says layout side-by-side I'm gonna change that to stacked And then I'm just gonna hide the settings again. Now. There's a dark mode if you prefer that I'm gonna go over here. I'm gonna do the same thing and I'm going to don't want the dark mode I want stacked and then I'm just gonna pull that out and then I'm going to Basically put that on the right. I'm gonna put that on the left and then I'll kind of go down through the code. So notice I Have the Java written already and this is from one of my previous tutorials and I do not have the Python written yet So I'm gonna write this as we go along So I'm gonna go ahead and run this and see what we get And again, this is an online thing. So it does take a minute sometimes or a little bit of time So it's basically just some very very simple output. And so in this lesson, I'm gonna talk about comments and printing Okay, so let's take a look at it now comments in Java single-line comments start with Slash-slash, but in Python they start with a hashtag. So Christian Thompson Thompson.com and my Twitter handle is at Tokyo EdTech And this is lesson one and it's one and two comments and printing Okay, so now here in Java. We've got a multi-line comment Technically speaking Python doesn't really have multi-line comments It does have something called doc strings where you could put, you know, this is a That should be wrong ticks there wrong keyboard. I Could put this is a multi-line comment But really it isn't it's a doc string and it's probably not the best way to do that if you read the Documents on the Python documents the preferred way of doing it is to use hashtags So there really isn't in it in the traditional sense a multi-line comment So I'm just gonna put that there and Here we go. Now. This is where we start to see some of the differences between Python and Java Java is what we call object oriented everything is a class everything is an object Python is not necessarily that way you can make everything basically into an object, but it isn't necessarily The way that Python functions again, I know I'm making some grand statements, but within limits That's basically how it works. So So this stuff here class main public static void main string args. We don't need we can just skip right to Printing so if I wanted to print that I'm just gonna copy that Python. It's much much easier type print and That is it Okay, so we don't need a semicolon at the end although you can actually have one few people know that but you can put a semicolon, but you don't need it and You just put print instead of system dot out print l n and this is a key thing l n versus Regular print and I'll talk about that a little bit later. So I'm gonna go ahead and run that And there we go lesson ones comments and printing. So now this is interesting basically at this point most things work About the same. I really don't like that pop-up all the time, but I guess I'll leave it So let's go ahead and just kind of copy some of this stuff over and take a look hello world and I'm gonna copy hello plus space plus little world Let's see print and let's go ahead and run it and see if we get the same output that we got from our Friends here oops, and I missed one. Sorry. I missed this this here. So so far. You can see how it's it's more or less a 1-4-1 Type of thing. Let me go into the settings here and see if I can get rid of code intelligence That's really bothering me. I'm gonna disable that Is just not looking good with the way I have this laid out So let's go ahead and save and actually don't have to save it's not just a habit and So comments and printing hello world. Hello world. Hello world so far so good. So I'm gonna go down a little bit print and I want to print a blank line. I don't have to use that. I'll show you later So now if I want to print a number Or print a number in quotation marks, you notice I my habits is now I'm kind of mixing my styles go ahead and run that so whether I print The number with quotation marks or without it's going to be the same Yeah, it's my space there so I do some scrolling And so the next thing is and there's there's reasons I'm doing this which you'll see in the next in the next lesson and print So 2.0 print quote 2.0 and let's go ahead and just kind of Take a look at this I'm gonna go ahead and just actually let me just copy this and just See what happens there. Yeah, I got some tabs And again, so this I can make this into print It's a lot of fun to watch me type but But what's interesting I think is that you see how You know once you've you've learned a system.out.printlin You know that it's basically the same thing Here so let's go ahead and run this and see if we get the same result Okay, so we got we got four we got two plus two and we got 22 now again, this is not an introduction to programming This is an introduction to how python does things versus how java does things I'm assuming that you already understand everything that you see over here So let me go ahead and copy that out And put that over here get rid of that And maybe for this one. I could have just done it ahead of time, but anyway Later ones will be a little bit more interesting. I think so I'm gonna head to run that See if I get my 4.0 2.0 and 2.0 so far so good And now this is probably the last part and this is where you'll see a little bit of a difference between how java does things and how python does things And note this is python 3 so Some of this will not work in python 2 actually So you can see here. I'm using the escape one of the escape characters slash slash n And I'm using here slash t And I'm using here And we're gonna see again, we're gonna see some differences here in a second One major difference. So I'm gonna go ahead and run that Okay, so you can see My name is christian. I think that's just a weird artifact of Oh, no, that is not a weird artifact. So you can see over here. We've got print versus printlin Okay printlin automatically adds a carriage return. So it goes to the next line whereas print does not so notice with print there is no print versus printlin in Python but in python what you would do is you would type comma end equals And two single quotes What that tells python is that instead of Ending with a carriage return and going to the next line. We're going to end with nothing and we're just going to keep printing from there Let's go ahead and run that And now you can see my name is christian my name is christian and Want to do the same thing here comma end equals quote quote Go ahead and run it and same thing comma end equals quote quote And you can see how we have essentially the same layout Now it's something weird kind of happened here. I'll talk about that in a second, but I wanted to show you this also In case you didn't know if you want to print quotation marks inside of Quotation marks you need to use the escape character here and the escape character here And I think this just cut off because of the width of the window. Yeah, so that's just cutting off So for some reason even though you have all this space here, it's cutting off at that point So it's yeah, not sure about why that's doing that. But anyway, it's just a little quirk of the web So anyway, so you can see so far. There's not a huge difference between The way java works and the way python works except in this whole class main public static void main Thing so in java you can't just have code out by itself It must be inside some sort of class structure It must be inside some sort of method in this particular case But python's a little bit more forgiving And you can just kind of start printing and doing stuff right away in python, which is quite nice So that is that for this first lesson. So thanks for tuning in. Stay tuned for lesson number three. Take care