#3 Python Tutorial for Beginners | Getting Started with Python

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] welcome back aliens my name is wi d and let's continue with this series of Python now we have talked about what is Python and we have talked about how to install Python on your machine it's time to start with the actual stuff right and we are waiting for this now this step one would be of course you need to open your IDE now remember in the installation we have installed two software's one is the interpreter and second is your PI charm but will not be using PyCharm in this tutorial we'll start with the basics so that you will be having that hands-on experience on IDL II as well so let's try it out so what I will do is I will open my eye IDL II and in that so this is your prompt okay so this is your prom this is where you will type your code now you know before going for the actual code we have a question here why do we code and why do we like a code now think about this we are living in a world where everything is done with about computers for example if you want to send an SMS if you want to send an email you don't have to do that your computer will do it for you if you instruct it example nowadays we have this amazing thing you know we have Siri on iPhone and then we have Google assistant on Android phones you know you can ask them to do things for you example you want to set an alarm you can you know they will do it for you but then how they understand what you want to say so you need to talk to a computer and if you want to talk to your computer you need to understand their language right and the language which computer understands is binary code which zeros and ones now that means if you only talk to computer you need to you need to talk to them in terms of zeros and ones now it is not actually possible right of course so what you have to do is you need to use a language which will which both will understand and of course do we so we all know English language but computer will not understand plain English right because we have some grammatical stuff here so what we have done is we have created programming languages now those are not actually example we have high-level languages now those are not exactly a binary code and they are not even exactly the same as English they are somewhat you know they have their own protocols they have their own grammar which we use so when I say English so we have level one English then we have level two which is programming language and then we have level three which is your which is your binary format so you understand English so what you will do is you will learn a programming language let's say Python in this case and then you may write a Python code which will get converted into binary format which our Committee will understand so if you say hey computer do something for me so let's go with this very simple stuff here let's say I want to add two numbers so you will say hey computer two plus three a company will say ok five but then how we talk to a computer in this case so we are using Python and then we have a interpreter in fact in Python is for now as as we as we discussed it's one of the easiest language right so what I will do is I would say two plus three this is the simplest task you can do on Python so I would say two plus three it works you can see we got five yes this is working what else what about subtraction you know we we love mathematics right so let's apply all the items of operations here let's try nine minus eight it should be one right we got one say yes subtraction also works okay what else we can use can we use multiplication let's try four into six which should be 24 yeah that's right we got the answer so yes addition subtraction modulation works what about division okay let's try some of that's a division it should be eight divided by four and I'm expecting answer to be - yeah it's - but hold on there is a difference here you can see if when we say two plus three be called five nine minus eight which is 1 so when you subtract two numbers we arguing that number right and specifically this are integer numbers right we all use integers but then when you divide a number it is giving you a point value now this point which is also correct float numbers so we have integers and then we have float now flow it stands for floating point representation okay but why it is 2.0 because we need divided numbers you might get two point values at example when you say five divided by two you will get two point five example let's try it out so if I say five divided by two you got two point five and you want that point five value right that's why it converts your number or your output into a float value because you want it they want to view the exact value but what if you don't want it what if you want only the cushion by the example when I say 5/2 you want only two you don't want point 0.5 value so we can do that you know V if you want only integer output so we don't want float now we want on the integer you can do that you can say 5 instead of giving 1 / you have to give 2 / now this is also called as integer division all it is also pass flow division say well I said on this query what - so this is working yeah okay what else we can do here can I do you know combination of this automatic operation example let's say 8 plus 9 yeah and then subtract it by let's add 10 is it possible and let's try it so it works you know so you can have multiple operations but then we have to follow grommet right if you say 8 plus 9 and then subtract you forgot to type 10 there it will give you an error which is invalid syntax and that's why you need to follow the grammar as well so in as in when you learn a language you need to follow grammars in the same way in programming as well you have to follow grammar can I use those brackets top which we used to use use in mathematics yes we can so example let's say we have 8 and then we I'm adding that value but then I also have a value which is 2 into 3 now which one will be done first of course the multiplication part right but then what if you want to do it all let's try this first so you can see we got 14 which is 8 plus 6 but what if I want to say 8 plus 2 which is 10 and then 3 so in that case you need to use brackets right if you remember the point mass rule so I would say 8 plus 2 which is in the brackets and then in 2 3 so you can see we got idea so yes this also works so when you multiply so if you give a bracket it will be solved first okay this is cool right nowadays we can do here what if I want to find a power of all you can say exponent you know so let's say if you have to raise to 3 or 5 raise to 6 how can I do that so I will say - I want to find cube of 2 so in that case I can say 2 into 2 into 2 yeah we can do that but then though what if you have 2 is to 10 you cannot simply type 2 into 2 into 20 10 times right because this will give like answer is 8 otherwise you can say - you can give double star and 3 so double star or double hash tricks simply means powered off so when you took two days to three so this is two hash trick hash tricks three and you can see we got eight so that's how you have to find you have to do this all this operation so we now we know how to add two numbers how to subtract two numbers and then multiplication division a flow division but what else we can do here in fact you know we can we can also do modulus now it is modulus here let's say I'm dividing I'm dividing two numbers which is ten divided by two or maybe three in this case that was a 10 divided by 3 it will give you 3 right but then we also have a remainder here which is 1 so if I even S it then divided by which is the integer division you've got 3 that's right but what if I want to remain the part of it so I would say 10 and we have to use a special symbol here which is modulus and we'll say 3 you can see we got 1 which is a remainder so when is a 10 more than 3 you will get a limiter which is 1 okay this works yay now you know all the operators right now what else we can do here not till this point we have discussed about you know the the we are discussed about two types one is the integer type which we have done here and then we have talked about float what other types we can have here can they have string you know what the string means it's a combination of characters example my name Naveen is a string Python is a string --kavitha is a string YouTube is a string right so we have to use can be can be a string here we can let's try so what I will do is whenever you want to use string you should be it should be you should always use single code or double code so let's try so I will use my name first so I will say single coach and I mean so we have to use a code Co so you have to say Naveen and I know you can see we got the same value and I mean we got Naveen there is another way of printing these values you know you can also print by providing some functions or that's a new word now note of functions in Python language we have certain functions which we can use another function is print now what print means or what function means is it takes a set of tasks which you will be doing so example in print which is inbuilt it has certain tasks which it will do you just need to call it can we define our old functions yes we can so print is a inbuilt function we can define our own functions as well so you can do all this operate in one function you can do that but we'll see that later how do we define our own function but time being let's use print and when you have a print you normally give this down package to pass any parameter let's say if you want to pass something to the function you can do it here in this case I want to pass my own names I'm saying print naveen so you can see it works you got Naveen as a value there okay that works now if you say difference between the windy partier command here if you compare this one with this one see the output so in the earlier one the single quote is getting printed as well but in the second one it is only printing my name and that looks beautiful you know okay let's try to print something else on once a print and here I want to print let's say nothing's laptop so no means laptop it should print novice laptop right when I say enter oh we caught an error that's weird now what went wrong here now if you observe here we have single code as a starting one and then we also have a single quote here so that means that is one string and then this thing which is s laptop it is not as a part of that single code that's what that that's where the problem starts so you cannot simply have single quote anywhere right so how do you solve this problem to solve this problem we have two solutions the first one is you in stop using single quote you can use double quotes example you can say print and in double quotes you can say in navin's laptop now since so starting and ending is done with the help of double quotes you don't have to worry about the single quote in between if I say enter and you can see record the output as the wins laptop now what else what are the commands we can do so this this thing works here I willing to think about this what if I want to print double quotes in a statement let's say we have print inside double quotes I am saying now in laptop but I want to print laptop in double quotes can I do that example the output should be Naveen and laptop but then the laptop should win double quotes we cannot do that because you know the first double quotes and second double quotes will be getting entered here so this this is my first string what about this laptop now in that case we will be using single quote so single code and end with single quote so you have to make sure the string part should be different from the part which are inside so inside we have double quotes then outside we should be using single quote like that makes sense right so you can see we got the output but here's a trade what if I what if I have both in this string example let's say we have print I want to say navin's laptop and you can see we have both now we have double quotes and we have single quote both that's what the problem starts so what you will do now because if I say enter you got invalid syntax in that case we will say single quote navin's and then in double quotes will say laptop the issue is with this s right this s is coming before a single quote so you have to tell your Python hey Python can you just skip that special meeting of that single quote and the way you do that is by giving a slash so when you say backslash it will make sure that you it will ignore the special meaning of that single quote so we're not Center it works you know so this is the basic fundamentals which we're talking about let us do some fun here so I can we continue with the pain later but we have some fun thing here what if you want to print having two times someone you want to print now in three times can I do that of course you can try it you can type Naveen and then the beam again or you can also use a plus character here so if you want to concatenate two strings so we have two strings here right we have Naveen and we have Naveen so when I say enter so because you can see we have Naveen and that means we are combining it what do I want to print in domain three times or ten times in that case you know you can play with numbers as well so you can say ten into in single quote you can say Naveen and center you can see record Naveen ten times yeah so but his phone actually you know you can you can play with it you can do some experiment that's amazing what if I want to print this one you tell me okay UK you try to guess it will it work or not just pause the video guess it let me know in the comment section of it will work or not and then we can continue what I will do is I will throw in something I would say C colon slash I have a directive as Docs slash Naveen so pause the video think about it and let's see what output you're giving let's try answer in term oh this is weird we weren't expecting it will print say : Doc's slash Naveen but unfortunately it is giving a new line and then I wind what's wrong now /n a special meaning in Python what is that special meaning and the meaning is it means new lines a slash and means new line and that's what is happening here it prints it is printing C colon slash dogs and then it comes to a new line because of slash and it is saying oven ok what I do is I want to print it I want to print it as it is how do I do that it's very simple you just need to cancel the special meaning of that thing right so you want to print this string as it is which is also for this raw string so I want to print this one has a lower string in that case you just specify our before the thing and it will say C colon slash dogs slash Naveen so we are printing this stuff as it is so when you say art it means raw string don't try to convert it that's what you are saying to Python hey don't just try to cut don't try to convert that slash it into a new special character and Center it works yeah so everything is looking good now so I hope you enjoyed it this stuff which we are doing here I'm playing with this stuffs and this in this video we have only talked about how can we use certain operators and then playing with printf in the next video we are going to talk about how to use variables now if you are enjoying this series let me know in the comment section about your thoughts and if you have any question you can put that as well I do read your comments by the way and if so that I can answer that in the next video and if you are liking my videos so click on the like button and do subscribe the channel for further videos thank you so much everyone bye you
Info
Channel: Telusko
Views: 2,513,707
Rating: undefined out of 5
Keywords: python, teluso, idle, script, string, immutable, navin, reddy, telusko, learning, java, tutorial, how, to, arithmetic, operation, add, subtract, divide, multiply, addition, subtraction, multiplication, division, modulo, integer, float division, brackets, bodmas, power of, escape sequence, escape character, print, raw string, exponentiation
Id: DWgzHbglNIo
Channel Id: undefined
Length: 14min 49sec (889 seconds)
Published: Mon Jul 02 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.