0:00 All right friends, so now we're going to talk about the very first command in Python and the most used piece of code that you will see everywhere in Python projects. We are talking about the print function. So what is print? Print is a built-in Python function that displays a text or a result in the output screen in order to communicate something to the users. So what this really means? So now let's say that you have a Python code and you are building like an application. Now in order to show a message in the output we can use the function print and the syntax for that is very simple. We use a function name print and then we put inside parentheses and double quotes a message like for example let's say hi. Now if you go and execute it what going to happen? Python going to go and execute the function print where it's going to go and take whatever you written inside the message and move it and display it in the output. And that's it. Or what we are doing is we are sending a message from our code to the output in order to communicate something to the 1:02 users. And now of course the question is what is function? Now we have like a dedicated complete chapter about the functions where we're going to deep dive into all details step by step. But now think about the function is like a mini machine in programming. You give it an input. It does some work and process your input behind the scenes and at the end it gives you back a result and output. So think of it it's like a coffee machine. You give it the coffee beans and the water. Then the machine it does the work and at the output you will get your coffee. So you don't really care about all details how the coffee machine did make the coffee. It's enough for you to know what you want to give the machine and what you are expecting from the output. And this is exactly what are functions in Python or in programming languages. And now you might ask where these functions come from. Well, we have three main sources for the functions. The first one is the built-in functions. They are functions that come with Python out of the box. You can just use them anytime you want inside your code. For example, we have the print function. That's why I said it is 2:02 built-in function. And we have other functions like the input, the length function, max and so on. Now, the second source of functions, we have the third-party functions. They come from external libraries like pandas, numpy, pispark, lotty and so on. Those libraries are developed from a third party from someone else. It's not from Python but still you can install them and use them in your code. And now the third source of functions we have the userdefined functions. These are the ones that you my friend creates. So you can go and build your mini coffee machine. But now my friends we are focusing only on the built-in functions for now and we are learning those important functions that comes from Python like we are learning now the print function. Okay. So now back to Visual Studio and let's practice this function. Let's start with something basic. So we're going to use the function name print and then we're going to open parenthesis and close it. And now in between we have to go and give the message and we're going to do that using double quotes. And now we are ready to put our message and you can write whatever you want. So for example, hi Python. And that's it. So that's all. 3:04 Let's go and execute it. Now you can see in the output we have as well the same message. Hi Python. So this is the most basic form of the print statement. We are just telling Python print this message to the user as it is. And now my friend there are like many special things that we can do inside the print. And I'm going to walk you now through them one by one. So the first thing is that we don't have to use always double quotes. We can go and use a single quotes and inside them we can go and write again any message. So if you go and execute it, same thing going to happen. Python going to go and print the message. So you can use single or double quotes. Python going to accept them as long you are using the same type at the start and at the end. So for example, if I go and say over here print and let's say I start with double quotes and then I say hi and then I close it with single quotes. If I go and execute it, I will get a syntax error. So use the one that you like, but always start and end with the same type. So this one is not working. I'm going to go and put it in a comment. Now my friends, you can use the print in order to show anything in the 4:04 output and you can style and design the output as you want. So for example, if I go over here and say let's go and print for example like a lot of minuses and then in between I'm going to go and say print and few spaces learn Python and as well few spaces it's like I'm making a title and at the end I will have as well few minuses. So now if I go and execute it I will get this cool design in the output. It's like a banner or a title or whatever. So you can go and have fun with the print in order to design anything in the output message. I just found this nice sketch in the internet of printing a dinosaur. So you can see you can use your imagination in order to draw something using print in Python. Okay. So now we're going to talk about special characters in Python. Now we have a lot of characters that has no special meaning in Python like regular letters A B Z and numbers 5 9 0 and as well a lot of symbols like at and question mark they don't mean anything 5:05 special and they are treated as normal text but now in Python there are characters that have special meaning when you are writing text they all start with backslash and once Python sees those characters it's going to understand immediately aha we have to do something extra so they have special purpose So now let's say that we have this text. So we have a sequence of characters, numbers. This is for Python is totally normal and there's like no extra job to be done. But now if we put slash before the n then what we have done we just broke the normal sequence. And now Python going to see special combination between the backslash and n. And this has a special job where Python going to go and create a new line. So what we have done here is we have escaped a normal sequence and we have in Python different ways of escape sequences. Like for example we have the backslash and the double quotes or a backslash with a single quotes. We use them in order to include those quotes in the text. And we have as well double backslashes in order to include a real backslash in the text. And then we have 6:06 the backslash and n in order to create a new line in the output. and as well a back slash entity in order to add horizontal tab just to have like spaces between words and as well we have the back slash MP for backspaces. All right. So now let's go back to our code in order to understand exactly what this means. And now let's say that I would like to have in the output double quotes like for example I'm going to say over here hi Python but I'm going to go and put Python into double quotes because I would like to see that in the output. Now if you go and execute it you will get an error. So you can see Python saying okay in your file there is something wrong with your print is an invalid syntax. So let's go and check our code. You can see Python is now like in different color. It is not inside our message anymore because Python going to say okay this is the first message. It start with the double quotes and ends with the double quote and then there is something called Python. It will not understand what you mean with that because it is not inside the message and then we have another message where it start and ends and inside it there is 7:06 nothing. So you cannot do that. So now how we going to fix this? We have to tell Python in some way that this double quote is the content of the message. It's not the end of the string. It's just part of the message. And we can tell that for Python using the magic of the backslash. We can use it in order to escape a sequence. So now how we going to do it? Exactly before the double quotes, the one that is part of the message, we're going to type a backslash. So now we can see we are getting like different color and with that Python going to say okay there is something to skip here. The double quotes that comes after the backslash it is not the end of the message. Now we are not done yet. We have as well this double quote after Python. This one should be as well skipped because it is part of the message. So we're going to add as well a backslash for it. And with that Python going to understand aha this is the content of the message. And the last double quotes we don't have before it any backslash. Python can understand okay this is the end of the message. So if you go and execute it you will see in the output we have hi Python and Python 8:08 inside double quotes. So again by looking to this the first double quote is the start of the message. So Python understand okay I have to print everything after it. Then the second double quotes we have before it a backslash. Python going to understand I have to print it. So it's not yet the end of the message. The third one is the same story. Python going to see before it there is a backslash. So it is as well the part of the message. And the fourth one, we don't have a backslash before it. So it is the end of the message. This is exactly how Python going to read this print. Now there is like another way in order to have double quotes in the output. You can go and use the other type with the single quotes. So you say hi Python and you can put Python in double quotes. So if you go and execute it, it will work as well because you are using at the start and at the end single quotes. And this will be working. And of course, if you want to have like single quotes in the message, it will not work. So if I go over here and execute it, you will see we will get an error. So in order to 9:08 have the single quote in the output, you have to go and use as well the backslashes. And if you go and execute it, it will be working. So that means my friends, you can use the backslash in order to skip a character to tell Python this is part of your message. Especially if you want to use the same type of code in the message in the output. Now the escape character the backslash can help us in many scenarios. Like for example, let's say that I would like to go and print the path of something. So I'm going to say path double point and we can say the path looks like this. The folder is C and then we have the folder users and then the folder of the user bar. Now if I go and execute it, you will see again I'm going to get an error. It says there is something wrong in the syntax. So what is going on over here? Backslashes are always a special character in Python and each time you use them, Python going to think you are telling something. So for Python is not understanding what to do with this character B after the backslash. It's not command because Python going to expect from you using the backslash to 10:09 do something like skipping special character or making a new line and so on. So now in order to tell Python this is actually the content of my message, you have to have a double backslashes. So with that we are telling Python hey I want to have a real backslash in the output. I'm not using this one in order to skip any character and this is the only way in order to print a backslash in the output. The same thing over here. Now if you go and execute it and now Python going to say aha okay I understand you. You are just using the backslash to be printed in the output. You don't have any extra command for it. So in order to have a real backslash in the output you have to use double backslashes. As I told you, there are a lot of special things about the print and the backslashes. Let's have the following scenario. I'm going to go over here and say message one and then I'm going to have another print message two. So now if you go and execute it, I will have those two messages in the output. Now if you say I would like to have like space or like divider a blank between those two messages in the output. Of 11:10 course you cannot go over here and add a blank between the two prints and execute it and then expect to have as well blank in the output. This of course will not work because in the line number two there is nothing to do for Python. So it will not go and print like a blank. Now there is like two ways in order to do that. Either you can go and say print and then you don't put anything inside this print. So there is no message. It's blank. If you go and execute it, you will have here like space between them. But there is like smarter way in order to have a blank or a new line in the output by using as well backslash. So how we can do it? we can go and get rid of this third print. And now just at the end of the first message, we can go and use backslash and then the character n. So now the combination of the backslash and n, you are telling Python at the end of my message go and create a new line, new empty line. So if you go and execute it, you will get the same results. The first print going to go and print the first message. But at the end of this message, we are telling Python to go and 12:11 create an extra new line. And this is exactly why we have here a new line. This one came from the first print. And then after that we have the third line the message two. This came from the second print because Python going to create a new line for each print. So this is exactly how it works. And if you say you know what I would like to have like three new lines. So all what you have to do is to put them after each other. So back slashn back slashn. If you go and execute it you will get here three blanks three new lines. So this is really nice. And now of course you can go and put everything in one print. So I can take the message number two and put it exactly after the new three lines and then I can get rid of the second print and execute it. So what is happening here? We have the message number one. This is the first line. Then we have a new line that came from the first n. Then a second new line came from the second back slashn. And then a third line came from the third back slashn. But it's not empty because after it we have immediately a new message. So in the third line we have message number 13:12 two. And now if you don't want to see any empty or blanks between those two messages but you want to have everything in one print you can go and get rid of two new lines and leave only one. So if you go and execute it you are having two messages in the output but each message has a new line and that's because of this back slashn. So these two prints going to give you exactly the same result as this one over here. So this is really amazing use case for the backslash. We can compact everything in one print and we start splitting the messages using backslash n. Okay. So now I have one more thing about the backslash for you. We can use it in order to add a tab a space between the words. So let me show you for example if you go and remove this back slash n and go and execute it. Of course you can go over here and add like space in order to make separation between the words as well. You can go and use the backslash. So now in order to add a tab in Python you can use back slasht. So now once Python sees this combination back slash anti it going to go and add a tab. So if you go and execute it you can see we 14:14 have now a tab between those two messages. Okay. So now I have a challenge for you. Now I want you to print in the output the following your learning path and then we have three bullet points. So Python basics, data engineering and AI. But very important those bullet points they do not start immediately as a new row. They have like a tab before them. It just looks nice, right? But now the real challenge here is to have only one print. Now pause the video and go and do that. Okay. So I hope that you have done it. Now we're going to do it together. So we're going to go and use print only once. I'm not allowed to use multiple prints. And then double quotes. So let's start your learning path. Double points. And now we need the first bullet points. Python basics. But now if I go and execute it, I will have everything in one line. But I would like to have Python basics as a new line. That's why I'm going to go exactly over here and make a backslash and end. So if I go and 15:14 execute it, I will get it in one new line. But we are not there yet. I have to have like a tab. So exactly after the new line, we're going to have a tab. So back slash t. And if I go and execute it, I will get my tab as well. So perfect. I have my first point. Let's go to the second one. We're going to have as well minus data engineering. So if I go and execute it, everything going to be in one line back slash n back slash d and execute it. So with that I got a new point in a new line and as well I have a tab before it. Now we're going to go to the last one. So minus ai and if I execute it I will see it exactly after the engineering. I don't want that. I want it in a new line and as well with the tab. So if I go and execute it, I will get the last point in the output. So as you can see the backslash gives me a lot of flexibility in order to put everything in one print and I can control exactly how to design the output of my message. Okay my friends, now to the last technique. As you can see over here, our message is not really nice like everything in one 16:16 big line and you have to scroll left and right to see the whole message. Now if you have like a long message and you don't want to put everything in one big line, you can go and split your message into multiple lines and as well using only one print function. So now let me show you what I mean. Your learning path going to stay over here and then in order to see the rest I'm going to go and hit an enter in order to go a new line in my code. But as you can see things going to get read right. But I'm going to go and keep doing that. So for the second message a new line and for the third one a new line. Now, of course, if I go and execute it, you will get an error because Python will not allow it. Now, in order to fix this, we can use the triple quotes. So, now at the start, we're going to go and add triple quotes. And as well at the end, we will add triple quotes. Now, we can see in our code, we don't have anything red anymore. And if I go and execute it, you will see it is working. But we are getting as well extra new lines. So actually if you're using trouble quotes if you start a new message using a new line in your code it going to be considered as a new line. So that means 17:17 we can go and get rid of the new lines. So we don't need those back slashes and n and if I go and execute it I will get the exact same results. So this is really nice way in order to add multiple lines in your code and as well multiple lines in the output using one single print. You can do that only if you introduce three quotes. All right my friends. So with that I have covered let's say the most important tips and tricks that we can use inside the print. It is really fun in order to design an output for your users. Now my friend if you are total beginner in Python I know that you will have always the same question. Why do we need this stuff? How we going to use what we are learning in real projects? Let me show you real use cases in projects for the print function. So for example we have this code. You don't have to understand all details but I want you to understand the use case of the function. So now we have here a lot of values and calculations and logics. Now if you run this code you will not get anything in the outputs because 18:17 everything is happening behind the scenes and we don't have like a window to what is going on and this is exactly when we need print. Now in order to see more what is going on in our code and to see inside the box what we're going to do we're going to go and print the last results. So I'm going to go and say final total double points and then the final total. So if I go and execute it now you can understand aha the final total is this value. So we do it like this in the project. In order to see the results we use a print. So we are sending the value from our code to the output. Now let's say that there is something wrong. I'm not really sure whether this value is correct. And in our code we have like many steps. And here again we use the function print in order to understand each substep. So for example I can go and place a print in between here. And now this time we're going to say here subtotal is equal to as well subtotal. Now my friend don't worry about the syntax and what is going on here. I just want you to understand when 19:19 we use print in real projects. So now if I go and execute it now I can see and understand aha the subtotal is this number and this might help me to understand the substeps inside my code and whether my calculations are correct. Now I can see the subtotal and maybe I want to see as well the discount. So I'm going to go over here as well and print as well this intermediate result the discount. So discount and as well execute. So now I see a lot of stuff the subtotal the discount and the final total and actually the calculation is correct. So my friends, this is a very important use case in real projects. We use it in order to print the results of our calculations in the output that's going to make things more transparent for us and going to help us in testing or debugging if there is something wrong in our calculations or logic. So this is how we use print in real world projects. Okay, my friends. So now let's do a recap. Print is a built-in function in Python and we usually use it in order 20:19 to communicate something to the users to show the progress and the steps of your logic in your code and as well we use it in order to debug and test. So the print function is very simple but yet very powerful and my friend I'm going to promise you something that you will end up using the print function in every Python scripts from the day one in the beginner level until the very advanced levels in Python. you will end up always using print. All right friends, so let's track our progress. With that, we have covered everything about the print function in Python. And now next we're going to speak about very fundamental concept in Python, the variables. This can make our code dynamic and smart. All right, my friends, one more last thing. If you really enjoyed this type of tutorials where it's free and as well I sketch those complex concepts and you want more content like this, then support the channel by subscribing, liking, commenting. This can really help with the algorithm and going to support the channel by reaching others like you and as well can help me to make more content like this. And of course, thank you so much for watching and I will see 21:20 you in the next video.