字幕資料室
python data
-
作成者
th*****
-
字幕作成者
-
-
登録日
2021-06-08
-
言語
မြန်မာ
-
ダウンロード数
132
-
動画名
-
字幕ファイル
subtitle.srt [550.86 KB]
-
内容
I'm going to talk about the focus of our course mastering Python for beginners in data science.So let me explain what kind of areas in this particular course we are focusing the most.In fact, because this is a course, for beginners, that's a beginner level course, we are notassuming the the course taker to have any experience whatsoever about any computer programminglanguage before, not even not even the problem, problem solving paradigm that lies in computerscience. So, we will, we will focus on problem solving for a bit. And we will actually startfrom the very beginning what problem solving is, particularly in computer science. Thesecond focus of this particular course, is mainly telling you why we are choosing Python,why Python is so important, particularly for data science problems. The third focus andthe main core focus is to learn Python, obviously, once we know what is what what are the techniquesto solve a problem. And once we know that Python might be a very good language to gowith, then what is Python, how to learn it? Well, the Python is the main core and mainfocus of this course, obviously, we will start from the very beginning, very, very beginning,which means we will start from how to install Python for example, we will start from there,and then we will see what are variables, I mean, very, very beginning, and then progressivelywe will be moving on and on and on to data structures to complex structures, but thattransition from 02 onwards, that transition will be very, very smooth. I mean, whateveryou know, so far, in the course, that will be helping you to gain more complex structuresvery, very easily getting the understanding of a lot of structures very, very easily.So in this Python, we will include all concepts of Python in general. And, and one more thing,after I mean learning, despite on the way we the way we organize this course of learningthis Python, you will be having an understanding of other languages as well. I mean, the contentshere are explained in so general way all over the Python syntax, but the general but butbut the concepts are expressed in so general way, the problems that we picked to solvefor practice are so generic that you will after this particular Python course, you willbe having understanding of programming languages in general. So data science is one other focusof this course, actually, the whole course is organized in a way that it teaches youabout Python, it teaches you problem solving, it teaches you something about overall programminglanguages and how computer can be used to achieve the solution of different problems.And and using Python, of course, and then we will be introducing the data science packagesthat are available in Python, because they are really, really fast, really fundamental,very easy to use, and very, very powerful to handle large amount of data very quicklyfor data understanding for visualization, for cleaning, processing, and a lot of stuff,what we are not focusing at because that's important. Knowing that what kind of thingsare are are the things that we are not covering, for example, we are not covering object orientedprogramming, we are not covering exception handling, we are not doing web development,or any general kind of tasks that are doable in Python, we are not focusing on those things.Everybody solves different problems every day. Some problems are easy to solve, andsome are difficult. And yet some are impossible to solve. They are called unsolvable problems.But think about different instances of the same problem one needs to solve again andagain. For example, sorting the sale records. And let's say we are sorting the sale recordswith respect to the sale value. And we have to do it after every eight hours. If the numberof instances if that number is huge, the optimal choice is to automate the solution if theautomation is possible, but how how to come up with the automated solution to come upwith a general solution that works for every instance of some problem. That is one thing.But to get that solution running on a computer is yet another thingProblem Solving deals with formalizing a general solution for that works for every instance.And programming languages, like Python deals with the running of that solution on a computer.Python, as, as we will see, makes the transition from problem solving to the running solutionmuch easier and quicker. And that's one big plus of Python. A lot of words, I know a lotof words. Let me take an example to clarify what I said, Hold on till the end of thisvideo. And I will make everything what I said so far, crystal clear. So let's take an example.Let's dive into an example to see what I just said. Let's say your a, and your friend isB. And your friend B is always willing to help you. Let's say you found such a friend.And then a just said, I want off just for some days. But be said, but what ghobadi enjoy.He said, someone have to do my job in my absence. And then be said, That's it? Is that yourproblem? I'm available? As always go buddy, enjoy. Man. He said, great. You're a truefriend. Okay, I'm leaving, wow. And be just said, Hey, wait, what do I have to do? What'syour job? At the end of the day, I'm going to do your job. What's your job? What do youdo? And then he said, after every eight hours, pick the email of the customer when the maximumsales. So that's what you have to do. He said, Okay. But from there, I mean, I have to pickthat email of the customer from where, where are the records? He said, Well, there aresales records. I mean, at the job place, there are sales records. And you have to pick theemail of the customer with maximum sales. We said, Oh, okay. But wait, what, what shouldI do with the email that I just picked? Then he said, oh, there is an other record calledpriority records, just write that email after eight hours, just write that email in purityrecords. And then be said, that's it. That's all your job. And he said, after so relaxed,he said, Yes, that's my job. That's all. No, think he leaves and later that day receivesa call from B. And B said, I don't really know what to do. Can you tell me step by step?What to do? Focus on again, I'm reading this particular sentence again. Can you tell mestep by step what to do? I have sales records with me having all the records for the lasteight hours, what to do, I just messed everything up. I don't know what to do. And then at thecall, he just described a procedure to be for his job. That procedure or a general solution,let's see the solution. He said number one, start from the first record, there may beseveral columns of the record, the customer name, the customer phone number, the customeremail, the customer products that he buys and the total sales. And in the point onesaid, he said, start from the first record, and focus just on the sales column. Okay,then, then after that, go to each next record one by one, and find the record with a maximumsales. Obviously, once you have focused on the sales column, you're just comparing salesof different records with each other and will eventually come up with a record that havemaximum sales. Number three.If there are more than one records with maximum sales, it is possible that the maximum salesvalue let's say is 100, whatever the units are, and there may be two or three or maybefive records with the maximum sales 100. Then which one to pick, as described here in Stepthree, that if there are more than one records with maximum sales, then pick the first onefrom top to bottom and ignore the rest I mean, whichever is the sole. So let's say you havefive records with maximum sale value, which record appears first from top to down, justpick that one and ignore the rest. That might be a policy that might might be a tie breakingpolicy, but just do that. And then the fourth step is focus on the email column of the recordyou found in step three. In Step three, you found a column with maximum sales. Step five,see the email address and write that address in the priority records. So that's for theeight hours, then repeat this process, see the step six, then repeat this procedure,after every eight hours, I'm gonna repeat this procedure, I mean, you'll see the thesolution a is communicating to be in in this in these kind of steps. It it gives me Itgives a precise idea of what to do. Still, there may be some, there may be some questionsto be is maybe asking, for example, B may ask how to find out a maximum, B might bethat person who don't know how to find out the maximum. And third, for example, anotherquestion we might may ask is that when when I'm going to write the email address in thepriority rock records, where should I write at the very top or at the end or somewhereor, but at the end of the day, a solution a step by step solution is required for communication,this kind of if you see the solution, although it has some it may be explained in there maybe more steps that should be added, but if you see the solution, the step by step solution,this is a general solution. This is a general solution, much more general solution for everyinstance, but every instance I mean, after every eight hours, you will be having somerecords, and you have to do this procedure on the records for that eight hours. And thenafter that, that after that eight hours, you will be having more records to work on. Soafter every eight hours, you have the same, the problem is the same, but the instanceis different, because the records after eight hours are different. But but the but the solutionsays whatever the instance you are right, right now, whatever the instance is that you'rein, just perform these, these steps, a step by step solution, coming up with a step bystep solution is is one module of the one module of the problem solving. And there'sstep by step solution is called algorithm.algorithm. Obviously, the step by step solution is not always required to be communicatedin plain English or in natural language, you may come up with shorthands or shortcuts toexplain these step by step solution. So, the the more shortcuts the more precise and uniquemeaning keywords you use in your step by step solution, the more better communication ofyour solution takes place. And going from this step by step solution, which is justin plain English, going from this to a more concise and unique kind of procedure, thatthat can that kind of work that one step that will take us from there to there, that wewill see in the next video will be called a pseudocode. And from that pseudocode therewill be few steps that will take us to the second major problem that the problem problemlanguages will solve the get the solution running on a computer. So I'm just just inthis video i i wanted to explain you that solving a problem may not be that hard, Imean, coming up with a coming with coming up with a solution of a problem may not bethat hard, but communicating that solution or, or writing that solution in a form ofprocedure that can solve every instance of that problem that that requires a step bystep treatment of the procedure. And those those steps they should be linked in a sequenceand they should be unambiguous. And if a particular step requires more elaboration, that stepmight be broken down to further steps. But that step by step solution at the end of theday is called algorithm. Now that algorithm might be in English, but we will see in thelater video that there are better ways of expressing algorithms better than Englishor better than natural languages. So, so, if you have another problem come up with astep by step solution of that, though, every instance of that problem should be solvedby that step by step solution, which is called algorithm. And in the next video, we willsee how to actually how to actually eliminate the need of having English with us and howto incorporate the uniqueness of understanding of these steps or algorithm using using theconcepts of pseudocode. And after the pseudocode, we will see it will be very quick to jumpto any programming language and we will see that the Python is very close to what humansgenerally think, I mean, it's very easy, the transition will be very, very easy. So, hopeto see you in the next video and I'll be explaining algorithms in in, in a in a more kind of keywordway. And, and in the same video we'll be focusing on pseudo codes which are basically pre stepoff of the actual core of any programming language. So, hope to see you in the nextvideo. Okay, in in the last video, we were talking about the algorithm what an algorithmis and how to express that any any algorithm and we saw that algorithm is just a step bystep procedure. But, but how to express an algorithm may vary, I mean, you need not alwaysto have plain English to or any natural language to express algorithm. The reason is that thenatural languages are normally so expressive, and each and every sentence they may havemultiple meaning. So, it is it is a good idea to come up with a structured way to expressan algorithm such that each and every statement is completely unambiguous. And one such wayis is to express algorithms using flowcharts flowcharts are our graphical ways of expressingalgorithms. Here we are taking. The problem here we are discussing is is computing PEof different employees of some company. And the procedure of I mean, if there are severalemployees, let's employ one employee to employ three and so on. Let's say there are severalemployees in a company and having each employee has name, phone number, email and all thecredentials. And then let's say the pay is computed on hourly basis, and each employeehas worked certain hours for example, eight hours and each employee has an hourly ratemight be let's say 100 units, whatever the units areemployed to might have worked for example, seven hours, but the hourly rate of this employeemight be 200 different employees, they might have worked for different number of hours,and each employee can have a different hourly rate depending upon the capacity of the employeeor the or the job nature the employee is doing and so on. So, so, so, if we want to computepay of all employees, one by one, the procedure of computing pay is stays the same, the instancesthey differ for employee one, the value of our is eight the value of Raiders 100 foremployee to the procedure will stay the same the values of our end rate they will differso what should be the procedure, the procedure might be that you take the take the inputof let's say employ one or whatever employee you are going to compute salary for take thehours hours value in a in a placeholder call that place or call that placeholder as oursplaceholder or a variable y this is called a variable because for different employersthis value will different will be different, ours will take value eight for each one employeeone this this variable, this placeholder will take value seven for employee two and so on.Similarly, once whatever employ whatever employ for which you are going to compute the pay,if you have taken the hours from some records from some working records, then take the ratefor the same employer as well. So input this that step one in Purdue that is step two,the steps the sequence of these two steps may change for example, you take the you takethe rate value first and ours value later than that, but either way, that's one wayof that's one way of expressing this this procedure. And then you compute the pay bythis formula. So hours multiplied by rate. So maybe this is confusing writing a star.Maybe maybe We should write this cross symbol because that is more common in mathematics.Or maybe this whole line can be replaced by, by this particular line, maybe. So pay isequal to multiply hours. And rate. Maybe this is more expressive, but it completely depends,I mean, when you start writing pseudocode, or whatever pseudo codes you're writing, whatkind of keywords begin is a keyword and is a key word, what kind of keywords you're using,and stay with those keywords for example, if the keyword input is to use to take toget the values to to process on then the input should stay everywhere wherever we want todo such kind of operation. If you if you're using for example, the value get rather thaninput then use get always but come up with some set of keywords that are expressive,as well as concise and then take the sequence of those statements, each and every statementshould be should have a unique meaning, it should not be ambiguous, and the sequenceshould be in the sequence describe the flow of what is happening, what is going on. So,first we take hours, then we take rate these two values for for for any kind of employee,and then we will just multiply them and after multiplication, whatever the scene we wantto make, based on this pay, we will do that, we may we may record this value, display valueat at some other records register, we may we may print that value on a print slip, wemay have emailed this value to some other department or whatever to see and we wantto make, but the procedure really is still here, then based on pay whatever action weare going to do that that may differ. Similarly if we go this is this is I mean, some kindof structured example of, of the, of the expressiveness of an algorithm which is called pseudocode.And what kind of keywords you're going to use, there are no general keywords, I mean,some people may use get some people may use different kinds of keywords for it, but itis good to come up with a set of keywords to to describe the describe the solution ofthe solution of the problem in flowchart for example, everything every every statementhere, that is here in in pseudocode every statement is described as a shape differentshapes for different kinds of statements. If you want to take input, then you have todescribe that action using a parallelogram. If you're going to do some computation, youhave to express that using a rectangle the start symbol and end symbol the start andend of any procedure in flowcharts they are described by the ovals For example, this ovalin that oval normally the flowchart sequences from top to down, but it is always good tojust print the arrows to describe the flow, because in complicated flowcharts there arethere are loops there are if conditions there are so many things. So it is good always todescribe the flow using using arrows. So, now the question is flowchart or pseudocodebecause flowchart also looks like a very cool way of writing. expressing an algorithm andpseudocode is also a way of expressing an algorithm. Well, converting flowchart to actualprogramming code is somewhat tedious, writing a pseudocode beforehand, which is readable,which is precise, concise, as well as unambiguous then converting that pseudocode to code ofany programming language, that is not that hard, that is simple in writing flowchartsfor very complicated problems is somewhat tedious, because then it It also requiresanother transition from flowchart to reactive programming code. That's why writing pseudocodeis more feasible, if the goal eventually is to convert that pseudocode to some core ofprogramming language. So, you can go with flowcharts you can go with pseudocode eitherone is fine, but more feasible way of expressing algorithms is a pseudocode. That was justa very simple example. I mean computing, computing salary of an employee writing a procedurefor that. I mean, this is so simple, nobody make your writing that kind of writing solution.have this kind of problem as a as an algorithm or as a pseudocode as a flowchart. But thebasic idea is, is is is the same, even if you have a complicated problem if even ifyou have a problem with maybe many more steps, the idea is still the same. In the in thenext video, we will we will see a procedure how to how to make tea for example, that mightthat may look look to you funny, I mean, do we really want do we really want to know theprocedure to make tea? Well, the idea is not to learn how to make tea, the idea is to learnhow to express the solution of this problem making tea that's a problem, the solutionof this for how to how to express solution of that problem as as a pseudocode. And wewill see one more example of flowchart as well. So hope to see you in the next video.Okay. In the last video, we saw flowcharts and pseudocode, we just took an example ofwe took a very simple example computing salary or pay of employee of a company given hoursand rate. And I also described weatherflow, the the comparison between flowchart and pseudocode.And I said that pseudocode is closer to the core of some programming language, which eventuallywe need, because eventually we need automation of of a solution of a problem. And for that,we need a code of the digit the code for the solution, the general solution in some programminglanguage, so flowchart and pseudocode, and then the core of some programming languagelike Python,it is somehow in sometimes handy to to break the problem or to devise a general solutionof any problem for in first step in a flowchart because that is more expressive, and moregeneric, more general, maybe in a graphical way. And then once the proof of concept isclear, once it is clear that this is indeed a general solution, it has no bugs insideit has no errors, it will work always, then we can take another step to convert that flowchartto pseudocode. And then pseudocode can be converted to the the code of any the codein some programming language. But writing pseudocode right away, I mean, from the verybeginning without flowcharts is also a common practice. Either way, whichever way suitsyou. In this particular video, I'm going to talk about problem the problem is making tea.You might be thinking, what are the different instances of this problem I'm in making teais making tea. What what kind of different instances are there? Well, one person maybe liking tea with, for example, 1.5 units of sugar, whatever the units are, and anotherperson may want a tea with, let's say, two units of sugar, one person maybe, maybe needinga D with, for example, point five units of milk, and another one, maybe a different unitsof milk, and so on. So the procedure of making tea should stay same. And the instances whichmeans the different people want tea in a different kind of combination that may vary. So let'slet's like let's see a procedure first and flowchart. And then in pseudocode, for formaking a tea, for making tea. So let's start that that might look like that might lookyou look to you a kind of funny kind of problem. But that's a genuine problem. For example,if you want to make tea, what is algorithm for this? So first we start and then the firststep we do is we put teabag in a cup, that might be a first step. You can argue shouldthis be a first step should that be the second step and so on the sequence of By the way,solving one problem, you can have multiple algorithms for that. And do different algorithmsmay just vary because of the sequence of statements even if you have the same statements. So I'mnot talking about that the algorithm or the general solution is unique. You can have multipledifferent general solutions or procedures. So for example, putting a teabag in a cupthat might be first step, or the first step might be the boil, boil the water and pourthe water and pour the water in the cup and then put the tea back. Both are fine, I meanthis way or that way. So let's start with putting a tea bag in a cup. So that's an that'san input. We take the tea bag from somewhere. That's our input last time, I do You thatinput is taken as parallelograms put a teabag in a cup and then forget about that cup andboil the water somewhere there is a water I mean take the water from somewhere and boilit and see if after let's say five or six or seven time units whatever the time unitsare, see if the water is boiled or not assume that there is a test that tells you that thewater is boiled or not. So, there is a test available to you. So, you apply that testand check that the water is boiled or not if it is not oil then keep on boiling. Soboil it again. And assume there is a procedure of boiling of water in in in normal case,boiling water is just happened by I mean keeping the temperature high or putting that thingputting the pot of water on fire or something like so, but that that itself is a procedure.So,while the water again and boil the water again check if the water is boiled if no then boilit again. If not boil again then check if no then boil it again this is called a loopthis is called a loop or repetition you are doing the same kind of stuff again and again.Until there is a particular condition that is that is met. So in this case, the conditionis when while the water is not boil, keep on doing the same procedure again and again.This is called repetition or loop. So you boil the water again, check the conditionif the condition is true, for example, the water boil Yes, then come out. Then you'rethen you can exit this loop and come out. Then pour the water pour the water in in thecup. Here we should hear we should describe that is that the same cup or a different cup?Well, this see you pick up here is acting as as a placeholder where this tea bag andthe water is going in. So we have a cup, we put teabag in it, then we put the boil waterin it, but before pouring the boiled water in it. We just boiled the water. Okay, andthen after we have water in a cup and a tea bag in a cup, what should we do next? We actuallywe actually first test one sugar or need more sugar? If yes, then then add sugar. So let'sapply some arrows. If yes, add them add sugar. And then again ask do you need do you needmore sugar? Or one sugar now? Yes, add sugar. One sugar. Yes, add sugar that is again aloop that is again a loop while while the while you want sugar. I mean you test thatthe sugar is okay or not. Here you test that the sugar is okay or not or whatever sugaryou need. If Is that okay or not? Until that condition is not met, you keep on adding thesugar, add a teaspoon again, then test out a teaspoon that is again a loop or repetition.Once the condition is met once you know then exit this loop and ask what milk because somepeople just take tea without milk. Maybe somebody wants a milk maybe somebody don't. So wantmilk? Yes. So add milk. So that's that's a mistake this this loop should go there. Thereright there. And this line shouldn't be there. That's that's wrong. Add milk and then askwhat milk? Yes, admin, that's again a loop. Once you exit the loop, then you ask needto steer. Yes, steer, then ask again. This line again shouldn't be there. So that that'sanother loop. Once you exit this loop, then the T is ready, you serve that D finish you'redone with the procedure. Now let's see the same procedure in pseudocode program is thekeyword and that's what program name is program make D what is a keyword put teabag in a cupwhile water not while while is a key word, while this is not while this condition isnot satisfied, keep on doing this. Whatever written in while and while is is the bodyof this repetition are called loop. So while water is not boil, boil water. Then againcheck water boiler not know what again. I'm in keep on boiling. So this is repetition.Once the water is boiled, which means this condition is becomes false what not oil becomesfalse so water boil, then you exit this loop, you pour that water in cup, that's again akey word, you in a cup, and then you ask, okay, need sugar? Yes, add sugar, need sugar,yes, add sugar. So you keep on doing this until you don't need sugar anymore. So, that'sagain a loop. So, so, you might be thinking that why we are writing this add sugar andthis boil water to writer to this this why we are really indenting this that style ofpseudocode to just display that this is inside this this is this particular statement orset of statements are called the body of the loop and this end Oil should be here in thisalignment here in this line and so, there is a there is a bug in this slide this shouldbehere okay once this condition is false sugar needed no then you can exit this loop andyou go here while milk needed yes add milk, check again milk needed yes add milk milkneeded yes add milk. Once this condition becomes false milk needed no then you can exit thisloop, you can just go to here. While latest here need to steer steer D need to steer yessturdy he was there yesterday, once this condition is false get out and your tea is ready Dowhatever you want to do. This example was so simple, but it expresses a very powerfultool in in the pseudocode as well as in flowcharts. And that tool is sometimes called loop whichis there to repeat a particular procedure whatever procedure you want to repeat againand again to until there is a particular condition that is met that is loop loop is there. So,the The purpose of this slide is was just to just to make you make you convinced andmake you comfortable with the pseudocode and flowchart we will not be talking about flowchartsany further from here on we will we will be just talking about pseudocode in just oneor two more videos. And then we will be directly going towards from we will be we will be comfortableenough with pseudocode for solving certain kinds of problems that we will then eventuallybe moving from pseudocode to actual Python code. And and I bet you I'm going to tellyou that the pseudocode in the next video I'm going to explain that will be very, veryeasily will be converted to the actual exact Python code. So in the next video, we aregoing to actually solve a problem of finding out minimum value from a list of values, sometimescalled the searching problem, we're going to solve it by first using pseudocode. Andthen in a later video, we will see how to write the actual Python code for that problem.So hope to see you in the next video. Okay, let's dive into real problem. Let's say you'regiven, you're given a list of numbers, let's say, let's say l is some list. with numbers,let's say we define list by these, these square brackets, let's say the list contains 23.Let's say that's a value minus four, that value is zero, that's a value 73. That's avalue, and maybe maybe minus 10. That's a value, maybe 13. That's a value. So let'sjust take an example that we have 123456 values in a list. So and that list is basically wetook the list here as L and we just describe that let's say the list is declared by orexpressed by the square brackets, and the elements of the list, they are separated bycomma. That is just our convention for this kind of problem for this problem just forthis code. And And I'm not talking about any particular programming language yet. Thisis just a list of numbers. And let's say we want a procedure that finds out the minimumvalue of any list. Well, first of all, why this problem has multiple instances. Well,we need to come up with a solution that works for any list for example, if the list is ifthe list has these six values, then the procedure should find out the minimum In this list,the minimum value in this list out of all the values is minus 10.Because minus 10 is smaller than every other value. 23 is bigger minus four is smallerthan 23. Zero is bigger than minus four, because the, the value with negative sign, it is smallerwith the value of a positive sign. But if you have two values with negative signs, thevalue with a bigger number, in terms of magnitude is actually smaller in negative sense. Soif you compare minus four and minus 10 minus 10 is smaller. In minus in minus domain, inpositive domain, the result is different. So I was talking about why this problem hasmultiple instances, why you need a general solution for that, that's less just go andfind out the minimum that is minus 10. Go home happy? Well, we need a solution thatworks for another list. Another list with different numbers. And maybe different numberof numbers. Maybe in this list, we have six numbers, another list may have 74 numbers,another list may have 1 trillion numbers, we want to come up with a procedure that alwaysfinds out the minimum value in that list. Obviously, the minimum value may repeat, Imean, the minimum value may occur more than once in a list. So what is a minimum valuerather than knowing how many times that occur, what is the minimum value, that's a problemfinding out a minimum value, and we want to find out, we want to come up with a procedurethat finds out the minimum value, regardless of the list, whatever the list is, this procedureshould actually return or end up finding out the minimum value. So, in this particularcase, again, for this particular example, the minimum value is minus 10. And we willtake example of this list, and we will see how to code a procedure for that. So but butbefore starting this procedure, what kind of things we really need to to, to write apseudocode. For this kind of problem, we may start by writing that program, like in theprevious video, program name as search. And then we take input or input list, then wetake input, the number of values in the list the total number of values, and then we moveon as as we want to move on. But writing out a procedure in terms of pseudocode, it isalways good to to avoid these input statements inside the pseudocode. And always supply whateverwhatever needed, always supply the instance, from outside and assume that the instanceis supplied and then just work on that instance. Rather than reading the instance. Rather thantaking the values of instance, a particular instance from inside the code, it is alwaysa good practice to, to, to supply the instance from outside, so supply the list from somewhere,and this n is really the size of the list. In this particular case, let's say if thisis the list, then that list will be there, supplied from somewhere, but we'll see howto supply that. And this n value here, in this particular case, the N value is six thetotal number of values in the list 12345, and six, these are six values. So it is agood practice to rather than writing program and then this, just write the name of theproblem you're going to solve in this particular case the name is search minimum from list.And then this particular we are talking about this list l with total number of elementsas n whatever the values inside the L is we do not know and and this n may take differentvalues, l can be different, this n can be different for different instances. But itis not a good practice to take input from inside here. Then, one more convention isthat, let's say list of two represents the second element in the list. In this particularcase, L of two is basically L of two is basically the second element in the list, which is minusfour, L of let's say three is the third element in this list, which is a zero, and so on.So let's let's take a convention, that whenever we want to access the elements of the lists,whatever whenever you want to read the elements from the list, we will read the element numberby giving the element number here let's say whatever the if we write L of AI, that meansit means the ayat element of the list.So, first we take a variable, we are assuming here that the list is supplied to us the totalnumber of elements in the list is supplied to us. So we first take the minimum value,we, which we really want to compute the minimum value we want to compute, but any list canbe supplied in this procedure. So what's the procedure, the minimum value that we wantto compute, we just consider the very first value of the list in this case, the very firstvalue is 23, we consider that is the minimum value. Obviously, that is wrong, this is notminimum value, minimum value may be somewhere else, or maybe this one may be somewhere else,but we are not sure that the first value in the list is the minimum value. But let, let'sjust hold on for a moment and move on. Let's say the minimum value is this here, this iscalled the assignment assignment. This min value is a placeholder or a variable, andI have assigned this value l one to it. Now, from here onwards, the min value will be willbe will be having a value which is 23. In this particular case, okay, so min value isthis, which is 23. Now, let's declare, let's declare another variable, which is calledcounter, we may need this counter. And let's declare this with two, why we are declaringthis with two it will become clear later on. So now we so min Valley right now, for thisparticular list, the min value takes the value 23. So and counter takes the value two, theseare two things for these two variables. Now, we apply a loop while counter is smaller thann smaller equal to n. Remember the value of n for this particular example is six, andcounter here is two. So because counter has value two, while two is less than or equalto six, first check whether this condition is true or false, because if this conditionis true, then you will go to the body of the loop, then this whole box will execute. Ifthis condition becomes false, then you will exit the loop and we'll go out. So now counteris to the so two is smaller or equal to six. true false. That is true. So the conditionis to two is indeed smaller than or equal to six, that is true. So we will go insideto the box and see what happens. Then what we will do, we will pick and pick a valuefrom at the index counter. Right now the counter has value to L off counter means pick thevalue, because the counter has value to pick the second value, which is minus four andpick that value minus four from the list, pick that value and copy that value or assignthat value to a variable v. That's a new variable we maybe needed somewhere okay. Previouslythe min value which is a variable, it was containing the very first value which is 23.Now we have picked the second value the counter value is two. So we have picked the secondvalue from the list, which is minus four. Now we compare if the value now which is minusfour is that value smaller than our minimum value. So far, the minimum value so far isis 23. So minus four is smaller than 23. Yes, the condition is true, if the condition istrue, we will go into this block, otherwise we will go into this block. So right now thecondition is true. So we will go in this block and minimum value will just be replaced bythe new value. And the new value right now is minus four. So because a minus four issmaller than 23, so we are here in this body, the if condition becomes true, you're in thisbody, and the minimum value becomes whatever the value is in V and right for this example,the value in V is minus four. Okay? So if if if you go into the if condition, then you'renot going into the else part, either you're going to F part or in the else part one ofthem. Okay, so then we move back Oh, there's a bug here we need to add the counter. Weneed to increment the counter here after after this. Before this. There is another statementincrement the counter. increment counter. That's another statement increment counter.So Now increment the counter after this if part increment the counter, and the counterwill become three. Now, we will repeat the procedure and check three is smaller thansix, yes, we will go inside, and we will pick now the counter value is three, we will goand pick the third entry. And now the third entry will be in V, the V will now containzero. Previously it contained minus four now it will contain zero min value is containingminus four now, so zero is smaller than minus four, no, if zero is smaller than minus four,then do this. But zero is not smaller than minus four, then go to the else part. Andas far as just saying just go on do nothing, I mean don't do anything. So when you're heredon't do anything except if condition increment the counter again. Now, you increment thecounter the counter value will become four and the value add for is 73. First of allcheck for is smaller equal to six Yes, we will contain the value at index four whichis 7373 is smaller than minus four no do nothing and given the counter check the if conditioncheck the while condition now counter will be five five is smaller or equal to six Yes,pick the fifth entry because country's fifth the fifth entry is minus 10minus 10 is smaller than minus four yes okay. Replace min value with the new value. Nowthe min value will contain minus 10 okay because if has executed else will not execute, youexit the if condition and then you increment the counter the counter will become six. Nowsix is smaller equal to six Yes, because six is equal to six hence the condition is true.Now, you go and pick the sixth entry which is 13. Check 13 is smaller than minus 10 becausemin value is containing minus 10. So far, no that is false go to else condition, thetwo else part just go on to nothing, increment the counter, now the counter will become sevenand you go back and check the condition seven is smaller equal to six false exit the loop.Okay, exit the loop, go to this condition, go to this statement. Now Now you're out ofthe loop and return the min value. And see the min value here is containing the actualmin value which is minus 10. So that's how we search the minimum, this return is alsoa keyword. So which means if we if we just if we just if we just use that function, ifwe if we just use that pseudocode with if we just use that pseudocode for this differentkind of lists with with its sizes, whatever the list, this is this was just one exampleif we chain the list, the procedure will work one one bug in in the code was the incrementcounter statement was not there, it should be there after the end F and before this endwhile here. So this that was the pseudocode of searching a minimum. In the next videowe are going to use this pseudocode and we will we will see how to rearrange the valuesof a list or sorting the values of lists such that all the values that are smaller theybecome earlier than the bigger values. And the problem is called sorting. So in the inthe next video we are going to talk about one more problem, very famous problem calledthe sorting problem. And after that problem, we will be going towards Python. Because afterthat problem, you will be having a fairly good idea how to solve a problem how to writea pseudocode for a problem. And the way we are writing the pseudocode is very close tothe actual Python code which will become so clear to you. So hope to see you in the nextvideo. Okay, in the last video we talked about we talked about this how to find out minimumvalue from a list of values. And we came up with an algorithm with name search men fromlist. Here we have just made a little modification that rather than just returning the minimumvalue, we are also returning the position of the minimum value in the list. So for example,if the list is 17024, let's say in nine letter that's our list. There are seven numbers inthe list, the minimum value is zero. so the value the minimum value itself is zero, butthat appears in position three. So when when this procedure will end, the min value willcontain zero and the ID x which is the position at which the value the minimum value was achievedthat will contain three So, not only we are not only we are finding out the minimum value,but also we are finding out the position of the minimum value.This procedure, our pseudocode actually describes a very simple, very simple concept, you considerthe very first value as a minimum value and the very first position as a position of theminimum value, and then traverse the list element by element and, and see if you findany value that is smaller than the minimum value so far, if that is found, then replaceyour minimum value with the new minimum value and update your position number. And thenkeep on moving till the end of the list. So, so that's what, that's the concept behindthe behind this algorithm searching minimum from the list. And to traverse the list weuse this loop while loop. So next we solve a problem called sorting problem very, veryfamous problem in computer science. So the problem really is let's say we have a list,let's say 14035. And seven, let's say and the sorted order the ascending sorted orderis the order in which the list is presented so that the minimum value occurs first, thenthe second minimum, then the third minimum, and so on. So the sorted order for this particularlist will be this, so this is the result, this should be the result of this sortingprocedure. So let's see how can we solve this problem, we named this algorithm as sortedlist and sorted list contains this L. In this particular case, the L is simply this. Andthis n is the size of the list. In this particular case, the size of the list is six, so six,and right now l two is empty. So although we have to populate l two, but right now itis empty. And counter again, we initialize the counter with one. And as as long as theConqueror is smaller than six, we keep on we keep on moving inside this, this block,that's the that's the body of the loop. So what we do is we pass the list and the sizeof the list. And we use the previous algorithm to find out the minimum from the list. Sothe minimum from the list will be found as zero and its position will be found as three.So min value will contain zero, and Id x will contain three, then what we do, we pick thisminimum value and insert in L two l two was initially empty. So we insert in L two, weinsert the minimum value, which is zero so far. And then just in the original list lwe delete the value at the position index. So for example, the index position is three,so we delete this particular value. So what we really do is we delete this value, we deletethis particular value. And the list now becomes with size 1234 and five, so what we do iswe decrement the size with with one and then we move on now the country is one again, theN value rather than six. Now the N value is five, so one is smaller than five, but thelist has no zero now in it because it was deleted, we searched the minimum again, andwe insert the minimum in the list. Now the minimum will be one in the new list. And wedelete that value from the list. And we decrement the size we keep on moving, eventually thelist l two will be populated like so. And once. And once this value of n becomes negative,which is minus one with we will exit the loop and we will return the sorted list. But seehow this sorting procedure actually uses the algorithm that we that we defined in in RPBprevious video.I'm not talking about that this kind of sorting algorithm is the most famous sorting algorithm.There are efficient algorithms very great kind of algorithms for sorting. But the ideahere is not to actually teach sorting the idea here to actually come up with the pseudocodefor this sorting problem. And also to show you how you can use the pseudocode how youcan use existing pseudo cores as as instructions in in other pseudo codes. So that's all aboutproblem solving. If you really understand the selection sort and all that procedurereally well, you're actually very good in problem solving, at least the problem solvingis that we encounter in the logic that we need to solve different kinds of problemsin computer science. In the next video, I'm going to actually convert these pseudo codesto Python codes. What do you need? Doo doo doo, right this sortlist procedure in actualpython programming language, and how will you change the search minimum from list inactual python programming language, we will see the Python details bit by bit in detail,starting from right zero and ending at the very high details of Python. So, in the nextvideo, I will just be showing you how to convert this code. But when we will start learningPython, we will start from zero and we will see each and everything of, of Python in indetail. So don't worry. In the next video, if you see, I mean, things like lengthy chordsin a very beginning, these are just because we have arrived at a pseudo code. It is very,I'm just want to show you how the pseudo codes which are very across expressible, how theycan be easily converted to Python programming, just to show you the power of and simplicityof Python programming language. So in the next video, I'll be converting these pseudocodes to Python code actual programming code. So hope to see you in the in the next video.Okay, in the previous video, we just get a flavor of problem solving by using this selectionsort called the sorting procedure. The idea was just to use this procedure to solve thiskind of problem. And we saw in detail, not in that detail, we just just brushed up butwe saw how to write a pseudocode for solving a problem of sorting, which requires actuallya list to be sorting in ascending order. For example, in this video, I'm going to convertfirst this code search minimum from list, you see that code, you know that code completely,we're first going to convert that code in Python code, and then we will convert thiscode in Python code. So see step by step, what changes are there. First of all, in Pythonthat we will see in detail. When you define procedures, different kinds of procedures,they are called functions in Python. And rather than writing this, we have to write a defstatement before it and then whatever name we want to write out, the rest of the thingstays the same, except at the very end, we have to write a colon. That's the syntax ofPython. So the changes from here to here is a def statement, which defines that is usedfor defining def for define. And then at the end, we write a colon. Next thing that wewill see in detail, don't worry if youif you're if you just see that why we're messing up with lips. So early, we will see that thingsin detail. But just to compare the in pseudocode. Normally the lists are indexed the indexesof the list start from one. But in Python programming language, the first index of thelist usually starts from zero. So they are the minimum value was the first value of thelist here, the first value is actually the index and Python is zero, rest of the thingsare same, you declare the variable as in pseudocode. The same goes exactly in Python. They're thebecause the index was one. And so the counter was one more than whatever the index was.Here, the counter is simply one, we need to right here ID x ID x equals to zero that wejust missed. In the previous the ID x is one, so here the ID x is zero, that's okay. Okay,then next, we write while counter is less or equal to n. Same thing while counter isless or equal to n here. So here we just write the, the colon at the end, we might have writtenthis equal sign here, this equal sign, we just missed the equal sign the equal signis there. So now, but see that see the difference here, the violet goes that way, here we havea colon at the end, rest of the things are exactly the same. Now, v is equal to L counterv is equal to L counter the same thing if v is less than the minimum value, same thingif v is less than the minimum value in the pseudocode. Python is exactly the same. Justsee the colon at the end, we have colon at the end of the while statement, we have colonat the end of the definition, we have colon at the end of the if statement. The otherstatement in pseudocode. In Python exactly the same. Now, in pseudocode, we have l statement.In Python, we have l statement. If we want to write an else statement, we have writea colon at the end of that. Then in Python in pseudocode, we have a past statement Pythonin our past statement, same things in pseudocode. We have n def, just to describe that thisf ends. In Python, everything is described by the indentation style. So if this indentationgoes on, if we have If you're here, then this is goes if this if goes out, so we need notwrite ends every day. Similarly, the vile body has this indentation style, this is allthe while body, whatever that is, that is earlier than this is not in the wild body.So, rather than writing the tokens and while and if the Python handles everything usingindentation, so no need of end if no need of end while Oh, we haven't, right, we haven'twritten a counter here. So we have to write a counter plus plus here, so counter. So thesame statement, we missed this statement in the Python code. So the same statement, exactlythe same statement goes here. That's it. The rest of the story is same, we do not needan end search here. The goal here is to show that the pseudocode is, I mean, the way youwrite the pseudo codes, they are they're highly,they highly resemble with the actual code in Python, Python is that expressive Pythonis very, very high level language. I mean, the way the you the way you think the problemin the pseudocode, the actual Python code is much similar to it. So learning the Pythonis very, very simple. The simplicity of Python is really a great property of Python. Andthat's one big reason of popularity of, of Python. Now the return statement is same andeverything is same, then we move toward the sorting. Again, we have sortlist, we haveto write the Define def define, and then we have this colon out there, we have to writethe colon there, then let's do is defined like empty, it's empty in Python as well.Counter starts from zero, because they are the list starts from index one. In Python,the list starts from zero, so we are at zero, while same as this one. Here we have thiscolon, maybe, maybe an equal sign, maybe an equal sign should appear here. I guess weare missing an equal sign. But either way, the code is more or less the same rest thisstatement exactly same as this statement, we have insert in L two, here, we write aband append function, I'm in Python, here with ID lead this in Python, we have a Dellstatement, rest of the story is exactly same. So you see converting pseudocode to Pythoncode is, is way more easier. This is this is not a this is not a formal introductionto Python. I mean, the the goal here in this video in these kind of session videos is justto introduce you with problem solving. But I I found this, I mean, I found this beneficialto show you that the pseudocode actually resembles to the actual Python code a lot, althoughwe will be dealing with variables lists, while loops, if conditions, all these kind of stuffin them in a in a big and huge detail. When we in the upcoming videos, when we will introducethe Python syntax and variables and all that kind of stuff. Actually, you will be masteringeach and everything in Python. And, and further, you may not write these lengthy chords todo stuff in Python, I mean, the whole dad thing is just you write l dot sort and you'redone. I mean, you need not write a lot of lines of codes in Python. Here, I just hereI just showed you that if you have a procedure, you can, if you have a pseudocode it lookslike much like the same as Python, which, which actually tells you the expressive powerof Python and simplicity of Python, and how it is closer to what you think. But the actualproblem solvingin Python does not require so many lines of codes, I mean, there are so many functions,so many powerful procedures. For those you just write one line and a huge amount of workis done for you. And there are very good one liners for Python I mean in for for for forprogramming in Python, you did not write a lot of lines of code to do some stuff. I meana few lines of code even a single line of code does a lot for you. And for that youneed to know the features of Python the feature of the features and the different kinds ofsyntax and features and libraries and the packages and what what is available with Python.I tell you almost each and everything is available just you need to know what is available. Onceyou know the what what what what are the things that are available. You need not to writelengthy codes you need now to build a lot of logic on yourself. Things are prepared,they're waiting for you, you just have to figure them out what are these things to dowhat what kind of features are there in Python, if you know that you are done. So you neednot to be writing these kinds of codes and lengthy kind of codes. Although knowing thatall knowing that is a is a is a huge advantage, but doing a bigger and bigger and bigger stuff.Python will give you a lot of features a lot of functionality that you need not to go into,and you need not write a lot of code for it. And that's the second power of Python. Oneis simplicity. Second, it gives you a lot of features a lot of functionality, a lotof built in stuff ready for you, you want to do something, it will be probably therein Python, you need to know where it is. And for that we have whole future series on Pythonto know Python each and every step in Python, and to know important packages in Python.Because knowing important packages and knowing how to code in Python will save a lot of timefor you. So spending some time on learning Python will be saving a lot of your time.To solve the actual pure problem. Whatever problems you're doing, you're going to solve.And Python is a real programming language granting programming language, knowing thislanguage is almost enough. So hope to see you in in the next videos where we will startPython from exactly zero. And we will see each and everything of Python in detail. Hopeto see you in the next video. If you're new to data science, you may stuck in choosingthe best language for data science. And in this video, I'm going to I'm going to talkabout Python, which is the greatest language so far for data science. To explain the featuresof Python, let me first go back to a little bit history of Python from where it started.It basically starts in 1980s. It was introduced first in 1980s. But with constant improvementsand a lot of bug fixes. It was officially launched in 1989. Nine years later. It wascreated by Guido van Rossum and it is open source which means it is accessible to everyone.Even though it's open source. It can be used for commercial purpose. The main goal of Pythonwas to keep the code easier to use and understand. Its huge library enables data scientists towork faster with the ready to use tools it is dynamically typed. So the variables thatyou are defined that you are defining that they are defined automatically, you need notto set the type whatever the contents in bring in, the type will be defined automatically.It is more readable and uses lesser code to perform the same task as compared to otherprogramming languages. It is flexible, portable, and can run on any platform easily. It isscalable, and can be integrated with other third party software easy. Python programmingis easy to use, and has a simple and fast learning curve. new data scientist can easilyunderstand Python, but it's easy to use syntax and better readability. So so that's whatthis point is basically it's it's really a beginner friendly if you if you're new toprogramming. Well, Python offers you a very easy environment to go on. It also providesplenty of data processing tools that help in better handling the data. Python is importantfor data scientists, because it provides a vast variety of applications used in datascience, it also provides more flexibility in the field of machine learning and deeplearning.It has, it has a lot of packages like TensorFlow, Kara's tiano. That is helping data scientiststo develop specifically the trending deep learning algorithms very, very quickly. Sobasically, the sport, the sport of machine learning and deep learning is huge in Python.That's huge. As, as is the case with many other programming languages? It's availablelibraries that lead to Python success around around 72,000 available packages. In Pythonpackage index, sometimes called by pi, Python. Why? Python package index by by around 72,000packages are available and they are good Constantly. So huge number of packages mature packagesare available. It is free open source and consequently, any Can anyone can write a librarypackage to extend its functionality. Data Science has become an early beneficiary ofthese particularly ponders The Big Daddy of all of them. The other great thing about Pythonis there are millions of users who are happy to offer advice or suggestions. When you getstuck in something, chances are someone else has been stuck there first. So a lot of communityis there, a lot of packages are there, it's open source it it's easy to use, it's easyto learn. It's simple, it's readable, more close to human language, it's high level language,you code less you do more, I mean, you write a very few lines of codes, and you achievea lot of work. So, I mean, I've spoken a lot of verbs here, too, too. I mean, explain thatPython really is best suited language for data science. But let me let me introduceyou some statistics about Python, the popularity of Python with respect to big with respectto its use, and with respect to the job opportunities that are there in Python. So for example,if you see this chart, in the ranking of top 10, languages, Python stays at the top. Sothat's the latest statistic, collected in 2019, February 2019. And out of the out ofthe total share of the languages, I mean, around 26%, just goes for Python, and thetrend is moving up, which means the people are more interested in Python, I mean, thetrend of using Python is getting larger and larger, as compared to several other languageslike Java, JavaScript, C, sharp, bhB, C, our objective c, swift and MATLAB. I mean, manyof them are used for data science, but Python stays at the top. I mean, this is that popularlanguage. And further, if you see, for example, the job opportunities in Python so so thatsays, I'm in a different companies like Facebook, Julia, and I'm in Google and several differentcompanies. This actually graph shows from 2014 onwards, that the job opportunities andjob postings are in different languages are at what amount, and you can see the graphof Python, although starting a bit low, but then stays up and stays up, which means the80 if you see the numbers 85% of the total jobs, there are just for Python. And not only,I mean, Python is not just for data science, it's a general purpose programming language,it's open source, it can be it can be used to perform any kind of task for embedded programmingfor, uh, for for posting, I mean, codes or embedding code on Raspberry Pi for web developmentand whatnot. You can you can, you can do the desktop development on it, you can use theweb developer knowledge you can use the data science, I mean, I mean, this is general purposeprogramming language. In other disciplines do it is performing very well. But data sciencefor data science, it is almost the default language today.So, I mean, if you're going to learn data science, really, we need Python. I mean, Pythonreally is the choice, the default choice, and we need it. And in this particular course,we are going to, we are going to introduce Python to you with all aspects, I mean, wewill start from the very beginning level. And we will gradually move towards the veryadvanced programming in Python, including the introduction to the data science packages,like pandas and matplotlib, for visualizations, and NumPy, for handling numeric data and stufflike so. So, in this particular course, we are really going to teach you Python, andwe are not assuming you have any programming experience before. So and this is one plusof Python. I mean, whether you're an engineer, you're coming from health sciences, you'recoming from biology, you're coming from arts, humanities, or from wherever. Python is somethingthat is very easy to get hands on. So if you're not assuming that you have any programmingbackground, you have any data science background nothing. So we will start from the zero andAnd we will gradually move to 200. So, and including the introduction to the data sciencepackages. So Python is the best, it is a default. If you're going to work in data science, Pythonis the default. And we are going to, we're going to introduce you Python from the verybeginning to the very professional. So hope to see you in this course. Okay, before actuallydiscussing the best ID for Python, and particularly for data science, let's first discuss whatan ID he is, as you start your coding journey, many of you prefer coding in a text editormaybe like notepad plus plus, where you write the code and then open a terminal window toexecute your code. When there is an error detected in your code, you switch back tothe text editor, correct your errors, typos and run the code again in the terminal, everythingis fine. Typically, for large scale problems, however, you not only have to code but youalso need to make sure your code works in all scenarios, which means you also need atesting module. Many times you have multiple coding and testing files, and switching betweeneditor and terminal often becomes both confusing and efficient. So, an environment is needed,where you can write you can run and play with your code all at one place. So the one thatprovides you with the capability of not just coding, not just writing the code, but butalso testing your code, running your code highlighting your syntax, bracket matching,auto completion, debugging your code, code suggestions, and and many more features. Thatis called an ID II or integrated development environment. Now, there are several ID isfor different languages for for Python, there are several ideas for example, Jupyter Notebookis an ID IE by charm is an ID IE spider is an IP ID and thought cannot be whim atom andthere are a lot more there are several of them. Now the question is for data science,in particular, what Id E is is the best or are what people suggest to be the best. Sobefore actually showing you the statistics that which one is the best before actuallyshowing you the actual numbers, the statistical numbers that shows which one is better, whatare the other let me just go through a few of them few of it ease and their featuresand stuff. And then we will move to move to statistics and some numbers that will showthat which one is better over the other. So let me start with with this Jupyter Notebook.For the past couple of years Jupyter Notebook has been gaining a lot of popularity in termsof coding and debugging. notebooks have been redefining the concepts of an ID E and areadding more and more features on to it. Jupiter was introduced in 2014 after its predecessoripython and from that date, it is really considered to be a bless in the coding community.Jupiter stands for I'm in some people say Jupiter stand for Giulia Python r but thatI come in that acronym does not mean just this. I mean Jupyter Notebook today is supportingmore than Giulia, Python and R and by the way, this Giulia Python, R and R all theseare open source languages for and they are best suited for data science. This JupyterNotebook, it has markdown editor. It allows you to write HTML code, it allows you to writelatex in it. I'm in a lot more. Further this Jupyter Notebook. It's a web application basedserver client structure, which is easy to use and allows you to create, analyze, andmanipulate documents. And all these documents are in the form of notebooks. Since it's aweb web interface, it can integrate with many of the existing web libraries. For example,for data visualization. Jupiter has so many functionalities you can write formula usinglabtech run a Python code and visualization. For example, a raw audio signal using matplotlibplotting library, all in the same notebook. Jupyter Notebook is not just an idea he butit's widely used and an educational tool for presentation and even for writing blogs. Youcan export your notebook from iPython Notebook formats to PDF or to HTML or even to.py, whichis the Python file. The user interface of Jupiter makes it a favorite tool, especiallyamongst the data science community. And one plus of this Jupiter is, it's it's very quickto start, I mean, very easy and very quick to start, I mean, not much rocket scienceto write your first goal, you want to write your HelloWorld it's very, very quick. Andyou're better to go and do that. By charm, if I discuss pi charm, however, if I discusssome of its properties, and let me just discuss, first that the pipe the PI charm is by thecompany JetBrains. And if you have never used japin JetBrains other IDs like Java ID, thenrunning your first code successfully can eat up a little bit of your time, actually, alarge amount of your time maybe such as I mean, setting an interpreter by charm. Bycharm, however, is, is much better for, for working with multiple scripts, handling multiplefiles and linking them together and huge large scale coding products. The good thing aboutPython is it supports Anaconda. And as a result, all the packages that fall under Anacondaare supported by char pi charm as well. And those packages in including NumPy, Sai, pimatplotlib, and so on. Just like other IDE ease pi charm has a powerful debugger. Witha graphical interface. It offers jet integration, it has skills, shell terminal and worryincontrol system. Python, it is customizable, which allows you to choose between differentthemes, color schemes, and key binding and whatnot. Additionally, Python lets you addplugins for non pythonic files. And these plugins take care of indentation highlightingthe errors and keywords just on the fly. So Python is also providing I mean, a huge supportfor coding Python. But, I mean, the one bad thing about Python, which is not that bad,but one bad thing is it is memory intensive. It eats up a lot of memory. It's a heavy thing.And secondly, I mean getting getting getting started with PI charm is not that quick. Imean, it takes a lot of time to just go with that. Spider however, is a lightweight, opensource ID Oh by the way, this by but this by charm is is is not I mean it has ProfessionalEdition and and Community Edition and it does not open source completely. Spider however,is a lightweight open source, ie that comes pre installed with Anaconda. And it was builtmainly for data science practitioners and engineers. Its look and feel is much likeMATLAB. So if you're a MATLAB programmer, if you've used MATLAB before, you switch toSpyder and you get a mean much look and feel the same cannot be by the way the unthoughtcannot be also has roughly the same look and feel as MATLABSo, but spider was built for data science community, it is integrated with essentialdata centric libraries like NumPy, Sai, pi, matplotlib, pandas, ipython, and whatnot.The built in capabilities can be extended further by plugins and API's Spyder containsfeatures like text editor with syntax highlighting code completion, static code analysis, debuggingvariable exploring, it also has profiler that recursively determines the runtime and numberof calls for every function and methods call in a file. And I mean, there's no thoughtcannot be there is a vendor's atom there are a whole lot of it is just for Python language.But But the question really is being a data scientist, which one is which one should youchoose being a beginner? which one should you choose? Even even for professionals, ifyou want to stay in data science, which ID he will you prefer over the other? I mean,there are so many of them. I have just described three or four of them. So let's see some statsbased on popularity of different IDs for data science, and then decide which one is betterover the other. So for example, this data this this analysis, that the chart I'm showinghere, this analysis by was was done by Katie nuggets and The link for that and it showsthat the most popular Python editors till December 2018 and you can see that the Jupiteris at the top, the second is pi charm, then spider then Visual Studio code and sublimetags, then add on atom women there are so many others, but Jupiter is at the top andthis is for I mean, these all are listed with respect to the data science community. Soin the data science community which Python ID he is best over the other and, and JupiterJupiter is at the top I mean it is it is way out. And one reason to this is its simplicity.It's it's supporting to so many different formats. It's it makes an interactive documentit makes it makes a web page that is interactive, you can just change the code you can makeanother web page and so on. You can you can run it on a local system you can run it anonline survey system and whatnot I mean it has so much flexibility and very quick startand easy to use. If you for example see the popularity of Python IDs with respect to theemployment then then you can see overall the the Jupiter has been a winner as comparedto pi charm spider also your code and sublime if you see company or self employed stillthe Jupiter is V out it has been if you see for in a student perspective, Jupiter is thechoice. If you go to academia or university, Jupiter is the choice if you are working withgovernment or nonprofit Jupiter is the choice I'm in Jupiter is I mean Jupiter is kind ofoutlier it is it is staying at the top everywhere. Further if you if you analyze the popularityof Python, it is with respect regions for example, again, overall, Jupiter is a winner.If you see US or Canada Jupiter's most popular mostly used Europe, Jupiter is the winnerAsia, Jupiter is the winner, America use Jupiter sevinor effect Africa and Middle East Jupiter,Australia, New Zealand Jupiter. I mean, these numbers are suggesting that Jupiter is isat the top, not just at the top. It's easy, I mean, and maybe that's one reason why Jupiterstands on the top for the data science. So these numbers and these all statistics suggestthat we should use Jupyter Notebook for Python. And we will be doing that. In fact, for thisparticular course we'll be working on Jupiter for all kinds of coding. And in the in thenext video, I will be just showing you how to installJupiter environment how to install basically Python and how to run Jupiter for the firsttime from it. So I hope to see you in the next video. Okay, in this video, I will showyou how to install Python. There are multiple ways of installing Python you can go to python.organd install Python from there I would recommend to use Anaconda distribution it has Pythonit has a lot of packages pre installed it has Jupyter Notebook as well. So installingthrough Anaconda is easier as well. So if for example if you are working on a Windowssystem you should download the executable for Windows we will be working with Pythonthree rather than Python two. So you should be installing you should be downloading Pythonthree point whatever the latest version is. Further if your system is 64 bit you shouldbe installing 64 bit version otherwise you will be installing 32 bit version. So let'ssay you have downloaded the executable file for Windows then after the download you justfrom that xe file and follow the steps and you'll be able to install Anaconda once theAnaconda is installed then in the search bar you just type Anaconda prompt and the Anacondaprompt kind of symbol that my mouse is pointing at this will appear in front of you, you justrun it you will see a command prompt like so. Then in that just type Jupyter Notebookand press enter and you will be having Jupiter running in front of you. Let me let me showyou that on my on my system. How to do that. Let's see. For example, this is my searchbar. Let me type and conda prompt so this is the Anaconda prompt. So if I click it,it runs then I just typed for example, Jupiter note book Then I just press enter. For thefirst time it will take some seconds to run. So let's wait for it. So yes, it runs andit will show you kind of browser in front of you. And that's what the Jupiter into interfaceis. We will see then how from this Jupiter how to write the code how to make the codefiles and stuff but that's how from Anaconda installing after installing Anaconda that'show you will launch the Jupiter. So this is that easy, no problem. Then, for example,you can install you can install Python if you're working on Linux and just downloadthe version for Linux. And then rather than For example, let's say your your your fileis downloaded in the Downloads folder then run this command bash and this.sh that's thefile name. The installer prompts in order to continue installation process this I'min these kinds of commands will will appear Press Enter to Continue then press Yes, andthe installer will finish with the thanks message. After that, you just go to downloadsfolder and type Jupyter Notebook and the Jupyter Notebook. interface the browser based interfacewill appear in front of you. You can have if you're if you're working on Mac, you canyou can in you can download the Anaconda distribution for Mac, then you'll find an anaconda Anacondanavigator, the launchpad you can launch that and then just click there's a Jupiter iconin front of you just press the Launch button and you'll be having your Jupiter runningin front of you. So in this video, we just talked about how to install Python. If youinstall Python using Anaconda you will be having Jupyter Notebook as well. In the nextvideo, we will see how to actually use that Jupyter Notebook interface for example, Iwork on Windows, so I'll be having this kind of interface although the interface lookslike same because it's a browser based web based interface. In the next video, I willshow you how to get comfortable with Jupiter and we will be also writing our first HelloWorldprogram in Python. So hope to see you in the next video. Okay, so in this video, I willshow youhow to write the first program in Python basically the HelloWorld program. Before that, in theprevious video, I show you I showed you how to launch Jupyter Notebook. So once you launchJupyter Notebook, whether you are working on Windows, whether you're working on Linuxor Mac, whatever, when you will launch the Jupyter Notebook, you will see this web basedinterface. And here you are in the right corner you can see the button new, you just clickit, you will select Python three, and you will see a beautiful interface in front ofyou that will allow you to go here, there are a lot of file edit view there are a lotof parents kernel and a lot of controls here we will see them as we move on. But this ishow you this is this is what the coding environment is this is kind of editor as well as I meanthis is complete, ie interface in front of you. So let's see this interface a littlebit. Step by step at least the controls that that we need. First of all, you are seeingwhere my cursor is moving. That's the file name or the notebook name. You can changethe notebook name or you can just write for example. Whatever the name of the notebookyou want, for example, mastering by Thorneforbeginners. Okay, so let's say that you're mastering Python, let's say let's say zeroto hero, maybe. So let's say this is your filing, you just create that file and you'llsee this mastering Python zero to hero that file is created with this file is renamed.Second. This is a cell in which you are going to type your code. The code, I mean, the twomodes of writing is one is you can write the Python code. Another way is you can writethe markdown. The markdown is important in in a way that if you want to describe yourcode, if you want to write other stuff other than Python code, you can use these markdowncells and they We will be helping you. For example, if I select this markdown, and Ijust select this markdown, and I type here, for example,this is by THON directorial. And then I press Shift Enter, it will appear as a heading.And a new cell will be graded down. This is also a cell. But this is a markdown cell.As you can see, now in this cell, that's a code cell, you can switch a cell from codeto markdown by just pressing an escape key, when you press an escape key, you will seethe color will change here, you can press Escape key, then if you press M, it will changeto markdown. And if you press Y, it will change to a code cell. There are several I mean shortcutsthat are available keyboard shortcuts, if you if you just see, if you go to help andsee this keyboard shortcuts, there are several shortcuts that will be available in frontof us. For example, if you press escape, and then press F, you can do the Find and Replaceoperation. And if you press enter, then that will go into Edit Edit Mode, if that's important,if you press Shift, enter, the cell will run and the new the cursor will go into the newcell. And there are a lot of controls you should be seeing most of them, I mean, gettinga good grip on these controls will help you moving in this Jupyter Notebook very quickly.So for example, this is a Python tutorial that's a markdown cell, you can also createthis, this cell also as a markdown cell. And then you can type here for example. This isour first program in Python. It there it is just started here, for example, and it justappears like like a description. And again, a new cell is created down and there you canwrite your code. So let's write the first Python code HelloWorld. So first of all, youwill write Brent Brent command will allow you to print anything on the screen. brantassays double codes, starts ends. And in the double code, you write whatever you want tobe printed on the screen, for example. Hello,world.And once you have written that code, just press Shift and enter, and this code willexecute in front of you. So that's HelloWorld printed in front of you. And that's our firstprogram, I mean, writing the very first program in Jupyter Notebook. is is that easy. Notonly that, this Jupyter Notebook will be created, you can you can just I mean describe anything,you can write the headings, you can write HTML in it, you can write math, using lattic.And for example, let me let me write lattic, or mat in front of you just just let's sayyou're making a notebook that requires some mathematics in it. And it allows you to writemathematics as well. For example, A equals B plus C, Shift Enter, and that appears likea mathematical equation, not just this, you can write very complicated equations. I mean,and and, and this whole notebook will contain your descriptions in terms of HTML or latech,or descriptions, and code and all that mixed up, whatever. And at the end, you will, youcan, you can just download this. You can just download this, this notebook, as if you wanta PDF file PDF file. If you want a notebook file, it's an output file if you want to latechif you want just a Python file if you want slides, for example. I mean, you can downloadthe same thing as slides. It will make slides for you. So there are a lot of ways of usingthis notebook. And that's a ready made document. I mean, you end coding, the document is readyfor you. So this notebook is really, really powerful Jupyter Notebook and coding in itis not just the coding. I mean, it is Preparing a document. If you want to prepare a document,you want to describe anything you want to add images, and at the end of the day, itwill be an HTML document for you. It can be shared on web. I mean, it's ready. Nothingwe we want to further finish it. So that was our HelloWorld program in Python. We willcontinue to build this byte mastering Python zero to hero notebook, we will continue codingin that we will describe the headings we will write the markdown cells and all that stuff.And we will at the end of this course, you will be having one notebook with all kindsof descriptions and code in it. You can use that notebook afterwards, we will be buildingwell one notebook, one complete notebook for Python. So that's about it. That's the helloworld. In the next video, we will see how to what are what are the constructs in inPython, what are variables and other stuff. But before that, I also wanted to show thatthis notebook is an enhanced worryin are the upgraded version of ipython shell. And I alsowant to show you ipython shell as well. So in the next video, we will just see the ipythonshell and we will see how can we how can we view Python as just as a calculator by usingipython shell. So hope to see you in the next video. Okay, so in this particular video,I'm going to show you the ipython shell just open up the Anaconda prompt as as before,like you want to open a Jupyter Notebook, then you just type here Jupyter Notebook.And you will be you will be in the in the notebook word Jupyter Notebook word. But ifyou just type in ipython and press enter, then a prompt is open for you in a coloredway. And this is perfectly fine to write any kind of Python code in here. Actually, theJupyter Notebook is more enhanced and more featured the use of ipython. Basically everythingthat I bought, that is there in ipython is there in Jupyter Notebook as well. But ithas more features more documentation and stuff. So for example, if I just write a Python codehere,hello world, let's say it will work in ipython shell as well. But remember, previously inin Jupyter Notebook, we type Shift Enter to run a particular command here, we just pressenter and everything will work. If you want to clear the screen here, whatever the whateverwe typed here, if you want to clear that, just press Ctrl l if you're on Windows Ctrll will work on Windows. Now ipython is just like, you can use the Python in this particularshell just like a calculator, for example, you want to plus three, press enter, that'sfive, let's say it's nine multiplied by seven, the answer is 63. You can write a complicatedstatement as well, for example, 45 minus eight is static, or multiplication, static is achievedby multiplication is achieved by a static symbol seven. And then you can have this minusthen divided by two and just press Enter. And that's the answer 16.0. If for example,by the way, I have just press the up arrow key and last command just appears. I havepressed up arrow key again. And the second last command appears. I press the up arrowkey again and the third last command appears and now I'm pressing the down arrow keys.So for example this and you may have whatever the result is, you may have that multipliedby 10 and minus or or maybe plus plus 15. So the result is minus 145, and so on. Sothis Python ipython shell, you can write very complicated are almost I mean, the completePython coding can be written in ipython shell. And you can use this shell just for a calculator.Now let let's see, for example, you you compute this result, let's say 45 minus 45 minus nineand let's say you compute this result, whatever the result is, and you save that result ina symbol, let me call that symbol as a variable. In here the variable is So let's say you savethat in a, and then you have another variable, let's say B, and three static 45, or maybethree steric 2.6, that is saved in B. Now, you have you have done this particular calculation,you know that 45 minus nine is in a, the result is in a, and then you have this particularresult that is in B. And now, you just want to add the two results together, and you wantto print thewhat what normal calculators does not have the support of saving the results and reusingthem. But here in Python, even if you just want to use the Python, just as a calculator,you can declare as many variables as you can and you can save the previous results, youcan retrieve the previous results. And you can use the previous results, save new resultsand so on. These kind of symbols that are used to save the results, and then they canbe just used afterwards, these are called variables. And our next video will be on variables,what are these variables, what are the types, what kind of variables the Python supportsone way or the other, if you want to go beyond calculators, you need certain results to besaved and retrieved retrieved afterwards. And the variables are are the constructs thevariables are the features that actually do that. So the calculator is fine, you can usethis ipython shell just as a calculator. But if you want to do interesting programming,complicated programs, I mean, you want to achieve a task that involves much more calculationsone way or the other, you have to save certain results in somewhere. And then you have tocombine the results together because the longer problems in normally are broken up into smallerpiece of problems. And each smaller problem has a result that should be saved somewhereand afterwards the several results they should be combined to achieve the result that weare after. So these variables are required if you are going to do some interesting orcomplicated calculations or computations. So you, by the way before, before having theseJupyter Notebooks spit out just the enhanced version of this ipython shell, the iPod ipythonshell just people used to write a lot of Python programming just in ipython shell. And eveneven today is several people are writing their code complete code in ipython shell. But thethe Jupyter Notebook is more enhanced for the enmore documented more, I mean, it hasbetter interfaces and several features that are better than just using ipython shell.So you have seen this ipython shell, it's very powerful, great, everything is fine withit. But we will be using Jupyter notebooks, which are just the enhanced variants of thisipython for our upcoming coding. So the purpose of this video was just to was just to introduceyou with ipython shell and just to tell you that you can use Python just as a calculatorand even more than that, and in the next video, we will be introducing variables in JupyterNotebook and we will see the Python or Python is really really much more powerful than justa calculator. So hope to see you in the next video. Okay, in this video, we will talk aboutvariables and operators the operations that you can perform on on variables. A variablein a very layman term is basically a symbol that stores some data that can be used lateron. So for example, this x is a symbol corrector or a symbol y is a symbol x y is a symbolnormally, and these are called names of the variables. For example, this is a variablename x, y is a variable name y, x y is a variable name itself. Now, these variables, they canstore different kinds of data, I mean, whenever you want a particular data to be used againand again, it is better to save that data or label that data by a symbol by a descriptivename so that you can retrieve that team retrieve that data by using that label or symbol. Soone way or the other. This this variable actually is a description of the data that you wantto use our store and you want to use later on in your program. Different types of dataare there, for example, the integer type data.For example, if the data you want to store is integer type, it's a number And the numberis just the integer number it does not have a decimal point expansion that is a type ofdata and that can be stored in a variable in that in that case, the variable type itselfwill be integer, you need not to specify the type of variable when you are storing thedata to it the storing data to a variable is sometimes called assigning data to a variableor assignment. For example, if your variable is x, and you are assigning a value let'ssay two, then two is integer value its integer it does not have a decimal expansion and whento is assigned to x, based on the content to that to basically is an integer type value,automatically this the type of x is set to be integer. And that is sometimes called thedynamically typed Python is dynamically typed language or dynamic typing, you need not tospecify the type of the variable the contents that you are assigning to a variable, theywill define the type of the variable on the fly. And the assignment for example, in hereI'm storing two insight x and next time if I want to print for example, what is therein x the the print value will be two. Now, this kind of symbol is hot right there isno keyboard symbol that looks like so, so rather than writing this symbol for assignment,normally an equal sign symbol is used for assignment for example, x is equal to twothat means two is assigned in x five is equal five is equal to five means five is assignedin y 7.2 equal x y equals 7.2x y is completely a new variable, it has nothing to do withx or y. And it is handy sometimes to to to suggest the name of the variables that aretoo descriptive that are very, very descriptive to increase the readability and managementof the code, because later on you will you will be seeing when you will be working indata science and other stuff. The programs that you will be writing might not be veryshort programs, they might be lengthy programs. So readability of a program and managementof a program becomes an issue if you if you if you do not assign the names of the variablescarefully. However, if you write the names very in a very descriptive way, by just writingthe name of the variable by just creating the variable symbol or or or the name, ittells a better look and feel of what kind of data inside and what should I do with that.So, I was talking about this equal sign this equal sign is used for assignment. Here forexamples when 7.2 is assigned to a variable x y, automatically the type of x y variableis set to be a floating point integer floating point number a float is a data type in inPython that describes that the particular data is a real valued it may have a decimalexpansion as well not just integer and floats are the only data types in Python, there areseveral others for example, you can define complex numbers if you if you want to youcan for example, defining a complex number might be for example, you write the name ofC and you write two plus four j if you write the symbol j here, it automatically becomescomplex. And now you can you can use this see the way the complex numbers should becreated. Similarly, there are other data types like fractions decimals, there are there arefurther data types, the objects called strings. For example, if you if you if you assign let'ssay s equals double quotes Hellothen that S is also a variable and the type of this variable a string string is just asequence of a lot of collectors, where he is a collector is a collector L is a collectorL is a collector always a collector W is a vector. And when we will define anything,any sequence of characters inside the double quotes and then ended the double quotes here,or the single quotes, single quotes and double course either way, then the type of this isbecome strings. And these characters should be created as it is. Like for example, ifwe have another variable s two and we just say one, two, in double quotes. Now this stwo is no longer 12 as an integer. It is a sequence of characters where first characteris one and other graduates two, we will talk about strings in detail in the upcoming videosbut just to give you a look and feel that Python actually supports a lot of data types,a lot of interesting data types including the most important data type is integer floatand string as well that we will see in detail. Further you can assign you can assign morethan one values to more than one variables in in a single line there is sometimes calledmultiple assignment. For example, if you write a comma b equals four comma 5.00, then fourwill be assigned to a and 5.0 will be assigned to B. notice one thing although 5.0 lookslike an integer, but when you when you write a decimal expansion, it automatically becomesfloat. So, if you Now type the type, if you now check the type of a it will be integerand if you check the type of B it will be float. Once you have declared a lot of variables,they stay in the memory they occupy a particular space inside the memory. For example, x isjust a label to a memory inside the memory that is to located somewhere. Similarly, yis also located somewhere in memory. And similarly x y is also located somewhere in memory. Andthis is the data inside that memory. These will stay in the memory and the occupy thememory. If you if you decide to no longer use a particular variable and future in thein the program, then you can call this function d l space, whatever the variable name, andit will delete the it will delete the variable from the memory like it was never there. Andonce the variable is no longer in memory, it is it is not accessible. If you now accessthe variable again, you will get an error. Let's see all these concepts. Let let's seemost of these concepts in Jupyter Notebook and let's let's actually, let's let's actuallydefine certain variables, use them, print them, do some multiple assignment and seea lot of stuff in in Jupyter Notebook. So let's go to Jupyter Notebook. So that wasour notebook that we were doing, that we were actually working on the last time. So let'ssay I define a variable X, let's say x is two. Why not? Why not? I should describe this.as what we are doing here is let's say variables. So just to give a heading that we are nowin variables, so variables, notice that now I'm in a code cell. Previously I was in amarkdown cell, notice this change in this particular cell, this is markdown in thisparticular cell, this is code cell, C that goes, Okay, x is equal to let's say, three,let's into this. Now x is assigned a value three. If you want to know how many variablesright now are there in the memory, we can write this command whose This is a percentagesymbol, if you write percent a symbol and then just type a command, w h o s, it willtell you all the variables that are on right now that are there in the memory. And rightnow the memory has a variable with name x, its type is integer, and the data inside thevariable is three, that's the memory view that you're now seeing. Okay, if you wantto explicitly check the type of x, you can print type x. So for example, this functiontype will will actually find out the type of whatever variable you give inside and thenthis print function will help you printing that on on the notebook. So if you see thetype of x, the type is basically its integer type. Now,if you for example, change the value of x as three to let's say, 5.7. So you have samevariable, but you just change the value from three to 5.7. So let's see what happens now.So if we call us again, we have now the variable name is still x, but its type automaticallyit's type automatically change to floating point number, because of because we assigna floating point number to it. And this is the data if we want to explicitly check thetype of this x, that would be class float now, further. Let's say we have another variableABCD. That's a variable name, let's say and we assign a value 55 six Point, three, two,that's that's the value. If we now called whose function whose command, we will be havingtwo particular values, one variable as ABCD, its type is float. another variable is x,its type is float, and that is there. If we, for example, do a multiple assignment, forexample, a comma, when you write comma, first variable finishes, second variable startsA, B, C, D, F, let's say these are five variables. And if you assign five values to five variables,again in a comma separated list, 356, point 07, point two, and let's say minus three.So if you enter that, and you now check the status of the memory, because now all thesevalues are assigned to the respective variables, if you now check the memory view, a is aninteger type variable with value three ABCD, the old variable that we assigned earlier,it's already float B is also integer, it has value five sees float, sees float all those6.0 looks looks much like integer. But when you when you write a point explicitly, itbecomes it becomes a floating point number. So D is again, float with 7.2, f is integer,it's minus five. And x is the old old variable that we know already. Now, if we, for example,delete a particular variable, if we for example, we we no longer want to use ABCD variableABCD. That's one variable that we don't want to use in future. And now if we see again,the view of the memory, we don't have this and if we now want to access this, for example,if we want to print this ABCD, we will get an error, we will get an error and we shouldwe should get an error because this particular variable does not exist in the memory, itpoints to no data, it has gone, it has gone like it was never, it was never there. Sothat's about the variables. We just talked about integer and float, there are severalother variable types as well. For example, let me just give you an example of an exampleof a complex number, if you are really interested in that's a complex number if you print itstype so that the type is complex. Similarly, you can have a string variable, let's sayhello, how are you? That's a string variable, if you bring the type of this you will geta string we will we have a whole set of videos just on string data type, because this isvery important data type we will we will see that in detail. But the purpose here is justto tell you that there are a lot of data types that Python supports and Python is dynamicallytyped whatever content you are assigning to a variable the that content decides the typeof the screen you need not to specify.So I end this video here. In the next video, we will be talking about operators basicallywhat kind of so once we have decided once we have declared once we have defined a lotof variables, what we can do with these variables, can we add two variables together and getthe result stored in another variable can we multiply two variables together, can wehave an operation like addition or mixed types for example, one variable is a floating bynumber and other variable is integer number integer type, can we mix up those can we addtwo different types of variables together and get a result then what will be the typeof the result and so on. So a lot of these discussions on operators the very basic arithmeticoperators on these variables, particularly the integer and float variables, we will seethat in the next video, so hope to see you in the next video. So in the last video, wesaw variables and we particularly saw integer type variable and floating point, variabletype. We also saw very briefly on Jupyter notebooks are complex, and string as well.So in this video, we are going to talk about operators, basically the arithmetic operators.Obviously, if you are defining variables, you're not defining the them the variablesjust to just to view them later on. Most probably you will be storing data to the variablesand then you are you're applying some computation on a set of variables together. Comparingnew results saving that and doing some stuff, most probably you will be adding to variablessome one way or the other in inside a program, you may have to add two variables, you mayhave to subtract a variable from the other, you may have to divide a variable you mayhave to compute for example, these are arithmetic operators, let me let me just this this plussymbol is used to add to variables. This minus symbol or subtraction is used to subtracta variable value from the other variable value. Obviously, these all are operated on values,not the names. Division, it like like the name suggests, it's if you want to dividethis this person to a symbol when it is applied to two different variables, if x is on leftand y is on right, what it does it, it actually divides x by y, and checks what the remainderis, for example, if x is 27, and y is five, then what's the remainder? What do you think?If we divide 27 by five, what's the remainder the remainder will be? Two Yes, so the resultwill be two here. So this computes the remainder. This multiplication this star symbol is usedas multiplication like in mathematics, we normally write this cross symbol. But in inPython, and in most of programming languages, Star symbol is used to achieve multiplication.This double slash is like the division, but it is division with the result flow to thequotient. What I'm saying is the following. For example, if you divide, let's say 10.by three, the result will be a floating point number, and the result will be 3.33. Somethinglike so. But if you want just the quotient, not the remainder, if you want the integer,that's the quotient value, then you write the double slash three, and it will returnjust the value that is that is there before the decimal expansion. So this value willbe returned. So this is kind of the integer division or floor division, this double staris used to compute the power. For example, if you want to compute to the right doublestar,four, that means two raised to the power four in mathematics, we write this as following.And the result will be 16, you can save that result in another variable, or you can justprint it or you can write that in a file of whatever. So these are most important. operators.One thing that I want to tell you that these operator are not just for integers and floatingpoint numbers, the applications of these operators is much broader than these later, we willsee the objects or the data types that are collections. And very, I mean, the data typesthat are beyond these integers and floats, and still there, this plus minus division,and all some of these are all of these, they have their meanings there. Even even eventhis plus is used for strengths. Now think for example, if you have a string, let's sayhello.And you have another string, for example, let's say this is string s one, and you haveanother string, let's say s two, which is why then Python allows you even to add thesekind of data types, although some doesn't make any sense with these kinds of stringvariables, but we will see four different kinds of data types. The the definition ofthese operators, they actually changed or adapted accordingly. For example, in mathematics,we are much more fluent a four with plus with Debian with subtraction, and it makes senseto add two integers to subtract a floating point number from another floating point numberand stuff, but with data type that is unfamiliar to you right now, these operators may notmake that sense to you. But there are definitions there, there are ways to use these variables.For the data types that are even there or even beyond an integer and floating pointnumbers, we will see all these details as we move on, as we move on to as we move onto the videos. And I mean, as in later on, we will see all these things in detail, butjust to tell you that these operators are not just limited to integers and floatingpoint numbers or complex numbers, they can be applied to several different data types.So a lot of words, I guess you were born Now, let's go to Jupyter Notebook and have funwith these kinds of concepts that we are dealing with. So yeah, here. So let's first pressescape, then m just to change it to markdown and then good scape one for heading begetting.And here I write, let's say operators, and shift enter its runs and automatically thengo to code. Okay, now let's say I have a variable. So let's say what kind of variables I alreadyhave. In the previous video, we use that. So we already have these kinds of variableswith us. Now, what is let me define a new variable, let's say sum of sum of A, B, that'sa new variable sum underscore AB, that's a variable name, you can have a better way youwill name maybe some of A and B, that might be a variable name. It is good to have thevariable names that are descriptive that describe what data is inside. Because in in programs,the programs become manageable, readable, and a lot of benefits are there. So Sum ofa and b, let's say that's a variable name. And you add a, b, you just write a plus b.Let me make the zoom level a little high so that you can see it clearly. So a plus b,let's say that's there. If you press Shift, enter, and now your brand. Some of By theway, if you have written some of you need not write everything, just press tab, andit will automatically complete the remaining part of the variable and press Shift Enterand you have eight. If you check the type of this variable, some of tab automaticallycompletes tab complete that is called tab completion, while it's integer, the type ofthis particular variable is integer, that's a new variable and why and the type is integerbecause a was integer, B was integer. And integer plus an integer is an integer. Whatif we add an integer with a floating point number? What do you think? What should bethe result? If I just type type? A, that's an integer plus d with some floating pointnumber. So a plus d, the result will be here, and type of that result. What will be thetype of that result? What do you think? Let me pause here for a few minutes, and oh, no,no, no, not for a few minutes. For a few, maybe seconds, maybe two or three seconds,what will be the result? What will be the type of an integer and a float combined?Well, the types are up costed, which means the floating point number, the result willbe a floating point number. And the reason is, every integer by default is a floatingpoint number, a floating point number is a is an upper class, or you can say a superset.So in Python, in Python, by default, the types are up costed to super super sets. So hereinteger plus a float, the result will be a floating point number. And that's a result,you might be thinking why we have why we haven't stored the result in another variable. Well,if we want to store the result in another variable, we can, or if we just compute theresult and apply some operation on that, we can do that. For example. We could do thefollowing, for example, a plus d. That's whatever the result is raised to the power three, whateverthe result is, whatever the result is, divided by maybe four. And we just save that in anew variable. Let's say. Let's say the new variable is V. Let's say we save that value,and V. And now we print we, and we have the result for me. Wow. So we can do a lot ofstuff with these kinds of variables. Let me show you a fancy stuff that we will see lateron. Don't worry if you don't get it just as one, for example, as one is Hello. Hello,and let's say s two is world. And we have another variable, let's say s, which is sone plus s two. What it will do is it will just concatenate them together. We will seestrings a lot later on. But just to tell you this plus is not just for not just for numbers,it is for other data types, very fancy data types that are there. One more thing, let'ssay we define 10 and we divide it by Three, and we want a quotient, the quotient is three.However, if we have 10 divided by three, Shift Enter, the result actually is 3.33, and soon, you might be wondering we have not saved that result in a particular variable. So wherethe result is saved, actually, if you do not, if you do not save the result, if you do notassign the result, for example, in this way, the result will be assigned to a variableor, but if you do not assign if you do not store the result in a particular variableexplicitly, by default, there is a variable in Python, which is underscore underscorecontains the last result that you did not store in a particular variable explicitly.So, that underscore is basically one default variable for for the result, if you want,don't try to update this underscore, just just read it Do not assign anything to underscore.For example, if you assign something to underscore assignment will be done, but then the propertiesof underscore will no longer be there as they are in in Python built in properties. Okay,so, that's about it, I guess. So that was the operators, we will see the operators moreand more later on. But before ending this video, I leave you with a question. So thequestion is, we saw the variable names like, Sum of a and b X, Y variable name can be canbe lengthy can be descriptive can be short anyways. So the question really is, can avariable name start with a digit? For example? Is it possible that the variable name reallyis is starts from the variable name starts from for example, a digit? is a 3x? validvariable name? Or, for example, at the rate of at the rate of Why is that a variable name?Or, for example, this symbol times two times x, is that a variable name? What are the conventionsto for variable names? can we can we write anything? In the left hand side? The rightlet's say 3x? Is equal to four? That means 3x is now a variable name. Is that true inPython? Or are there conventions to define the variable names? So?Yeah, think about it. See you in the next video with the answer to this. So I hope youwill, you will be having answer for this question. Hope to see you in the next video. Okay, soin the last video, I asked you a question about the naming convention of the odd variablenames. In particular, I asked you whether 3x is a proper variable name or not in Python?So what's your answer? Yeah. What do you think? How many of say, how many of you say no? Howmany of you say yes? Well, by the way, you might have tried that, declaring that variablename and Jupyter Notebook, and then you might have got this answer one of these? Well,let me tell you, the answer is no. A variable cannot start with a digit. Not with, not with,at the rate of not with hash symbol, not with I mean, there are severalother special characters are not there except a few factors. One of those is underscore.Let's go to let's go to Jupyter Notebook and and check this. So, for example, 3x equalsfive error, invalid syntax, let's say activate of y equals four. Invalid star d equals fourerror. Well, an exception is underscore underscore E equals six, that's allowed. Starting a variablename with underscore is allowed, it is different than the underscore that is built in underscorethis underscore E is different than simply underscore. So it is good to not declare thevariable names that start from these because you will be getting errors further. variablenames should be descriptive. They should give you a look and feel of the data what theyare containing and you're free to define variable names, as as descriptive as you want. So itis a good practice to, to start writing the variable names in a better way. One, one betternotation, one better notation of defining these variable names, even the function names,we will see the functions later on. One way to defining those is to use camel notation.camel notation camel notation is you start with the variable name with for example, lowercaseletters, let's say your variable is starting time of the course. Let's say that's yourvariable name. So you write starting, that's one word finishes, then the next word shouldstart from capital T, starting time of the course, let's say. So this kind of notationis called camel notation. And very famous, particularly the Java developers, they normallyfollow this and several other developers. But you should come up with a notation thatis one notation, there are other ways of keeping consistently keeping the consistent strategyof defining variables. There are several other ways this is one way. So starting time ofthe course is let's say 2.0. That's it. So that's a variable name, if you if you nowcheck, that's a variable name. But now, if you see this variable, just just the namesuggests the data inside is doing what? So the names should be descriptive, I mean, andmake that as a habit. So, yeah, I guess we have now answered our question very concretely,that variable name cannot start with a digit not with any special character other thanunderscore, okay. In the next video, I will be introducing comparisons with with variables.For example, what if you want to compare whether one variable is smaller than the other ornot? What if you want to compare whether the two variables they are containing values theyare same or not? What if you want to do comparisons of the of the data that is stored inside thevariables, and based on the result of the comparison, you want to do something else.So in the next video, we will see a bool data type that is very, very famous, and it isused in a lot in decision making. And we will see the comparison operator sometimes calledthe relational operators in the next video, so hope to see you in the next video. Okay,in this video, we are going to talk about a data type which is called bool. That's very,very famous data type. Actually, it's the most famous data type because it is used indecision making all the control flow most of the controls, so depends on this data type.Although it is very, very famous, very much applicable data type, it is very simple. Itis a data type with just two states with just two values. By the way, there are capacitiesof different data types. For example, in T integer, thedifferent kinds of values that you can store are huge, you can store any negative numberin it, you can store zero, you can store any positive number, the capacity of floatingpoint number or the number of values that it can save is is even higher than even higherthan integer and the complex number is even higher than that and so on. But the bool datatype, it has just two states one state is true. It has just two values. True is a value.And false is a value just these two straights true or false. In some programming languages,the true is denoted by one, and the false is denoted by zero. But in Python, the trueis just t ru e true that thing and false is false. That's it. If you For example, definea variable let's say any variable name, whatever the name is, let's say B and you assign truethen it's its default data type will become bool. And if you have another variable, let'ssee which is false. Then C is also bool. One thing that is important, there are other operationsother than arithmetic operators that we saw, adding subtraction division and stuff, thereare other operators that we can apply on bool datatype. For example, a true and and is akeyword combining true and true. If if there is a variable, let's say a with a There isa boolean variable a with data true. If there is a boolean variable b with data true, thena and b is also true. So let's say I've used this variable D, in storing this A and B,the D will also be true. So true and true is always true. Further true and false, thisis always false. And this is committed if for example, true and true is true, true andfalse is false, false and true is false, false and false is false. So, if you apply an operatorand keyword to combine the two Boolean variables together, if both are true, then and willresult a true otherwise and will result of false other than this and there are thereis there is another, there is another operator, keyword or so, this results false. If bothare false, false, false, false or false is false. If any one of these is true, then theresult is true. Remember the difference between n and R and will result false if any one ofthe two operands at least one of the two operands is false,then the result is false. If both are or are anvisa true, if both of the operands are true,otherwise it is falseor will result false if both of the options is false or false. Otherwise it is true. So,you now know and you now know are there is another operator called not. This is not sonot for example, returns not true. Results false and not false. returns true. Great.So knot is a unary operator. unary means it just takes it just takes one variable andoperate on that, and is a binary operator like plus is a binary operator. It takes twovariables to operate on, or is a binary operator it operate, it takes two operators, it takestwo variables to operate on and so on. So remember, remember these things, one, andwe'll return true if both of the variables are true, otherwise the result is false, orwill result false. If both are false. Otherwise, it will return true and not is not just flipsthe the state. So not true means false, not false means true. So these are basic, that'show you can combine the Boolean variables together. In the next video, we will be seeinghow to apply these comparison operators and the result will be Boolean types. And howcan we combine the Boolean types together to to build a better decision making. So inthis particular video, I just, I just introduced the boolean data type for you with you. Inthe next video, we will see where the boolean data type actually appears, and how it impactsour, our our programming style or thinking style or coding style. So hope to see youin the next video with comparison operators that actually produces the Boolean variables.Hope to see you in the next video. Okay, in the last video, I discussed boolean data typeand I discussed that a boolean variable takes either a true or a false and we can combinethese Boolean variables together with and our operators. And then we can apply a knotoperator on a particular variable. And we we saw that a true and true returns true andand otherwise it also returns false. Similarly false or false is false. Otherwise, or alwaysreturns of a true before before actually discussing these comparison operators. Let's do let'sjust go to Jupiter and just just play with a boolean data type. Just Just for just fora moment. Let us just convert this to markdown cell and just cried. Both that's a word Booleanvariable. So let's say A is true and B is true and C is false. False. And okay, so theseare variables. Let's press those to see what are the states of. So, a is a boolean variablewith value true B is a boolean variable with value true C is a boolean variable with valuefalse. So, now it is true B is true, C is false. So that means, let me print print aand b, what do you think? What is what will be the result? Let me print a and see whatwill be the result. And let me Brent? C and A. So because a and b both are true, the firstresult will be true, because C is false, false, true and true is true. The the other two statementsthey will result false. So first value will be true, then false false. So yes, true, falsefalse. Let's, let's check the or print. And by the way, let's store that are in anothervariable, let's say A is true, or C is false. So what do you think what will be the resulthere, because or gives false when both are false, here is true. So the value of d willbe truefor the not a, because A is true, not a will be false. Similarly, not B, B is true. Sonot B will be false. Not C, C is true, C is false, and not c will be true. Similarly,not D, we can save the result in another variable, let's say D. and we can just check the typeof D if we want, that's a Boolean, we can also check the value inside D and that isfalse. So, yes, not only that, I mean, we can we can we can we can combine at a higherlevel for example, A and A and B, whatever the result is, or C or D, whatever the resultis, and whatever the result is not of that. I mean, we can we can combine them in a verycomplicated way. If we want a and b the result will be some Boolean, that Boolean and thatBoolean thereare theresult eventually will be a Boolean, and then not have that. So let's check what if thatis the result is false, well, why the result is false. figured out why the result is false,let me go to comparison operators. So, the comparison operators, let me just go throughcomparison operators. This equal equal to it compares whether two variables whetherwhatever the variables are whether they are integer floating point, whatever, whethertwo variables are are, they have same data or not, for example, x equals equals two y.That will be true if x and y, they both have same data. So for example, if X has valuefour, and y has value four, then we are just checking x equals equal to buy or not, theresult will be Boolean. Because an X may not be a boolean variable y may not be a booleanvariable. If we want to compare the values of x and y, then we write w equal withouta space inside. Remember, if we write single equal that will be an assignment operator.If we write w equal that means we are checking whether the two values are same or not. Similarly,if we write this particular symbol that checks whether two values are not equal or not, forexample, x is not equal to y, the result will be true if x and why they both have differentvalues, otherwise the result will be false. Remember, the result of comparison is alwaysa Boolean, it is either true or false. Okay, next we check whether less than So for example,if x is less than y, the result will be true. If x indeed has a value that is smaller thany, let's say x is two and y is 10. In that case, the result will be a true otherwisethe result will be false. Similarly, we can compare the two variables using greater thanwe can compare the two variables by less or whether whether the whether one variable lessor equal to the other. For example, if X is less or equal to y, the result will be trueof this comparison the result will be true if X has a value that is not larger than whyas long as x and y are equal or x is smaller than y In any case, the result will be trueotherwise false. Similarly, greater than or equal to. Okay, so I end this video here inthe next video, we will be, we will be moving to Jupiter and playing with these operators,and seeing the return types of Booleans. And then combining them together with ands andORS and doing doing interesting stuff with that. In this particular video, I just talkabout the comparison operators, the boolean data type and combining them by and or not.In the next video, we'll be first moving to Jupiter, we will see the comparison operators,we will write all these statements in Jupiter and just get a good hands on grip on that.And then we'll be moving on verse. So hope to see you in the next video. So in the lastvideo, I talked about comparisons, w equal to not equal to less than, greater than, lessthan or equal to, greater than or equal to. So let's go to Jupyter Notebook and see howthey actually work. So let me just first enter a markdown cell and type comparisons. ShiftEnter comparisons. So we can we can compare different values by first assigning them tovariables. And then comparing those variables or we can we can compare the values directlyor for example, rent. Two is less than three. What do you think two is lesson three, theresult will be what Remember, the result of a comparison operator is always Boolean, itis either true or false. So in this case two is smaller than three. So the result willbecause this statement is true. So the result will be true and true will be counted. Further,we can store that result in in another variable for example to is smaller than three, whateverthe result is, the result will be true, the result will be saved in a variable, see, ifwe check the type of seereject the type of seeing as long as let's print the value of C. So you can see the typeof C is Boolean, and C in this particular case is true. Moreover, for example, let'shave three equals to four. Is that true or false? What do you think three equals to four,three, w equals to four, that is false, three is not equal to four. And let's save thisresult in D, remember three double equals to four, that's an operation the result isfalse. This equal is an assignment operator that the false value will be assigned to thevariable D. and here we can see Brent D. Burn it is false. Similarly, what do you think?Three double equal to 3.0? What will be the result? Remember, three is integer. 3.0 isa floating point number. And I'm comparing three double equals to 3.01 is integer, andother is a floating point number. So what will be the result? Let's say the result istrue, because they are comparing the values by discarding the decimal position. Further,let's see. Three is smaller or equal to so let's say x is equal to four, y is equal tonine. And z is equal to let's say 8.3. And r is equal to minus three, let's say and theseare our variables. Let's see. So what do you think what will be the result here x is smallerthan y. What will be the result of that x is smaller than y, the result will be trueand z is smaller than z is smaller than y. The result is again true because the smallerthan y or r r is r is equal to for example, x. So what do you think what will be the resultat the end after this, so, let's see first first this will be true, this will be againtrue, and that is false. Okay. So, this true and true will return true and true or anything,the result final result is true. So, this will return or it's returning true. But, ifI just do if I just switch the order, for example, if I just write this statement, whichis false, this particular statement here and then I do this, what will be the result now,Now see, x is smaller than y it is true, r is equal to x that is false. So, this resultwill be false eventually, and z is smaller than y, that result is z is smaller than y,let me just say z is larger than one, let me just check z is larger than y, z is largerthan I just just do just to tell you. So, this is true, this is false. Both of theseare let me let me switch the let me switch the listing r equals to x, I just want toshow you the precedents of r and x is smaller than y. So now, if you see this is false,this is true, false and true is true, true or false and true is false, this is also false.And the result overall is false. It should happen, but what if, what if this goes first,if this goes first, I mean, I want to show you whether and an AR, which one of them willoperate first. So, in this particular case, the result is false, but it can happen letme let me tell you this in more and two, or false and true or false. Andtrue,what do you think what will be the result here, true or false and true, if true or falseoperate operate First, if true or false operate First, the result will be true, true and true,the result is true. If however, let me let me just write a false here. If all operatesFirst, if all operates first, then false or false is false and false and true is the resulteventually is false. And if and operates first, then false and true is false, false or falsethe result in both cases here is is false. So, a better way of representing these kindof sometimes sometimes they can make confusions, sometimes they can make confusions, for example,if we have a true here, if you have a false here for example, false and trueHow can I so, false, false and false or true. So, in this case, if in this case, if falseor true that operate First, the result will be true and false and false, false and truethe result will eventually be false. However, if n operates First, the result will be falsehere, false or true the result will be true. So, here if and applies if you apply if nis applied first, then the result overall result will be true. But if all is appliedfirst, then the overall result will be false. So it is it is good to know whether and willbe applied first or off will be applied first in this particular case and will be appliedfirst even if you even if you change this even if you change this order for example,if you even if you pick this thing and apply here still the result is and will be appliedfirst and or will be applied after, it is always good rather than to one way is to rememberthe precedents and will be applied first then or, I mean it is good to think about the precedents.Another good thing is to specify the order using parentheses. For example, now, we specifythis first our will be applied and then four and will be applied. So, it is good for readabilityto always apply these parentheses and and check the order in which ands and ORS andthe combination will be applied. So, the in any way the result of these comparisons willbe bullions. Question, what will be the result here? So, not to not equal to three and trueor false and true. See this slide for a while. Even if you want to pause the video, pausethe video, see it? and answer the Brent will return true or false. okay with this question,I end this video. In this particular video, we just saw the comparisons on Jupyter Notebook.Just see how the comparisons return true or true or false. We combine the different toolsand different Boolean values using ands and ORS. And here is a question for you. Okay,I will see you in the next video with answer of this question. So I left you with a questionin the last video. So that was the question if you remember. So the question really was,what's the what's the result here? So what's your answer? True or false? The result, eitherwill be true or false, because these are all comparisons and combination of Boolean values.So let's see step by step. First of all, let's see this two is not equal to three The resultis two is not equal to three Yes, it is true, two is not equal to three That's true. Sonot true not true is false. So, this is false. So, this whole thing is false. Now false andtrue false and true that is false. So, this whole thing here till here is false. Now wehave or or and then we have false and true false and true is false. So, this whole thingis false this whole thing is false and or between false or false it is false. So theresult of this. So the So the answer to this question is is false. Let me let me just convinceyou by typing the statement in in Jupyter Notebook. So, if you remember we have Brent.Brent, not two is not equal to three and then we were having I guess and false and yeah,that was a different one. And true, sorry, that was and true. So this was and true, thenwe were having ourand then we were having these false and true. So the front ends here and the result is Oh,I have some I have some parenthesis mismatch. So not true and this okay, I should have thisone I guess this goes to there and this goes to there and I guess Yes. So the result isfalse. The result is false. The purpose of this question was not just to the purposeof this question is to appreciate actually the fact how we can combine different Booleanvalues to to to achieve the final boolean value and these kind of combinations willbecome very, very helpful further in in control flow and we will see the if conditions anddecision making and stuff so The answer to this question is false. Yeah, and I end thisvideo here. In the next video, we are going to see some useful functions of Python. Andafter seeing the some some kind of useful, there are a lot of functions, we will seejust a few of them very useful of them. And after seeing those functions, then we willdirectly jump to control flow basically the if conditions and stuff where you will seethese comparisons, these Boolean values in a much more applicable sense, then then earlier.So hope to see you in the next video. Okay, so let's have a very quick tour over somesome useful functions in Python. Obviously, there are a lot of functions in Python, butI will be covering just a few of them. That I think with the passage of time, we willbe covering more and more but let's start a function are sometimes, particularly a builtin function is is basically a feature from the language that is supplied for the usersto achieve particular task. For example, around function. If you give round for example, around,let's say 4.6. This 4.6 is a floating point number, and rounding means make it as integer.And what round does is it finds the nearest integer to 4.6. And the nearest integer inthis case is five, because five is more closer to 4.6, then four. However, if you call round,for example, on four point, let's say three, then the result will be four, because fouris more closer to 4.3, than five. So that's one use of round eight rounds, basically roundsa floating point number to the nearest integer. Another use of round is if you give anotherargument that that is called an argument to the function. For example, when you writeBrent. Brent, let's say a, this a is called argument to a function Brent. Similarly, roundis a function 4.6 is an argument round is function 4.3 is an argument, we will see functionsin details, and we will be writing our own functions as well. But for now, just justbear that just bear with me that functions are these kinds of features that are available.However, we we will be writing our own functions later on. So this particular function acceptstwo arguments surround has two different kind of implementation. One is when it acceptsonly one input argument, it returns the nearest integer to that, if it accepts a floatingpoint number as well as another argument like here we have three, that means after afterpoint, after decimal, go to three places only, and then round up, then round, for example,this 4.55 and then eight will be rounded based on its next value. If the next value is largerthan five, then eight will go to nine and stop. If the next value is smaller than five,then it will stay as eight and the result will be three decimal places after this. Solet's practice this round function just on a Jupyter Notebook very quickly. Let's see.So here we are. So let's see rent around, let's say 4.556. And in this case, the resultwill be 4.5. And the reason is 4.5. And it's rounded up, it stays to five and the reasonis this 4.556, it is more closer to five thenthan four. However, if you if you just print round, four point, let's say 345. Let's see,and the result will be for the reason is 4.345 is more closer to four. However, if you callthis round function with more than one argument, for example 4.556789 let's say or with argument,let's do that means the result should be only two decimal places after the after the decimalpoint. So in this case, the result is 4.56. And the reason is, this five is rounded basedon the next digit and the next digit is larger than five. Hence it is rounded up. So 4.56If however, I call this function for three Then what do you think what will be the resultit will be 4.55. And the six will be rounded up based on the seven, and it will become4.557. Yes. However, if, for example, there will be a value at at the place of seven,if there is a value, let's say three, then you call this function, then 4.556. And thenbased on the next value three, the six will stay as six rather than going to nine, andthe result will be 4.556. Yeah, so that's, that's the, that's the round function. Basically,another function is diff mode, diff mode function basically divides and returns quotient, and,and remainder. So in the next video, we will be seeing this diff mode in detail how itactually works and how, how it is useful. So in this particular video we saw aroundfunction in the next video, we will see diff mode, and there are a couple of more functionsthat we will see in the upcoming videos. So hope to see you in the next video. So in thelast video, we saw round function that sometimes accepts one argument and sometimes accepttwo arguments and behave accordingly. In this particular video, we are going to see anotherfunction dev mode. And it accepts two arguments, two different arguments, but maybe same ordifferent arguments. And it it returns two outputs, two numbers, two terms basicallyquotient and remainder. For example, in this particular case, the quotient is five, andthe remainder is two, because if five is divided by if 27 is divided by five, the result isfive, but then the remainder is two. And the result is returned in a kind of an orderedpair. And these kind of collection in which we have two or more elements, we call thesecollection as tupple that we will see in detail when we will see the data structures moduleof this course. But right now just bear with me that it returns two numbers, two elements,and the two elements are ordered in an ordered pair, which is called a tupple. A tupple isnot just an ordered pair, it can have three more three, four, or five or seven, or maybeseveral elements. But right now we will a tupple is just an ordered list, which we willsee in detail. So let's see the working of the stiff mode function in in Jupyter. notebook.Let's see. So let's say we have dev mode. Let's say for example, we have 34. And thenwe have lots of them. Or maybe let's say nine, so what do you think what will be the quotientand what will be the remainder. So 918 27 So three, three is the quotient. And the remainderis remainder is seven. So three is quotient and salmon is the remainder. So and if yousave the result, for example, if you save the result in a variable, let's say G. Soif you see the G the type of G if you if you just type the type of if you just find thetype of ci it's a tupple, which we'll see in details, and if you see the contents ofG if you see the contents of G the contents of gr three and salmon, and if you want toaccess each element independently, then you can access the element first element, becausethe if there are multiple elements in in a variable normally that that kind of variablesare called collections that we will see in detail later on. And these are the indexingthe positioning is start by zero rather than one. So g zero means the first element ofG which is three in this case, and the second element of G is oneat one, which is seven. So, this is basically this is called the index or position of ofelements or data in this particular collection, we will see these indexing and all these kindsof collections in detail in in the in the data structure scores, and we will see arraysand strains and different kinds of structures. But and default sometimes is, is basicallysometimes it is helpful. By the way you can achieve dev mode by by another by anotherthing. For example, if you want to achieve a more 34 nine, you can do the same thingby let's say 34 divided by double divided by nine that will give you a quotient. Andthe question is three and further if you write 34, remainder nine and that will give youthe remainder that you need. So you can call that function Dave mode. Or you can use thesetwo there are multiple ways of doing the same stuff. Okay? So, yes, so, I mean, sometimesit's useful when you're going and knowing this kind of function that returns quotientand remainder. Okay, next function that is more useful is is in stance, and we will seethis function in the in the next video. So hope to see you in the next video okay, thisfunction is in stance, it actually returns either true or false. And it just checks thatparticular given data value belongs to this type or not. For example, if you want to checkwhether one has type integer, so, you can check that using this function by the way,you know that one is of type integer then you may think that why on earth one shouldbe interested in checking the type of one if somebody no it is in teacher, sometimes,we have certain variables and certain data is stored in it, and we want to check thedata inside it belongs to which kind of type and in several cases the value to this variableis not assigned by us It may be read from some file or maybe through input a user givesome number or something like so. So, sometimes it becomes important to check the type ofa particular way if we are if we are expecting a particular type of the input and the inputis different than this function might be helpful. somewhere. Either way, this is a functionavailable in Python and it checks whether the given value has a particular type of not.So is instance one int returns true is instance 1.0 integer that returns false maybe, becausethis is a floating point number, and you can check a particular value belongs to one ofthe several types or not, you can give several types in a in a tupple. And you can checkwhether it belongs to this, this or not. So, let's go to Jupyter Notebook and see, actuallyhow it works. So, by the way, this is the same notebook that we have, that we are populating.So, hold on with me, at the end of the day, we'll be having one notebook complete. So,is in stance is instance, let's say three is that instance of integer The result istrue in this particular case, if for example, we check whether is in stance 3.4 is thatnmt? Is that an end user? The answer is no it does not end in Deezer. If for example,we check if this is not in nature, then maybe it is a float? The answer is yes. Or maybewe check that. For example, if that value is either float or integer, if it is one ofthese, then I mean check that particular value in this particular case 3.4 whether it belongsto one of these types, we can increase these types, for example. So, let's say we we gavea complex number here and check is in stance let's say two plus three j that's a complexnumber. And let's say we asked whether it is an integer or float or not, the resultis obviously false. And the reason is, it is neither integer nor float or even if wegive string there str, so, it will still say no it is notnot any of these, but maybe there is a complex data type if you see that, that says yes,because it is complex. So sometimes this is instance becomes really useful. Next functionis power. So power you can you can compute power by the way using using for example,if you want to compute x raise to the power y, you can use double star and that computesexactly x raised to the power y or equivalently you can call the function POW x comma y andthat will give you the same result as this one. But power sometimes take three argumentsas well. And in that case, it it a it performs the power function in a different behavior.So for example, if you supply three arguments what it does it it raise y to equate x raiseto the power BI whatever the result is, then it takes the remainder by z and gives theresult. So let's see the functioning of this power function in Jupyter Notebook. So let'ssay Baba, I want to compute to raise to the power for the result is 16. No problem. Toraise to the power four, I can compute the result 16 this way as well. But here is anotherway, how can we use this to raise to the power for whatever the result is, then I want totake the remainder, by let's say, I want to take the remainder by seven, or two, so we'vegot four is 16, then if we take the remainder by seven, the result will be two. And that'sthe result two. So that's how you can use this power function. I'm just introducingyou some built in functions that are available, there are so many functions that are available,I'm just getting you comfortable with these kinds of functions so that in future if yousee another function that he had not seen here, you'll be able to use it and apply it.So in this particular video, we saw this is in stance function and this power function.In the next video, we will see one more function that will allow you to take input from theuser. So far, we are supplying values or assigning values to variables directly, what if on thefly, we want to give the values and those values should be assigned to the variables.So in the next video, we will see the function, we will see a function that will allow youto give input from the keyboard, hope to see you in the next video. So in this video, weare going to see a very important function called input. This function is I mean, thisis beneficial for taking input from the keyboard from the user. And the way to call this functionis you type input. And then you type a message that actually describes the expected entrythat for example, into something if you want somebody to or tell somebody to just incurlet's say, a number, you can write into a number, or any specification to help the userto enter whatever input the user want to interest properly. One thing is that no matter whatthe user will enter, the variable a will be having type string, str. So even if you entera number, let's say 12, or 34, or whatever, that will be received as a string. And thenthere are ways to convert string to number if that really was a number. So whatever youreceive using input function will be a string. And then there are ways to deal with thatstring, if that was a number, how to convert that string to a number, and, and so on. Sofor example, let's see, let's see on the Jupyter Notebook, how it works. So let's see, forexample, x is equal to input, enter a number. Let's see. And then then if I press ShiftEnter, a prompt will appear in front of you, that will require you to enter a number forexample, if I enter, let's say 56, and then I press enter, not Shift Enter, Enter, thenx will receive 56. Now, you might be thinking this 56 is an integer, so the type of x shouldbe an integer. But this is not the case the type of x will be a string. And the reasonis, whatever you enter is received as characters five and six, even if you have entered somethingelse that would have been received as a sequence of characters. So this is no longer a fiveas a digit five, six as a digit six. These are some characters sequence of characters.Now, if you want to,I mean, there are ways to convert this x, for example, maybe you want, let's say, yor x as int x. So this means you have now converted this string to integer and thenwhatever the result is, you have stored that result in x again, if you now see the typeof x type of x, the result is integer. And you can for example, print x minus 34. Andthe result is 22. Because X was X was 56. So this input function is I mean, it is anone way by the way, if you if you're expecting an integer or a float value, for example,let's say you're expecting a float value, then it is good to write input, let's sayenter a real number, maybe or any message, any message and then at this particular timeat the time of import, then it is okay to convert that thing to float and it will becomea float. Yeah, that's it. So, now, for example, you enter 12.5 if you see the type of a now,type of a will be float okay. But there are problems for example, if you are if you areexpecting float and somebody enters into something that is not float for example, a or let'ssay B equals load, input enter are real number, let's say and then you press Shift Enter andsomebody just interest let's say ABC. So, now, this is not a float ABC cannot be convertedto a real number no matter what. So, you will catch an error there are ways to avoid thesekinds of errors and programming program breaks using exception handling and there are otherways, but be careful I mean the user is not I mean the one who is going to enter the theenter the input if that that user is not restricted enough, then you can get errors. So, I mean,this is not the case that whatever you will enter it will be converted to a float if itreally, if whatever you have entered is really to convert it is really convertible to a floatthen it can be convertible to a float, not otherwise. And at the input time, there isno restriction you cannot restrict the keyboard to enter water or whatnot, although thereare ways although there are ways to do that. So that's about the input function. So, wehave seen some of the functions, let me just let me just go through quickly we have seeninput we have seen is in stands, we have seen diff mode, we haven't we have seen power function,we have seen the round function and there are several others. Yes, so from now on, wewill be actually moving towards basically decision making based sometimes we will usethese kind of functions, mostly you will be using input function, but sometimes we'llbe using maybe other functions like these functions. And sometimes we will be doingdecision making based on the ease and and stuff like so, one thing that I want to tellyou is if for example, you know the function name, some function, let's say like power,you know, that POW power is a function, but you do not know how to use that function.One way is to just type question mark in front of it, and then just press Shift Enter,and in front of you, the documentation of the power will open up so it will tell thatthis is power, that's how it should be called and then some description will be in frontof you that equivalent to x raised to the power y with no arguments, the two argumentsare equivalent to x raised to the power y remainder with z with three arguments andso on, if you want to see implementation of this function as well. We will see the functionslater on but if you want to see more about the help, you can type the double Sam equala double question mark and more things should be open up in front of you. So, in this particularcase, the small function does not have an implementation in Python. So, the single questionmark and double question mark are the same at one more way is to use the help functionhelp out and you will get a lot of information about the power how for example, help on builtand function power in module built in. So this is power this is equivalent to this somekey types and stuff like so, or for example, you want to know how can I use the input functionfor example, so you can write help on input and this is how this can be used. So sometimesit is okay if you know the if you know the name of some function, and you know how touse it, you can just open up the documentation right here in Jupyter Notebook by either usinga help function or you can use just a question mark in front of the name and so on. So, that'sabout the functions. In the next video, we will be seeing the power of comparisons andthe decision making or sometimes called the control flow. So the real fun will begin fromthe next video because we will be actually deciding which part of the code should runand which part should Not run based on based on certain conditions. So hope to see youin the next video. Okay, we are in control flow, the most interesting part of any programminglanguage will assume that you have two numbers, you have taken two numbers from the user a,you've taken that number from the user using input, I have not supplied the input messagehere, the message is optional. It's a description if you supply that that's okay, if you don'tsupply even that, that's okay. So A is some number the user will supply when the codewill run B is some number the user will supply when the code will run. Now, once you havea and b in front of you, obviously the user will supply that on the fly, you don't knowwhat the value of a and b are. Because when the program will run, only at that time, theA will be populated and B will be populated. Your task is whatever the value of a is thatis that you don't know whatever the value of b is that you don't know, the user willsupply that value those values, your task is to print the value that is bigger thanboth. So for example, if a is bigger than B, then print a if b is bigger than a, thenprint B. So whatever the bigger value is, print that value. Let's say that's your task.How can you do that? So the question is how does Python allows us does Python allow usto do that, for example, if a is bigger than we should print a, if b is bigger than weshould print B, remember again, and again we are we are talking in terms of if A isbigger, if so this is this is this is what if a is larger than B, then this conditionwill be true. This is like the comparison. So this is true, but then we must have anF condition as well. If A is bigger than to what, so if a is bigger than B, then do certainthings. Otherwise, don't do that. Those kinds of things. So this if condition is really,really powerful, and is available in all programming languages. In here, for example, let's seeif a is an input B is an input, writing an if condition, that's if is a keyword. That'sa comparison that we have done earlier as well. And then the syntax required a colonin front of that. So if this condition is true, if this result, if this comparison resultsto remember the comparisons, they return Boolean values, if this comparison, if this, whateverthe result of this operation is if that is true, then you go into this block. And whateverthe statement inside is do that, for example, print b is greater than a.Now my question is, is that is that done? Are we done with the task, the task was toprint the bigger number. If b is greater than a, then B will be printed then or they mighthave printed, for example, we might have printed rather than writing this we might have mighthave printed, let's say just print B because b is bigger. If b is not bigger than a, whatwill? What we will do them. So yeah. If b is bigger than a then B will be printed? Yes.Because then you will be inside here. If b is not bigger than if this condition is false.We will do what then? So that's a question. So right now I'm just coding this in Jupyter.notebook. And then we will see how can we deal with that if b is not bigger than a kindof condition? So let's first see the blessings of if condition and Jupyter Notebook. Yeah,so let's say a is an integer. Let's say you're expecting an integer input. input, let's sayand then you write if, let's say B is again, an integer input maybe. And let's say if ais greater than b, then print a. That's it. That's your program. Remember, this indentation,I have not written this print here. This is the indentation that defines the block ofa let's say if I want to print a, then I want to print, let's say, I am still inside. Ifcondition, condition, and so whatever that starts from this, whatever that starts Formwhatever that starts from this alignment, if I write something here, let's say x isequal to five, all that block all that block is called the body of the if condition, ifit starts from this alignment, If however, I I typed a statement, but I typed that statementin that kind of alignment, the alignment like this, this is no longer inside the if condition.So, for example, here I type I am outside the if condition. So, the purpose of writingthese multiple lines is just the if condition does not require to contain only one lineof code, it can contain a whole block of code multiple lines of codes. So, this is no longerinside the if condition. So, now we will take input a input B, whatever the numbers willbe, if the value in a will be larger than B, then this will be printed and this willbe printed. Once these two are printed, then this has to be printed regardless of the valuesof a and b, because this does not this last sprint statement, it does not depend upon.This does not depend upon the values of a and b, it has the if condition has no impacton that, that is just a sequence of statements. the if condition, the statement inside theif are just these two. For example, if a is not bigger than B, then neither this willexecute, nor this will execute. But this will still execute because this is this has nothingto do with the condition. So let's run this code and see how it works. So let's set thevalue of a see the power of descriptions. If we could have written a description, thenthe description could have been could have appeared here. But let's say this is the valueof a let's say 12. The value of b let's say, let's say 10. In this particular case, becausethe value of b is 10, the value of a is 1212 is bigger than B if this condition is true,this statement becomes true. Whenever this condition becomes true, you're inside theprints you are inside the if condition. Now this print executes and you're you get wellthis print executes and you get I am still inside the if condition, and this has to executeno matter what the values of NBR so now let me read on this and give other values of aand b let's say the value of a is 10. And the value of b is let's say 45. Now, thiscan this condition becomes false because 10 is greater than 45 this is not true, thisis false. So whenever this condition is false, you never land inside the if conditionand you go out from the if condition. So these are the statements that are inside the ifconditionthey cannot execute because because you never visit them, they can only be executed if conditionbecomes true. So then once you're out the if condition that's the statement there isgoing to be executed anyways. So yeah, so that's the flavor of if condition on the seeand making and this is the comparison operator that returns a Boolean value. You may havedifferent kinds of comparisons here or combination of comparisons here No, no problem dependingupon your logic. But the question is, are we done we are going to print only the biggernumber we have, we have printed the one that is if a is bigger, we have printed that whatif if b is bigger, we have not solved the task yet. This is the task we have not solvedthe task yet. So how to do it. Okay. So yeah, it looks like complicated. How to print onlythat number that is bigger. So if b is bigger than a, then we will print B. Maybe Maybewe should make maybe we should apply another if condition. If b is bigger than a then printB. If A is bigger than B, then print eight, maybe. Yeah, why not? Soum,so for example, let's go to Jupyter Notebook and, and write the following. Let me let mewrite a whole new program here. A equals and import. Okay, let's do not have a messageand input and then if A is bigger than B, then print a. Okay. However, if B is biggerthan a then print B, I guess we are done. If this condition becomes true, then we arehere and we know if this condition becomes true, then this condition cannot become true,because it cannot happen there is because then B as well as B is bigger than a Thiscannot happen. So, whatever the bigger number will be that will be executed further youcan see I have this if condition and this if condition they are aligned in a way thatthis if condition is not this the second if condition is not inside the body of the firstif condition, we will see such cases such cases when this is required. But right now,I guess we are done. If A is bigger than B, then print a, if b is bigger than a then printB and only one of these if conditions will become true, because A is bigger than B Bis bigger than a, these two statements cannot be true at the same time. So, let's see. SoA is 10, b is 45. So the answer is 45. Well, because 45 is bigger. So let's run it again.So A is let's say 22. b is let's say four and the result is 22. Because 32 is bigger,I guess we are done with the task, we have used this if condition twice to achieve thetask to print the number that is bigger and both the numbers we we took both the numbersfrom the keyboard Yeah, I end this video here. And in the next video, I will tell you morefeatures of this if condition particularly the L statement, whatever what we have donerecently with another if could could be achieved through an L statement that is more powerfuland more readable. So in the next video, I will talk about ELS statement which is a partof F so hope to see you in the next video. Okay, in the last video, we saw if conditionand we actually had an example in which we wanted to know we wanted to just print thegreater number. So we input a number a we input a number B and if b is greater thana we printed the is greater than eight, then we applied another if condition to check ifa is greater than b, then paint a the else clause or the else part of f is as as thename suggests, if this condition is true. So, if this condition is true, this particularcondition is true, then go there. If this is not true, which means else if this is true,then go there, else go there. So if this is true, then you learned here, if this is false,then you learn else part for sure. And this else is I mean, if b is greater than a ifthis condition is true, then you print this thing. Otherwise, a might be greater thanB or A might be equal to b either way you learn in else part. So this if and else theyboth have this alignment, but then the block of ELLs started from this particular alignment,maybe you have more statements here, the alignment of this if block structure from here, andyou may have more statements here. So let's go to the Jupyter Notebook and see the elserunning. So let's say a equals and input and B isB is int input and we say okay, if a is greater than b, then brand aelse else rent else brand be elsewhere outspent B. Now B will be printed, even if it is equalto A or if it is greater than a either way, B will be printed. So let's just see. Let'sjust run this and see what happens. So Shift Enter. So input a number. So A is let's say10, and B is let's say, 12. So what do you think when I will press enter what will beprinted, B or A, B, B is printed, that's what B is printed. Now, if I run this again, anda is done, and B is done, still the 10 will be printed. So let's modify it, let's, let'sjust say, print. If part. So that means we landed in if part. Otherwise, we landed inEllsberg. So just to be more elaborated, let's say so 10 and 10. And we landed in L sport.And the reason is if a is greater than b, so 10 is greater than b 10 is greater than10. False. So you got two L's, and the LS block, the whole block just executed. So that'swhat else is, it's really very nice to have an L state or whatever this whenever the,if this is false, whatever that condition is, if that is false, then you learn in else.So yeah, that's the health part simply now, okay. So, we have this f l structure, we canhave one more power with this F, what if we want, if a if b is greater than a, then youprint B. Else, if A is equal to b, then you print they're equal. And if this is false,and this condition is false, if both these conditions are false, then you go to elsepart. So basically, if else if else if else, if else, so, you can have really deep structurefor example, in this particular example, if b is larger than a, then you land in thispart else, if this L is just short form of else, else means B is not greater than a else,you can have another check elsif A is equal to b, then do what?ll, if we can have one more check, we can have one more check, we can have several checks,and then else else will only execute if all if conditions or elsif parts on top. Theirconditions, they are false, and only then else will be execute. So let's see these ldiff running on Jupyter. notebook. Okay, so let's say a is and so rather than taking inputs,let's say is one, B is let's say five. Let's say we have taken these inputs is one B isfive, if A is if a is equal to b, then the word rent equal l l F, which means else ifnow, because this is if you should you have to write a condition here, which will be eithertrue or false. If A is larger than B, then do what? then print, let's say, a. And else,let's say your brain be okay. So that's it. And this statement, rent is not in if conditionNot, not in if this is outside complete, this is complete if condition with all its L'sand LDAP parts, and this is no longer inside. So let's run this. What do you think whatwill be the result if A is one B is five, then else bar is going to be run because Ais not equal to B, A is equal to b that's false is larger than B that is also false.So you will learn in export and B will be printed and then a statement will be printedwhich is not an F. So yeah, so B is printed and not an F. If b is 10, then what will happen?A equals to B that is false, so you will not land here. Else if A is larger than B true.You will land here because you land here else will not execute. So He will be printed andthen not enough. If A is 10 and b is also banned, let's say, then you have equal. Yeah,so that's elsif. Okay, so that's about if else if else if or short form is lf l structure.In the next video, we will be talking more about this if else if else structure in abit more detail. And we will also be giving you a short form of this this guide of ELLsif elsif elberfeld of structure. So hope to see you in the next video. Okay, one way ofwriting this, if elsif else kind of structure there is a short form as well, which is writtendown here in a in this green color, for example. This is kind of a same code that we saw inthe last video, but that's the short form, let's say a equals nine and B equals 10, thenprint a if A is larger than B, else print this particular thing, if A is equal to b,l sprint that this is exactly the same kind of structure, for example, print a, if A islarger than B, so you just read that if a is larger than B, then print a else if A isequal to b, then print equal, else print that. So that is kind of a short form of writingthis if Elif else kind of structure. But I will, I will recommend to to to use, I'm inthe structure in this particular horizontal form. Rather than writing that in this particularway. Because this kind of structure, that horizontal kind of structure is much morereadable, much more manageable. And this might be this structure might be confusing sometime for for some kind of readers or, and also if this structure goes on and on andon, which we'll see in a in an example today. Writing that writing very deep and lengthystructures in short form is not very feasible. So although but but this feature is thereif you like to write if elsif else kind of structure in this way, this is available inPython. Okay, let's let's get a good grip on this f LS f l structure on Jupyter. notebook.Let's move on to Jupyter Notebook. To see an example, just an example. So let's saythe example is user will input a number, let's say int input, let's say and enter marks,let's say enter marks for a particular subject, let's say user with enter some some marks.And our goal is if the marks are larger than 85, then we will print a grade. If the marksare larger than larger than 80, but smaller than smaller, so if the marks are larger equalto 85, then we will print a grade. Else if marks are larger equal to 80, but smallerthan 85, then we will print a minus grade. And if else if if marks are larger than largerequal to 75, but smaller than 80, we will paint we will print for example, b grade forexample, b grade, and so on, let's print this whole nested structure that let's let's makethis else. if else if elsif kind of structure a little empty, let's let's get comfortablewith it. So if a is larger than or equal to 85 to enhance readability, it is good to includea space is a space after the variable and space but don't actually write the space insidethere because larger and equal to the combined without space is an operator. So if a is largerthan 85, then print let's say a grade rate l if A is a is larger or equal to a D andE is smaller than 85. So let me let me write this in a more readable form. Else if A issmaller than 85 and is larger or equal to 80 then we should do what it is sometimesgood to include these kind of parentheses sometimes it is good just to make these thingsmore readable that this is one block. This is one this is one Boolean, this is one Boolean,this is one to see and this font is E and although not writing the parenthesis is alsookay. But writing the parenthesis make code a little more readable. So, for example, ifa is smaller than 85 and a is larger than 80, if that is true, So, remember and is trueonly when the left side is true and right side both are true, then this whole conditionbecomes true. And I promised you that I will show you the power of comparisons and actuallycombining the Boolean variables using ands and ORS and stuff like so. So here you'reseeing the one. In that case, let's say brand. Let's say a binary sprayed and Elif if heis if he is smaller than if he is smaller than 80. And a is bigger or equal to 75. Ifthat's the case, then what should we do? Let me omit the parentheses just to show thatwhether writing parenthesis or not writing parentheses is perfectly okay. I just recommendright parenthesis, so the code becomes much more readable than otherwise. Okay, then wehave Brent, let's say, b grade. And let's say one more lF lF. If A is smaller than 75.And a is larger or equal to let's say70. samedi, then Brent b minus grade, let's say. And let's just finish this let's elseprint. below. Average, for example, let's say that's it, that's our, that's our record.So, we will we will enter numbers, if the number is greater than 85, then a grade if,when this condition becomes true, then this print will execute. And we will out of thestructure right there. If this condition is false, then this condition will be checked.If this condition becomes true, then this print will execute. And we will be out ofthis structure. If this is false, and this is false, then this will be checked. If thisis true, then we print degrade and we are out. But if this is false, then this willbe checked. And if this is true, then we'll print b minus grade. And we will be out. Ifthis is also false, then we will dive into L sport and we will say okay, below average.So let's see, for example, let's say the marks are at two. So a minus grade. That, that thatthat makes sense, a minus grade because the marks are smaller than 85 and larger thanlarger or equal to 80. So a minus grade. Let's, let's run this again. And we have let's saymarks let's say 64 below average. Okay, great. So you see this if Elif, Elif Elif else thiscan go as long as you want, depending upon your logic. So great. And further, you cancombine several comparisons several billions, together with ands and ORS, and nots, whateveryou whatever you like to like to do. Let me give you one more or one more beautiful thing.let's let's let's create an L without writing an else or let's let's just let's just writelF and implement ELS completely so we are not going to write ELS explicitly, but weare going to write a program that actually simulates ELS So let's see, if a equals let'ssay, three. If A is larger than 10, then Brent let's say larger than that. Now, we are notgoing to write else, but we are going to achieve the aerosport.Tell Ifnot,a is bigger than 10. To see, then print you see that I mean, that's beautiful. If thiscondition is true, then go there. If this condition is false, then not have false istrue, then you learn here. And you need not to write an expert if you want just I've implementedI have implemented l spark using l f. So see that. So l sparks so we are right now Spark.If A is let's say 13, then we will think okay, rather than just for fun, just for fun, okay.Okay, great. So, we saw if condition it's shorthand and LDAP structure in in a bit more,lengthy way. So in the next video, we will see if condition inside or in the body ofanother if condition, which is called a nested F. So hope to see you in the in the next video.In the last video we saw if lF structure, in this particular video, we will see nestedF, or are simply called if inside the body of another F. So let's take an example tounderstand what nested if condition is simply we can understand if condition inside anotherif condition, that's all rest of the story is same. The way it works, it works even ifit is inside the body of another if or or anywhere, actually. So let's say we have inputa number, and then we check if x is larger than 10, then you move inside the if condition.If that is true. If that is false, then you are here, whatever you write here, it willwork from here. But let's say x is greater than 10, then you print your number is greaterthan 10, your number is above 10. Let's say let's see Brent that now after this, afterthis statement, you move to the statement, and you just make another check if x is largerthan 20. Now you see this if condition. This particular statement is inside this particularif condition, if this, this condition becomes true only then you dive in, otherwise you'renot. So here you're checking if x is larger than 10, then you move inside and inside you'remaking more checks. So for example, if x is larger than 10, then you print or do somestuff here, then you apply Further more, more checks more graduality more, whatever yourlogic is. So let's say here you're checking if x is larger than 20. Now, if this conditionis true, then you move here else now this else is of this if if x is not larger than20, then you move to this else l squat and you're here. So and we can have another ifinside this particular F or an F inside this L sport and so on. So if inside an F is callednested if and we can have I mean deep structures, for example, if then something then if thensomething then if so maybe we can have a very lengthy structure if nested if structure dependingupon the logic. So let's get ourselves comfortable. As always, by writing the code on JupyterNotebook because that makes much more sense. When we see things running on, on on the notebook.So let's say a is let's say again, and let's say we take some number and if a is largerthan 10, then we say okay, Brent, larger than 10 and do more stuff, Brent. That's inside.If condition, okay, then then maybe we have another check if A is larger than 20 thensay rent greater than 20 Yeah, greater than 20. And you can rentnow rent inside the nested if, okay. Else rent l sprint, smaller or equal to 20, smallerequal to 20. And then brand, for example, inside the L spark of nested if that's it,and you can print here, brand outside all it's fine. So that's it that's that that'sthe structure. So let's see, let's give an input which is larger than, by the way, ifinput is not larger than 10, this if condition is false, then you directly dive to this printstatement and all this structure is not going to be executed, this is this complete thingis called the body of this if condition, and the body will only execute if the conditionbecomes true, whether that condition is just a single condition, or you have a combinationof a lot of comparisons and a lot of Booleans whatever, if this condition becomes true,whatever that condition takes form of, then Then and only then you dive into this part.And when you are in this part, then that's a whole new universe, then you're on its ownin the new part, in the new part, for example, if this condition becomes true, then you arein this part, that's the body of this particular if condition, and that's the body of the elsepart, see the the body of the top if condition has this kind of alignment, all the statementsthat are in the body of if condition, they start the same alignment, and all the conditionsall the statements that are in the body of this particular if condition, they have theirown alignment, and this indentation is necessity just to define, for example, which statementis in what kind of block for example, if I just press a tab, then another tab, then thisprint statement is in this L sport and this is the indentation that is defining the placementof this print, if for example, I press I align this with this, this particular structurehere, then this print statement is inside this if condition, this is the indentationthat is defining the placement of different statements. And if the print starts from here,then it is completely outside of all if conditions it is like this way. So let's run this boardand see what happens. Let's say we brand let's say we just cried a equals let's say 12. So,what do you think what should be printed, if A is 12 then first of all this conditionis true. So greater than 10 will be printed inside the top if that will be printed, thenthis check will be executed and this condition will become false because 12 is not largerthan 20 then you will go to the else part and less or equal to 20 this number this stringwill be printed and then inside the else part of nested if that will be printed and thenyou will be out of all if condition then outside of all F's that will be printed. So let'ssee whether whatever we have said is correct or not. So yes, greater than 10 inside thetop if less than or equal to 20 inside the else part of the nested f outside all F'sYeah. So that's what the nested F is. And by the way, you can have you can have forexample, more if conditions inside the nested ifs for example, you can have one more conditionhere, if A is larger than 30 for example, then do what then print it is larger than30 as well. And for the brand, maybe not necessarily that you always write print statements youcan do any interesting stuffinside inside the nested if of nested if find and then you can write the else part of thisparticular if condition here if you want to or or whatever I mean you can have as hilariousstructure as you want, but that completely depends upon the logic or you may have anif condition inside that l spot here for example, You can write an if condition here, if whateverthat is also, that is also perfectly fine. So, if a is larger than 20, then you printthis if A is larger than 30, then this, for example, and literally write the else parthere else, print less than or equal to 30. And we can print inside the nested insidethe else for all of nested if of nested if, okay, so, while you see that program, letme let me just scale it down so that you can see that completely see that program. I mean,yeah, it makes perfectly sense to me, for example, you take an input, if that is largerthan 10, then you're here. If it is larger than 20, then you are here. If it is not largerthan 20, then you're here. Okay. So let's say it is larger than 20. If it is largerthan 20, then you are here further, if it is larger than 30, then you are here. Otherwise,you are here. And once and by the way, if A is not larger than 10, then you are directlyhere. Wow. So let's run this code. Let me just scale it down so that you can see itmore. You can see more text. Let's see. So let's run this. No errors. Great. So let'ssay the number is let's say 25. So, what do you expect the result. So the number is 25is greater than 10 inside the top if it is greater than 20 inside the nested if it issmaller than or equal to 30. So inside the else part of nested if off nested if and thenoutside all the hips conditions. Great. Yeah. You enjoyed that. I enjoyed that. rate. Okay,so that's about the nested if one more thing that I have already told you, but just letme tell you the power of indentation. You are here for example, in this particular ifcondition, that's the if condition and that's the nested if, and that's the else part ofthis if if you move this L sport in in the indentation or the alignment with this ifthen this is else part of this if and this is not the else part of this If so, rememberthe power of indentation the this is the indentation that defines which part belongs to what whatkind of block or structure in Python. In other languages. Sometimes, for example, in c++,they they normally use to write these curly brackets to define a block and their indentationdoesn't really matter. But in Python, this is the indentation that actually defines eachand everything. So, for example, this is a crucial example if this else just moves backwardsand aligned with this f you get this else with this if these two if an L structures,this is still nested if without an L sport. And if this else move somewhere in betweenI mean this is not aligned with this if this not aligned with this if you get a syntaxerror because that is not a proper indentation. So focus on indentation that is really reallyimportant. Yeah, so although i have i've told you that the indentation has already toldyou but I just I just found to make a slide over this elsewhere because that's important.Sometimes you may get confused whether this else belongs to this F or that F Well, theindentation defines this LS belong to what? Okay, I end thiscontrol flow indentation here. So from next video we are jumping toward loops. But beforeloops, I just want to I just want to write a lengthy program in F LS f there are combinations.I just want to write a Jupiter program for you to to get comfortable with F nested fthe conditions that are ands and ORS and nots are stuff like so. So So in the next videowe will be practicing more on Jupiter for if conditions and then from the next to nextvideo. We'll be jumping toward loops, the very very powerful structure. Okay. Hope tosee you in the next video. Okay, so let's just practice this if condition a little bitmore in this particular video and we are going to achieve particular tasks. So let's designsome task here. By the way, this has comment, comment, comment is, it starts from a hashsymbol. And that's a statement that will never be executed. This just describes your code,for example. So like it, like, it is not there. But it is there as a text, but not as a codefile. Like hash sometimes represents. Comment or description with a single line. If yourcomment goes on multiple lines, it is good to write a multi line comment. So that's singleline comment, for example, single line comment, the multi line comments, they start with threequotes, and then end with three chords. So whatever you write inside, in these, in thisparticular block, that's a multi line comment. So let's describe our problem in this modalline comments, because that's the problem in form of text. And then we will be solvingthat problem using using the code. So that's just description of the problem, let's sayuser will enter of loading point number. Number, let's say 230 8.915. Let's see. Okay, yourtask is, is to so let's just adjust more readable, your task is tofind out the teacher integer, portion, integer portion, before the decimal before the point,let's say for the for the point, in this case, in this case, it is 238. And then,andand then check whether if that teacher portion is and even number or not. So just print yesor no. So print even if it is even number, otherwise, print odd. So that's the that'sthe problem statement. That's the problem that we are going to solve. And this is justto commit now we are outside the command that's a multi line comment. Yeah, so how to howto solve that problem? How to solve that problem? So let's start solving this problem. I'm goingto spend some time on this program just to get comfortable with the if conditions, let'ssay let's say that number is x is input, let me convert that inputinto ourreal number. That's it. Okay, we're just assuming that the user will enter a real number. It'sreal number. real number might be I mean to 38.0, that's a real number or 238 itself,that's also real number. That's okay. But we're not assuming that the user will enter,let's say some characters like ABC or stuff like sort of just just assuming that. Okay,now, assume that x contains real number, it may be an integer. By default, maybe userjust enters 10. And that's it. So it may be already an integer, then we have to checkwhether that 10 is whether that 10 is even or not, or the user may enter 11.7, or theuser may enter minus 34.7. Or the user may enter just zero or user may enter just zeropoint 30 535. There are a lot of possibilities that a user come up with this exe can containany kind of number, and we have to check according to. So how can we move let us just see, whetherthat number let us just extract the decimal portion, the portion before point. Let's justextract that how can we extract that there are two conditions First of all, let's seeif x is positive, then do what else do what? So let's try this structure first. The factsis positive, then what we have to do? And if x is negative, then what we have to do?So if x is positive, then what we do? We, we just so, what should we do? I'm just stuckhere. How can we extract the, the decimal portion, the portion without this particularthing? How can we extract that? That's, that's tricky. That's kind of tricky. Yeah. So any,any ideas? I guess this? The the structure I have, I'm using the let us just first thinkthat x is positive, just make our life easier. And then if x is positive, it's a positivenumber. How can we extract this portion out? Just the number that is below? That is beforethe decimal point, but what should we do? can we can we can we apply apply around function?Will that help? x? Will that help? helps. Yes. But no round function? So let's say ycontains the rounded value of x then, so what? Then how can extract How can we extract thethe the decimal portion, the portion the integer portion? Or maybe there is a function thatactually round down? Let me check whether there is a function float or not? No, floatis not a function, I guess. So let's say round x. Okay, now y contains the rounded vol valueforever the Xs we are now assuming that x is positive, okay, then what? Now, if, ify is larger than x, that means we moved up. Okay, we moved up, the round goes up. In thatcase, what we do is we just subtract. So the let me so we just subtract the integer portion.So the let me in teacher portion, let's say that's our variable name, then the integerportion is simply y minus one is that correct? Is that correct? If y is larger than x, theninteger portion is simply y minus one. For example, for example, just Just think aboutit, if When, when, for example, if the value was 29.6, and the rounded value will become30, so 30 minus one will be 29. There is what we are what we are interested in. So, yeah,so otherwise, if for example, else, else, if y is not larger than x, then y itself isan integer portion.Y itself is an integer portion. Is that correct? I mean, is that making sense to you? Thatif for example, if if x is larger than effects, larger than if the rounded value of x is largerthan larger than x itself, then we just subtract one and we get the proportion. Otherwise,the rounded value itself is the portion, just just let's just run this, run this code fornow and check whether what whatever we have done so far is correct or not. So after that,just print, let's say the integer portion. And teacher portion, let's just print that.Okay. So enter a number. Let's say the number is, let's say 25.3 45.367. Let's say, obviously,the integer portion here is 25. So let's say let's see our program returns 25. And nowOh, the result is 25. magically Oh my god. We found 25. Let's run it again. Let's runit again. Just to see. Okay, let's run this again. And order this time let's give it to45.8. Okay, the integer portion is 45. But when we will round We will get to 46 and 46minus one, we will dive into this particular if condition. Let's see. All the result is45. We are we are still moving very bill. Great. That's, that's great. So, okay, let'splay with it. Let's, let's give, let's give 0.2 the result should be zero, it is zero,right? Let's run it again and give it let's see, let's say four. That's it, the resultshould be four now, it is four. Great. So, we are working very well we have extractedthe integer portion as long as the number was positive. Okay, right. What if the numberwill be negative? Let's say that was true, if that was true, so, that whole logic works,if x was positive, so if x is positive, then whole this logic just works okay, then elseWhat should we do? If x is positive, then this logic works effects is not positive,then what will happen? Then how can we find out the integer portion because first we haveto find out the integer portion and then we have to find out whether they are integerportion is even or not finding out whether they are indeed a portion is even or not mightbe simpler. But first, we have to find out the integer portion. So for example, let'scheck the behavior of round function on negative numbers, let's say around minus 9.3. So theresult is minus nine. Okay? If we say okay, round, minus 9.6, the result will be minus10. So it looks like the same as working in the positive numbers. So round function isactually working roughly the same way it should work in the positive numbers. Okay. So whatshould we do here? Any idea? Maybe, maybe we first convert? Maybe you first convert,by the way? Yeah, maybe first convert the number, let's say y equals around x again,like before, but then what? Then what? So maybe this rounding helps the same way? Maybethe rounding helps the same way. We should extract this out from this here, because itis going to work in the else part as well, why to compute it, why white write this redundantcode? So why is round x let's say then if y is greater than x, what should we do? Ifit is negative y is greater than then what would what will be the portion? It will bethe integer portion will be portion will be what?y minus one or one? y plus one? Yes, you got the answer? That's y plus one. Great. Andelse I guess we have in future portion. Equals Whitesell, I guess, yes, I guess that's thethat's the good. That's cool. I guess that's checked, by the way, but I guess that's thecode. By the way, this else part is, this else part is same in both of these conditions.So maybe, maybe we can combine this code and write a more elegant code, but I guess thiswould work. Let us just print the integer portion, just to check whether we are workingwell, so far or not. So let's enter let's see 12.3 The result is 12th grade. So it didnot change our previous I guess our previous logic. So let's say there is minus 9.8. Nowthe integer portion should be minus nine, oh, it is returning 10 Why is that? Why isthat? Oh my God, this should be changed when it is round. It may go that way or when itrounds it actually becomes lesser than 10. Because when it rounds it goes up and it becomeslesser than a negative word. This condition should flip. Yeah. So we are making an errorhere. Let's fix that. Okay, let's run this again. And see Let's say minus nine pointminus nine d 3.2. Minus 93. Great. So then we have let's see, let's run it again. Minus8.9. minus eight. Yes, we are working perfectly fine. Once we have integer portion with us,we just right here. At the very end if integer portion is your portion, remainder with two,if that equals to zero, if that equals to zero, Brent, even, otherwise, else, brand.Art. That's it. That's the whole program. Let's see. And let's see, how is it running?Let's say 22.6. It's even, let's say minus 87.3. That's odd rate. So you see the power,if condition and, and how can we think in writing these programs and stuff like so?That was a lengthier video, I know. But I guess you get a very good look and feel of,of if conditions and thinking and building logic and all that stuff. So in the next video,we will start loops. So that's a beautiful structure, hope to see you in the next video,the best way to understand loops is to think about in a repetitive structure or repeatingstructure. Let me let me give you an example. And they will, we will dive into this codein a while. The example is let's say a user gives you a number, let's say integer number.And you want to print all the numbers till that number, let's say you start from one,and you keep on moving and printing all the numbers, as long as you reach that number.So for example, if user enters, let's say, five, your goal is to print one, then printtwo, then print three, then print four, and then stops, then stop just or, let's say ifuser print, if user enter, let's say, three, then you print one, you print two, and thenyou stop. This is easy. If user enters in n, we can just print, we could have writtenthis thing, print. Brent, I, let's initialize a variable by with one, Brent I, and thenI equals two i plus one, or in Python, we can write this quickly as i plus equals toone that means Ithat means in I store a plus one, this is the short form of writing this. And then afterthat, you just apply an if condition. For example, here, you can apply an if conditionand say, Okay, if I is smaller than n, you keep on printing, and after printing, youjust increment again this, then check the if condition and keep on moving. Well, thatis visible if n is five, or n is three, what if if n is let's say, if t 1000. In I mean,you're writing all that structure again, and again. And again. I mean, that's a lot ofcode. Well, the loops are just a solution for this kind of structure when you want toperform the same kind of task again, and again, the loop gives you the facility to do that.For example, let's just consider the VI loop. This is again a condition similar like a conditionin if condition like an if condition, you evaluate this Boolean expression, then that'san expression that results a boolean value. While this condition is true, you will stayin this block and after executing whole block once you check this condition again, if thiscondition is again true, you will dive into this block again. Then check the conditiondive into the block then check the condition dive into the block. As long as this conditionstays true, you stay in the block you you move inside the block. Once this conditionis false, then you exit this while loop then the loop terminates and you move on to thefurther processing just like an if condition just like if conditions if if the conditionbecomes false, you accept that if condition and you can move on, moved on. So in thisparticular case, for example, if n is five, let's say if n is five, user give an integernumber that is five I is equal to one, now one is smaller than five, the condition istrue, we move inside, you print I, the value of i is one. So that's what you print, youprint one, then you change a, you increment i with one, that means i equals i plus one,so I becomes two. Now the body of the loop finishes, that's whole body of the loop, thebody of the loop can have many, many statements, a whole block of code. Once I becomes two,you move on and you check, okay? Two is smaller than five, yes, it is true, you move insidethe block again, you print two, then you update I, the loop body finishes. Once the loop bodyfinishes, you go and check the condition again, whether that condition is still true or not,it is still true i is three i is three is smaller than five, yes, you move inside, youprint three, you update, I, you check the condition four is smaller than five, yes,you move inside you print four, and then you update I and then you move on now five issmaller than five false. Once the condition is false, you will not dive into the bodyof the loop, you will exit the loop and you will print done. And that's it done. So thisloop becomes very, very, very handy. In in, in, in applications that have representativestructures. And in most of the interesting programs, most of the interesting problems,these are the loops that play a very huge role. So let's go to Jupiter just to get ourhands, get our hands on this loop. For example, let's say x is again, that's the end or n,let's take n and is in input. Let me make this a little bigger, just do. Let's say thatinput and input is a number, let's say n i is your surgeon, let's say let's say one,while I is smaller than n, you may have written this parenthesis just to just to create thereadability just to make readability. And otherwise I mean, this is also Okay, that'sperfectly fine. If as long as I is smaller than n, keep doing the following you whatyou do is bring, for example, the square of I paint the square of I, that the square ofit, let's say, and then you say, Grant, for example. This is a question number. And thenyou just print I, that's the iteration number I have the loop.That's the equation number I this is just the spring, this is just a string. And that'sour variable, its value will be printed. This print function takes as many arguments asyou pass. So you can you can write a comma here and continue whatever you want to print.That's very flexible function. Okay, then what you do you say, Okay, I plus equals toone. By the way, this i plus equals to one is the same as i equals i plus one. You see,I have just commented here just to explain what this is doing. If I just write i equalsi plus one that is also that is also correct in Python, but that's kind of shorthand. Okay.And that's it. Now, again, when I de indent, I'm outside the loop, let's say sprint. Loopdone, for example. So that's the code for example. So let's run this code. Let's runthis code. For example. Let's say n is equal to five, then we have five. So this is one,this is the aggression number one, then two square is four, this is the aggression numbertwo, then three squared is nine, the aggression number three, then four square is 16. Thisis the iteration number four, and then the loop finishes. That's it. That's the firstsnapshot of the loop. We will continue from here onwards in the next video and I willshow you more and more flavors of this loop. So hold on and wait for the next video. Okay,in the previous video, we saw a while loop and we saw one. One program related to whileloop, just printing Just printing a bunch of numbers till a particular number. Well,when you are inside the body of the loop, that's a whole new you can write whateveryou want to write, for example, you can you can apply an if condition inside the bodyand check that an at each iteration a particular decision should be made or not. For example,in this particular case, I'm going to print I whenever I is an even number, so, I is somenumber if it is even then printed, else pass this pass statement for example, is just astatement of saying that do nothing It is just a shortcut of writing do nothing we couldhave we could have omitted the whole else part along with this pass and still the codeis equivalent but sometimes writing this past make the code readable just so so writingthis boss statement just means do nothing and just move on. If we omit else statement,and we omit this boss, that's perfectly okay. So, for example, let's try it on the score.Let's say n is let's say n is five i equals one one is less than five Yes, one is notan even number. So go to the else part else means boss, which means go on and then incrementi this print statement is outside the loop this is this is aligned with this while it'snot inside the body of the loop otherwise, it should have been intent indented insidenow i is incremented I becomes to now move back to is smaller than five years. Two remaindertwo is zero Yes. So brand two, so two will be printed. Because if executed else willnot execute and I will increment because I is not inside the if condition it is insidethe body of the loop. So I incremented I becomes three you go back, three is smaller than fiveyears. Three, remainder with two is zero false. So pass i i plus one, so I becomes four, fouris smaller than five years for remainder two is zero, yes, so Brent four. So else willnot execute now increment i, once you increment i you get, for example, I equals five, nowfive is smaller than five false, so you go out of the loop and you print down. And that'swhat this code is. So, you can have if condition inside the loop, you can have nested if insidethe loopyou can have loop inside the loop nested loops, we will see examples of nested loops as well.I mean, that's that's all allowed are sometimes rarely required. Okay. So, next there aretwo important statements that are there, one is break one is continue, I want to focusthese statements because they have a deep link with loops. A break statement where everwritten inside the body of the loop tells that exit the loop immediately whenever thisbrake is encountered, whenever this brake executes, it exits the loop immediately andbrings you outside the body of the loop. That's what it does break. So for example, if I becomesif I becomes divisible by 17 and the remainder becomes zero, you will print a break and thenwhen this break statement will execute you will exit the loop immediately regardlessof what is the value of AI What are other states wherever break exits the loop Okaygreat. Now, the continue continue statements continue statement wherever encountered continuebrings the next iteration loaded regardless of the remaining remaining statements in theloop for example, when this continue will be executed, no matter how many statementsare there onwards that are there, in the body of the loop, the loop will not finish itsiterations iteration by going through all the remaining statements, but it will startanother iteration immediately. So continue basically skips the remaining body of theloop and starts another iteration. Here I have written this. true true means while truemeans always run. You might be thinking always run it's an infinite loop will it will itwhen we will exit the loop because this true statement will always stay true. We're notchanging this true anymore. There is no condition here. That's true. While true means alwaysgo inside the loop but once where whenever this Break his encounter, you're outside theloop right away. And this break exists, the loop does continue skips the remaining remainingportion of the loop body and starts the new iteration starts another iteration. So thiscontinue means start another iteration immediately skip the rest of the stress of the statements.So the rest of the statements inside the loop body. Okay, so let's just practice this breakand continue with just just in Jupyter Notebook to get a better look and feel of the loop.So let's say we have, let's say again, let's say n equals let's say 10. Or we might havetaken that as an input, let's say n is equal to 10. While true, which means keep moving,it might have taken some value here, I equals, let's say one, while true, if I remainderwith, let's say, nine, if that is equal to zero, then just break the loop tells ELS.Else, what you do is really you increment a else what you do is, if I is if I is notdivisible by nine, then what you do is i equals i plus one, that's true. By the way, previously,we we have written this way. So either way is fine, whether you write a short form orthis form, so else this okay. And that's, that's it, the loop finishes. That's the loop.After the loop, you just write Okay, print, the loop is done. So let's see, what's theoutput? The output is done straightaway. And the reason is, why it is Oh, one is not oneis divisible by nine, only then you could have break. While true. Why? Why the loop?Oh, it does not print anything, we could have printed some statements so that we know thatwe went inside the loop or not. Okay, so inside, if so, for example, Brent.Inside else. So let's run this again. Oh, okay, great, inside sales, inside sales insidesales inside rails, the first time it go inside, if that time it breaks, and it goes out andpants down. That's what this break statement does. So let's see an application of continuousstatement. That's for example, just copy and paste that code into another cell and seehow this continue works. So, let's say we have a loop like so. So, what we say is likethis, if I is nine is not equal to zero. If this is the case, if I is not divisible bynine, what you do is you get take i plus equals to one and then continue continue to the nextstatement. And whatever else you write here for example, brand something brand somethingelse something else whatever that is going to be printed and what wants to continue willwill be encountered whenever this eye is whenever this I divisible by nine is not true. If Iis then you continue once this AI is divisible by nine for example, then you will not followthen you will not dive into this if condition only then these two statements will be printed.Because this this continue will not allow anything further that should happen. And oncethese are printed, let's say we break our loop right there, let's say so if for examplefor the very first time one is not divisible by nine, so I equals two. So continue thesethree statements will not be executed the next loop the next loop. The next one If conditionbecomes false, this continue will not operate, and then we print this statement, then onlythen we will print this statement, and only then we will break and we'll exit the loopand print the data. So let's print here. Brent inside, if so, let's run this code, let'srun this code and see what happens. That's the goodI should I should just yeah, NASA better font, let's run this code. So, when the code isrun inside if inside if you see when you when you are inside if when you continue when whenthis is the body of if condition when if condition completes, it should print these two things,but continue is telling the cursor to go back to the next iteration and move on. And oncethis if condition becomes false, only then you get this distinct printed this thing printedif this break was not there, you do you then again was going to the while loop and youwill be running an infinite loop and then you have done so that's what this continueand break does. So, in the in the in the very next video we will see another kind of loophere we saw the while loop in the next video we will see a for loop very powerful and veryfamous kind of loop for it does almost the same stuff as while loop while the while loopruns based on a condition they fire the for loop it runs based on contracts a counterloop that many times it should run and so on. So we will see the details of for loopand the application The for loop in the next video hope to see you in the next one. Okayin this video we are going to discuss for loop and other kind of loop in the previousvideo we saw while loop although most of the stuff almost all of the stuff can be achievablethrough while loop and sometimes it becomes handy to apply for loop. In this particularexample, I'm going to populate a list. So before actually moving towards for loop let'ssee very shortly what a list is, although we are going to be or we are going to explorethis lesson in much more detail when we will discuss the data structures module but justfor the sake of example, a list is a collection of different kinds of elements for example234, that's a list of three elements. So two three and four the list can contains differenttype values, for example two 3.4 and stuff like so, we can access different elementsfor example, L of zero means the very first element the indexing This is called the index,the index starts from zero then index one is so if we print for example, Brent Elifzero the result will the result that will be printed will be two similarly we can appendmore values inside a list append let's say 53 and list after this append operation, thelist will be having these values 234 53 we can remove delete, update and do a lot ofstuff we will see lists in detail, but just for this example, just think that list iscollection of a lot of elements and we can add insert more elements we can delete elements,we can change elements and so on. Or we can just initialize the list with just an emptylist and start inserting elements one by one and expanding that list. Okay. Now, this isan empty list for example, and four is just a variable for i in this range isn't it greaterrange then means sequentially give a number one by one starting from zero start from zeroa gift num give numbers one by one for example, first time give zero I will contain zero secondtime give 1/3 time give two and so on after every equation the range will give anothernumber as long as the numbers they are smaller than 10. So, the last number that this rangewill return will be nine. So whatever this is written inside is not included and it startsfrom zero. So as long as I is in this range is lower than 10 as long as that you thatthe body of the loop just like the body of the while loop. So first time I will be zeroand zero is smaller than 10 Okay, you print i i plus one and abandon the square of thatin a list. Then next time this range will automatically return the next number intoI. Now next time I will contain one next time I will contain two Next time I will continueIn three, four or 5678 and nine, once the value of AI becomes nine, that's the lastiteration of this body of the loop. And after that the loop finishes. So let's just writeon this very very first time I will be zero when the loop enters its body very first timeI will be zero and one will be printed because we are printing i plus one, at that time thelist and the empty list will be having one number which is zero square. So list willbe having just one number zero, because zero square, so, next time I will be one and wewill print two and the list will contain one square which is one, next time I will be threewe will I will be two we will print three and we will be having a square of two whichis four, and so on till so until 10 here, when I will be nine we will print print 10.And in this list, we will be having nine square which is 81, I guess, and after that the loopfinishes and we will be out of this loop.Okay, let's see this. Let's see example of this in, in Jupiter just to get more comfortablewith with list as well as the for loop. So let's see, let's say we have an empty list,let's say an empty list. Just to consider a list like this L is just a variable, youcan write another variable a name, that's a variable name L. Okay. So for i in range,in is a keyword range is a function in is a keyword, i in range. For example, let'ssay then, what you do is you brand, your brand i plus one or whatever you want to do, that'sthe body of the loop, and Eldad a band, that's a function of the lists, we will see thatin detail in the data structure sessions. Okay, and that's it, the loop finishes. Whenyou finish the loop, just print the whole list. So let's print the list. And you cansee the result 1-234-567-8910. And that's the these are the values in the list. As asI mentioned earlier, all the little the values. By the way, this range function actually,if What if we want it to jump more than just one, for example, b we want it to start fromzero, it reaches 10. And let's say we want two jumps to be taken as two rather than oneand one. So the very first time so that's the start location. That's the end locationwhich is not included start location is included and location is not included. And that's astep size. So very first time I will be one you move inside, then a jump of two will betaken the next time I will be so very first time the AI will be zero, then you move insidethen the jump of two, then you move inside then a jump of two then you move inside aslong as you stay smaller than 10 you will move inside the loop body of the loop. Solet's see what now printed let's print just I rather than i plus one there was an errorwas the error 00 the range function does not have colons, it has actually commas. Sorry,my mistake. I was just a MATLAB user one. So MATLAB actually has this colon things.So I was just confusing MATLAB notation with this. Okay, great. So so first time i waszero, next time a jump of two, I becomes two. Next aim to jump off to AI becomes four, thenI become six, then I becomes eight. And next time I becomes 10. But 10 is not included.So you're out of the loop. And that's the squares that you got. It is not necessarythat you always start from zero, you can start from one and you can j take a jump for examplethe jump of three. And it's not necessary that you just reach them you can reach forexample 20 it's up to you it's completely your choice. And in that case, you have thiskind of vibrations. So this range function really is helpful for creating over over aloop body or a structure. Okay, great. So that was introduction of for loop and we haveiterated here on on our list we just have actually populated a list using for loops.Okay In the next video we will see more details of this for loop and more fun stuff. Okay,hope to see you in the next video. Last time, we saw four In the last video, and magicallythis else has something to do with for loop in Python. Well this else clause makes sensefor F. But in for loop it hardly makes sense. But let me let me let me try to make senseof else clause for follow there is an else part of for loop as well in Python, not inother languages. I don't know any other language that has this L spark maybe there is somebut I don't know.So this else part in Python, particularly in follow, this else part or else that wasblocked will only execute if four completes its iterations. For example, this is a seta set like a list is is a collection list is defined by square brackets set is definedby curly brackets, the set is just similar like the set in mathematics, we will see theset lists tuples dictionaries and many of these data structures in detail in data structuresportion, but just I have introduced this, just consider this set has three elementsApple 4.9, and Jerry. Apple is one object or one data. 4.9 is one data, which is a floatingpoint data and Jerry is one data which is a string data. Okay, so this S has three elements,three different elements. So now for x in this set, as long as x is in the set, thevery first time the x will be Apple, so it will print Apple, next time x will containa 4.9 as long as so I create over this set, as long as x is inside the set big elementsone by one, and just print them all. Okay, we expect that when x is Apple, when the veryfirst time x will be Apple, it will print Apple next time x will be 4.9 it will print4.9. Next time x will be cherry it will print cherry, and the loop ends because there isno item in sets to iterate over. Because the loop finishes it's complete iteration thereare expected three iterations and the loop finishes those now the else part will executeand you will say okay, loop completed. So iterations. Well, you will be wondering inwhat case the else will not else will not execute. If you apply any brake statementinside the loop body, which means you forcefully you forcefully remove some of the iterationsthat were going to be executed but the loop did not complete it did not complete citations,then the L spot will not run. So let's see an example in in in Jupiter to get a goodgrip on this else. Okay, let's define a set S. S is a variable name. You can have anyvariable name that say it Apple, or let's say 4.9 I guess and then we was having, let'ssay, Sherry, if if these Spelling's are correct, I guess jelly. Okay, then for x in PES, aslong as x is ns Brand X. Fine ELLs rant, when you finish the law terminates with success,or all iterations it completed all its iterations. And this is a statement that is completelyoutside the loop. side the loop, so let's run this. So you can see Apple 4.9 cherryloop terminates with success outside the loop. Okay. Now you might be thinking in what casethis else will not execute. Okay, if, for example, as long as x is an N, if I say okay,let's say I take a counter here, I equals one, that's a counter, let's say, and everytime I just increment i, i plus equals one, and then I check if i is equal to three. Ify is equal to three, then just break. Let's sayelse just for readability else was now this else is else of this four. And this else iselse of this if and this POS statement is just a statement for doing nothing. Now whatyou do when is equal to one you Brent this i plus equals I becomes two two is equal tothree false, so you pass you move on. Next time, x will print 4.9, I will become threeand three is equal to three, that's correct, the break will execute, which means the loopshould have one more iteration, but the break just disrupt that one more iteration thatshould be there, because the loop could not complete its iteration due to this certaincondition, this else part of the loop will not execute, and you will go directly outsidethis loop. So let's run this code and see the result. So you can see this apple fourby nine outside the loop. I would recommend although this else is there for for loop,but I would recommend to avoid using ELS in the beginning, I mean, you may be confusingthis else By the way, there is a there is a mistake here, this l should be ended witha colon here, okay. So I would recommend to not use LS clause for a for loop in the beginninguntil you you really need it. Because you may confuse this else with the with the Lof F condition. And you may think something else and the program behave in a differentway. So either way, if you want to use LS LS for a for loop is there in Python. Okay,just one more example of for loop. And here we use dictionary, I'm introducing some datastructures here just for fun, we will see these data structures in detail later on.So dictionary, that's a key value period like set, but one item is consists of two numbers,that's called a key. And that is called a value. That's a key. And that's a value likea dictionary, we have key and values. So now as long as x is an X, X represents two keyand d is our dictionary and D off x represents to whatever value that x points to, for example,Apple is a key that points to 44. Cherry is a key that points to gain. For example, ifwe're ID, apples, apple, the result will be 44. Similarly, d of Jerry, the result willbe game. Okay, so let's I create over this dictionary using this for loop. All am I showingyou that this for loop is very, very handy of creating over different data structuresand a lot of data and stuff. Whereas file while loop is more handy and checking theconditions and stuff. Although you can do all the stuff using while loop you can alwaysstuff using for loop but one is better over the other insert in certain situations. Sothat's let's let's just run this for a dictionary. Let's say I have a dictionary D. It's definedlike a set, let's say my key is a and my value is 10. Let's say my key is B and value isminus 19. And let's say my key is C and my value is let's say ABC, let's say that's mydictionary. So for x in the Brent the key as well as the value of that key. So now youcan see the key is a the value of Stan The key is B the value is minus 90 in the keyof C the values ABC. So this far loop is really really handy and iterated over a lot of datastructures and stuff although it has other applications as well but this is handy. Okaygreat. So that's about loops for loops. And while loops These are two kinds of loops inimportant loop these are two important kind of loops and they are inPython, in the next video I will directly go to Jupiter and Jupiter notebook and wewill be practicing for this for loops or while loops. We will be practicing the loops wewill be doing actually examples of nested loops we will be actually solving a problemlike we did in the if conditions we solve the problem Previously, we wrote a code forit. Here we will also write a code and we will be get a good grip on the loops. So hopeto see you in the next video we will solve a problem in Jupyter Notebook directly. Okay,hope to see you in the next video. Okay, welcome back. In this particular video we are goingto practice for loops are basically loops. So let's have a problem statement. First,what problem we are going to solve let's have comments. And the problem we are going tosolve is let's define given a list of of numbers, numbers. For example, I II, let's say 124minus five, a 7932, like this, make another list making another list that contains allthe items in sorted order from minimum to maximum, ie, your result will be another list.Like, in this particular case, we will be having minus five, which is smallest, thenwe will be having one, then we'll be having two, then we'll be having two, then we willbe having two, then we'll be having three. So all items, but in minimum to maximum sortedorder, then we having I guess, four, then we'll be having seven, and then we'll be havingnine. So that's your, that should be your output in another list. So assuming this listis available to you, or any list is available to you assume this list is available to you.So how to solve that problem? Let's start. Okay, let's assume that the list is available.That's it, this is the list we are going to sort. Let's say this is available. Okay. Okay.So, what should be the logic? What should be the logic? How can we solve that problem?This is, this is an easy looking problem, but it is not so easy. Let us first right.Let us just simplify this problem to just finding out a minimum from the list. Let'ssay we are given a list and we just want to find out minimum number one a minimum fromthe list. So how can we move that. So let's say M is some number. So M is the very firstvalue of the list, let's MSP our variable, let's say that's the first value. And whatwe do is for i in the for i n L, as long as I is an L, if I AI is smaller than m, thenif AI is smaller than m, then m should contain AI. Otherwise do nothing. That's it. So atthe end, rentas m, then this m at the end. So, Brent, the minimum number, that's great.So so that's the nasty, basically. So yeah, that's the that's how we will find out justthe minimum value. So let's run this code. And the minimum is minus five available tous. What if we want to store the minimum value as well as the position of that value? Forexample, we not only want to just find out what is the minimum number, we also want tofind out at what index for example, here 012, and three, at the third index, we found theminimum, what if we're interested in the index as well. So let's say for the very beginning,the index is zero. And then what we do iswe moved on and we say, okay, we maintain a counter, let's say a counter is C equalsc equals zero, for example, right now, and C, just plus equals to one, that's a counterand then this ID x is just that C, whatever that c is. So whatever that index is, whenwe find this C, that index is also there. So let's print the index as well as the minimumvalue. So okay, so at the position three, at index three, we found the minimum value,okay, now we have written kind of a code block that helps us finding out the minimum value.How can we actually how can we actually do how can we act? So the basic logic is youfind the minimum value and swap the that value with the very first value, okay, great. Andthen move the loop next time find out the minimum value from the remaining list andswap that minimum value with the second value. Next time you find the minimum value, as longas the position and swap that with the third value and so on. So do that stuff and justrearrange the same list using this but, but how can the so that's the logic find out theminimum value. So happened with the first value and then start from two till end startfrom start from the remaining values, find the minimum so appid with the first valueof the remaining list, then reduce the list step by step and you will be having a sortedorder, but how to start with how to find out like this how to how to do that. So, any ideaand we are going to so for example, in this particular case, if I want to swap the list,what I will do is I will say okay, swap with zero at the at the at the zero, so, I willcontain a temporary variable, temporary variable will contain the value of zero, this zero,so what I will do is at least zero, right the minimum value and the minimum value. Soat zero you write the minimum value, but at this particular index, from there, we foundthe minimum value, just place the just place the the value at the very beginning. So inafter that, after that operation, the minimum will be at the first position, or the zeroethindex, and that value will be some minimum value will be swapped with the very firstvalue. So let's run this code and see what a list looks like after that good. So yousee, for example, the minimum value is swept by the first value, whatever the first valuewas, but we want to do that progressively for for the rest of the list, we want to findout the minimum and follow up with the first one for the rest of the list and keep on moving.How can we do that? So yeah, that's, that's, so let me define four. So let me first indepth a bit, let's say control right bases that will indent all my code. So for j inrange, length of the list, whatever the length of list, let's say for G is that so what Ido is M is the gf value the index right now is J and the C is also C is also the ConvertC is also starts from J, okay, great. Now, we want it to start with two now we want thisI to start from J and move onwards here. So let's say i in range, start from G and gotill length of L, one by one, take the step of one. Okay, great. So what next? Now thevalue will be L of I, rather than simply L of I rather than simply I in that case, youdo this.Okay, and the index is just C. Okay, great. Keep on keep on introducing this index again,after this loop, what you do is you pick the gf value, you slap the gf value with the minimum.And you do that. And that's it, you keep on moving and offer after the outer loop finishes.If you branch your list, you will be having the list sorted or at least we hope so. Somaybe there is a bug in the code or maybe there is a problem in the code. But we hopethis will work. What we are doing progressively By the way, this is a nested loop. This isa loop inside the loop and that's and then we have an if condition inside the nestedloop. Loop inside the loop. Great. Let's see how it how it works. If there is no Oh thereis an error length of range. Oh, we haven't write a colon there. Don't forget this colon.That's a problem. Oh, we have a sorted order. Oh my god. We have a result with us. You seethe applications of this. Oh, one three is missing. We were is three, we have two threesOh, the output we have written here is wrong, there is no two threes there is only one three.So you have sorted a list. If you remember, we have written a similar kind of code inthe problem. So problem solving session very earlier, where we solve this problem usingselection sort, but they are we just wrote a pseudocode. And here we have a code muchsimpler than actually the Python code. If the problem was just sorting there are builtin functions to do that, but I'm just telling you how these loops and if conditions andall that stuff can be used to communicate with each other to match with each other toto actually perform a problem solving task when given a problem. Although we will seelater on in Python, most of the problem solving tasks, I mean many more of them, there area built in function for those that are available functions for those you need not write allthat stuff, but to mastering to to master any programming language, you have to go throughthese constructs. So that for a new problem, or for a very large, complicated kind of problem,eventually you you may need these kind of structures with you. So mastering these structuresis really essential for problem solving and programming in general. So okay, that's aboutthe loops and if conditions and control. So, all of that, in the next video, I will I willstart talking about functions. So you have seen this L e m data function, you have seenthis range, that's that's function idolater. Although you have seen around function, youhave seen def mode, you have seen print function, what if we want to write our own function?How can we do that? From the next video, I'm going to show you how can we write our ownfunction? Wow, isn't that great? That's great. So hope to see you in the next video. In thisvideo, I will talk about functions. A very powerful construct in almost every programminglanguage. Python also supports functions. What a function is, let me let me describethe let me describe the need of the function by a scenario. Let me give you a scenario.The scenario is let's say you are writing a very lengthy program, the program requiresto print particular messages whenever needed, for example, you need to print this particularmessage the task, the task was successful, let's say you need to print this. And thenyou have to print moving to the next task maybe to to inform somebody maybe in to informyour client. And then you have to ask, okay, send me the next task. Because I am done withthe previous task, let's say you want to print this, or maybe you want to print more or dosome more stuff. And let's say you want to do this again. And again, whenever needed.Somewhere, whenever you complete a particular task or something, you want to print all thesemessages, and then somewhere else, whenever a particular event occurs, you need to printall these messages again. Now one way to do that is to write just these print statementswhenever needed in the program. One way is if you want to perform a task and the taskhas a lot of coding, maybe maybe maybe a very small amount of coding or maybe a very largeamount or magnitude of the coding. In this case, we have just three statements, but maybewe have a task that we want to perform again and again and it is really a very lengthytask in terms of the coding.So, one way to do that is to just write all the coding in coding somewhere and definea function and that function means the function contain all the tasks that you need to perform,whenever you need to perform that particular task. Just in your coding, just call thisone statement, just this one statement, and the whole task that is written under thisunder this content maintaining this as a heading that will execute automatically I mean, however,I mean, that task that is under this heading may be very lengthy may be short, may maybe complicated, may be simple one or anything, but the need is we want to perform this taskwhenever we need. And we do not write to code this again and again we do not write to codewe do not write to we do not want to write the same lines of codes again and again andagain. And again in our program. Just write this particular lines of code once definea function, just like a task. Whenever you need to perform that task, just call the headingor the name of the function. And the whole task under that function will execute functionsin almost all programming languages. They do that even in mathematics. They do thatIn Python, the syntax of defining function is you if you want to define a function, youhave to first start with D E F meaning definition or defining, then you need to write the nameof that function the name of that function name a function and name a variable has resemblance,I mean, the name of functions should be descriptive, it should, it should portray what the functionactually is doing. So, it is good to write it is good to suggest the names of the functionsthat are very descriptive to make the code readable and manageable. So, here I have writtenthe function name is sprint success, you can write any name, then you start parenthesisthen you end parenthesis and then you write a colon like you have written the colon forif conditions are for loops or any other constructs. And then you do indent like the body of thefor loop like the body of the if condition, this is the body of the function, body ofthe function is all should all be aligned, then you write all the tasks, all the codingthat you need to be performed whenever this function is invoked or called, this body cancontain if conditions for loops inside, I mean, this can have a whole lot of codinginside it. And whenever you will call this function, whenever you will type this command,wherever in your coding, the whole task under this will be executed automatically againand again whenever you like. So, let's take a look of defining our first function in Jupyter.notebook. Let's just I guess, yes. So, yeah, so, that's our notebook, we were populatingthat notebook. So by the way, if you if you want to know where this notebook is located,if I want to, for example, invoke that notebook again, when you will run your Jupyter Notebookfrom the Anaconda prompt, you will be having all the files that you are working on. Andone file is for example, this you just click on that, and your file one or more files,whatever you want to open up that will open up in the Jupyter. notebook. Yes, so it isopening up, it's a lengthy file, so it may take may take a second. Okay. Let me justtake a better zoom level, just to Okay, so we were working on that notebook, let's defineour first function, let's say D, F, define. Let's say the function name is Brent. Success.That's a, that's a syntax, then press enter, Brent, I am done. Then Brent, send me anothertask. Let's see. And that's it. Let's say that's the, that's the body of the function,the body of the function here contains only two statements, okay, then you run this, yourun this command, just like Shift Enter, you run this. So thatit is it is reported in the symbol table, there is a symbol table inside the Pythonmaintaining Python is maintaining all the variables all the function information inside.So once you run this cell, then the then this print success function will be registeredto Python. So that whenever you want to call this function, again, it will be available.Now if you want to perform this task, let's say you want to perform, let's say you wantto perform this task whenever you want. So you just call this function, this is calledcalling of the function. whatever I'm doing now, when success and that's it, you pressShift Enter, and the all the statements that are under this will be executed. And you dosome other stuff, let's say three plus eight that is that is 11 do some other stuff. Andafterwards, if you want to do the same process again, then you call this function again andall the coding inside the function will be executed it is very, very handy. If a particulartask if you want to perform that task repeatedly, it is good to just write one code for thattask in a function and then just invoke function whenever you need. It supplies a lot of managingpower, a lot of debugging power if you have an error for example, inside the function,you just go to the code we just go to the code of the function itself and fix the errorand come back You need not to you need not to go all over the code if you have not definedthe function and you have called these lines of codes everywhere inside your main code,then it will become very difficult to handle And function actually provides a lot of alot of simplicity of managing and readability and, and a modular approach in that sense.So that was our first. That was our first function. We will be talking about more, we'llbe talking more about this functions in the next video. So hope to see you in the nextvideo. The function name should be descriptive, that's okay. But it is further important sometimesto have a documentation of the function sometimes called the doc string, the doc string allowsyou to write the description of the function. But that description will never be executed,it will be available whenever you need help. Or you need to know what this function does.Sometimes it happens your function can contain a lot of code, for example, you have a particularfunction, let's say, fun, let's say it contains def, fun, and it does a lot of a lot of complicatedstuff inside. And it is sometimes required to know what this function actually is doing.So this document string is one way of describing what the function is doing. You might be thinkingthat if you're writing this document string inside the where the where the coding of thefunction should be written, we should open up that the coding file and see what the functionis doing, or should we actually open up this function implementation where the functioncode is written. And then we have to read what the function is doing. Actually, Pythongives you another power. If you have written the document string inside, that should bea top statement before the first coding statement. Whatever description you want, as a documentstring, it will be available without actually opening up with without actually seeing what'sinside the funk without actually opening up the file that contains the implementationof this function. Let's see, let's see. Two in Jupyter, notebook imore, completely whateverI'm saying right now. So for example, let's define a function. def print success. to let'ssay the function name, this function is print success to the function name is print successtwo, although it's not a very descriptive name, but the specimens are also not correct,but that's fine. Print success to here I just define a document Strank. The document stringmay contain maybe just in one line, or it may be a multi line, it is like a multi linecomment, or maybe a single line comment if you want. But it starts with the three quotesand ends with three quotes. Let's say I write here this function is doing nothing exceptrenting. message, printing a message, let's say full stop. And then I further define let'ssay I define more in saying that that message isHello, let's say, let's say are any description you want for this function. Now, this is adocument string, and it will be available whenever you need. Now here are the codingstarts, let's say you, right according here, and again, hello, let's and you run this code.Now, let's say we are not seeing this function we are we are not available with this function.We are not available with the code of this function. And we want to know what this functionactually does. First of all, we can just write if we write pri, and just press tab, the tabwill allow us to access all the functions that are available with prefix pri. So let'ssay we go to print success, brand success. Brain success here brain success, as shouldbe capital, Brent success, let's say so print success to let's say and we write a questionmark in front of it, and then just press Shift Enter, it will pull the document string itwill pull the document strength whatever we have written and we will get to know whatactually this this is doing. So this document string actually does a lot of job furtherif we I mean this is this is kind of whenever we need to know what a function is doing.The document string is one way to just go and check what is what is happening. Rightnow this function implementation is in front of us But in several times, the function implementationwill not be in front of us several times, we will be accessing functions that otherpeople have written in their libraries. And we need to know what those functions are doing.So document string is one very, very healthy way of describing our function. And I willrecommend to make your habit writing document strings, every time you write a function.I was telling you that if you write a double question mark, then it will not only pullthe document string for you, it will pull the whole implementation as well. So now ifyou see you, they said the document string, and that's the implementation. So whole implementationwill be available, if you want. And this is true for the functions that are that are,that are the functions that are third party functions, or some other person have writtenthat function and so on. For example, you know, a function length, we call that functionseveral times. So let's let let's, let's see, also the document string is returned, thenumber of items in our container, that length function is not written by us, somebody haswritten that function that's a built in function, by the way. And we can, this document stringtells us, okay, what this function is doing, we don't have the implementation of that function,obviously, somebody have written that function. And, and if we write the double, then we shouldget an implementation as long as the implementation is not in c++, I haven't told you that a lotof a lot of implementation of Python itself has been done in C and some other languageshave C mostly. So several built in functions, because of because of their speed, they areimplemented in C, and if you, if you want to get their implementation, they get theircode, the code will not be available for most of the functions. So that's so whenever youwrite a double question mark, and the answer is the same as a single question mark, that'san indication that this particular function is not written in plain Python, it is writtenin some other language and is used in Python. That's, in other words, the diversity or flexibilityof Python, you can engage multiple languages inside, Okay, one more thing, I can writeHelp, help command and I can get this Brent successsuccess too. And the help of print success to by just typing this help command. So, thishelp will tell us, you see the Help is telling us the document strike I mean, this help onthis function, if and this and this is the function we have written, this is the functionwe have written, this function is doing nothing except whatever description we are givingthere. If, at some time, if we are supplying this function to somebody, or making a packageof a lot of functions, that we are writing these documents, strings will help to getto know how to use these functions. By just knowing the function name, we can, this documentstring actually tells us how the what the function is doing. While great Oh, by theway, we haven't called this function yet, we are just playing with the document string,let's call the function print. Now we know what the function is doing. let's print, let'scall this function. And whatever written inside the function will be called See, this is onlycalled this is just acting as a comment and it is basically a comment. Yeah. Okay, great.Stay with us. There is much more about function that we are going to tell you. Hope to seeyou in the next video. Okay, in the last video, we saw document strength. Or you might bethinking, what is power of this function, if it is doing some static task? Well, inthis video, I'm going to tell you that the function can the coding or the behavior ofthe function can be dynamic, based on based on the arguments based on some propertiesthat you will be defining at the call time. For example, the function has in almost allprogramming languages, the functions, the most interesting functions are the functionthat receives an argument. And an argument is just considered an argument just as a variableand performs its task according to that to that arguments. argument. Just take a singlesimple example. Let's say rather than having a function print success, we have a functionprint message, and it it prints whatever message it receives. And at the call time, for example,we call this function like so print message. And let's say we call this as, let's say,success. Let's say now success will be printed. Next time we call the function and we giveanother argument maybe in a string, let's say so 74 errors, let's see, that will bethat will be printed or anything, I mean, anything that you supply will be printed.Wow, isn't that great? I mean one function. And you might be thinking the plain printfunction does that what's the power of this? Well, I'm just telling you the function ofthe function does not only contain one line, I mean, it can be a whole task depending uponthis input argument. And the whole task will perform dynamically based on based on whatinput argument you are supplying there. You are noticing one one thing that I that I justforgot, what is that thing I define this function? I guess everything is fine. I just have justmissed something Oh, document string, I should have written document string. Although documentstring is not essential. If you do not write document string, it's perfectly okay. Thefunction will run but it's a good practice. It's an it's a good habit to always writea document string. Okay, let's see the power of input arguments by again, going to ourgood friend Jupyter Notebook. Okay, so let's see. Let's say we define a function defineBrent grant message, let's say, edit receives an argument message. And this argument isjust a variable, it's just a variable. And let's say we say okay, print message or further,let's say you say, if is in stance message spraying, if this is spraying, then simplythen simply branded. If this is not a string, then just say okay, brand, your input argumentis not a string. And then you say, Okay, here is what you have, slide. And then you say,okay, whatever you have slide, just see, okay, message. And that's it, that's it, that'sthe function, we might have written a document screen for it. The function rents the messagesupplied by the user, or brains, that message is not in the form of strength. While Don'tworry, we have to see the strings in detail, we will see the sprint function in detailas well, because the sprint has a lot of lot to do with strings. So so just for now, Imean, that's our function print message, let's say if the message is of string type, thisstring does not good, this is this should be simply str this should not be that is instantsteak like this, your input argument is not a string here is what you have supplied. Hereis what you have. So here, we can, we can say here is here is here is the typeof whatyou have supplied. And then we can just print the Type, Type MSC. So the goal here is tojust create a function that prints a message if that message is in plain string form. Ifit is not a string, then it prints that okay, you're the whatever you have signed is nota string, it is not a proper message in string form. Let's say this print message functionreceives a string, let's say that's our logic or something. So let's run this. First ofall, let's see what it does help rent message. So the function prints the message suppliedby the user. We can access the same help by question mark if you want and it gives usthe document string If however, we want The implementation as well, then we write readablecode and implementation is also available. While grade Python is really great. Okay,let's call this function. Let's call this function, Brent, message. And whatever youwant to print, let's say, this is the message. This is the message, let's say you want toprint this. And this is the message that's printed. Okay, now, let's say you call thisfunction again some time, and you supply 23. And it will say your input argument is nota string, here is the type of what you have supplied, it's an integer type rate, you canyou can have, you can have, you can call this function in the following way, let's say youdefine a variable y, and the variable y containsHello.Hello there.That's it, that's your, and then you called, then you call this function on y. And it willprint hello there, because y is also a string. Great. So that's how you can you can you can,you can pass different arguments and instruct the function, how should it behave withoutactually writing the whole logic of the task again, and again, if written all the logic,once, actually, this is actually the logic starts from here. That's what the task isto, that's what the task you want to perform. And you need not write this again. And again,whenever you need this kind of stuff, you just call that function supplied arguments,and it will behave accordingly you want. Great. So you might be thinking, the function onlyreceives one argument, maybe we want to supply more than one arguments, maybe, maybe twoarguments, maybe three, maybe four, maybe five, and maybe we want to supply severalarguments. And we want to do some task based on the values of those arguments, or thosevariables. So in the next video, I'm going to show you multiple arguments. Okay. Hopeto see you in the next video. So in the previous video, we saw we can define a function, andwe can supply input argument to it. And in this video, we are going to see that we canactually send more than one arguments to the function these arguments are just variables,these are just variables, whatever value we will supply to these dynamically, becausePython is dynamic dynamically typed dynamically they are type will be defined. And for example,here we have supplied just two variables, and we just printed them, but based basedon supplying more than one input arguments, and based on what logic we are going to perform,we can do anything, we can do anything. So guess by thumbs, allows us to supply multipleinput arguments to a function and and we can, we can just perform all the tasks accordingto whatever logic we are going to do with that. So let's go to our friend Jupyter Notebookand see an example of a function with multiple input arguments. Let's say the function theB define a function, let's say, my power, let's say, my power, my power, let's say,you remember there is a POW function in in Python that's a built in function. I'm goingto write my own function, let's say it contains a and b. Well, document string. My, this functioncomputespowerjust like built built in power function. Great. That's the document screen. Okay. Now whatwe want to do is we want to print Okay, let's let's, let's create another variable, see,that is a power B. Okay, then we print this C, and we are done. That's it. That's ourgoal. So we register that function by just just calling the job by just pressing theshift enter in Jupyter Notebook. And now we check what this function does. Well, thisfunction can be horsepower, just like built in power function. Okay, just to Just to remindyou again and again, the importance of document strength, I'm writing this again and again,let's run this function, my power, let's say three ways to recover for illness. So theresult is 81. Oh my god. So whenever, by the way, if you don't have POW function with you,although you have, you can you can create your function and whenever you want to use,you can use your function, not a big deal. By the way, what if you? What if you Whatif, let's say, you can, you can define a function with more than two arguments to find, let'ssay, display types. That's it, that's your function display types. And all you know,is our check arguments, let's say, check our x. That's it, that's your function, and A,B, C, D, let's say E, these are the input arguments. And let's say, at some tasks, youwant to know whether all the five variables that you're working in somewhere, whetherall of them are numeric values or not. If they're not numeric values, you're not movingon, and you're doing something because you were extra, let's say you're, let's say you'retaking input from somewhere reading from a file or whatever. And you need to, you needto check before moving on whether A, B, C, D, and E, whether they are in sore floats.Otherwise, if if if any of them is not into float, then you're not processing, then you'renot moving on, and you're going to check the input arguments again, and so on. These kindof functions are there because whenever you call certain, whenever you want to do processingon data, sometimes it is required to check the type of the data whether the data is suppliedin a way that you were expecting and so on. So let's have this function check Oryx. I'mnot writing document string here, I guess, I've told you enough to write document stringagain and again. So let's see. If is instance. A, if is instance int float? If that is true?Andis it let's just have three variables just to just to focus on if is instance, a thenB. and is instance see if all of them are? If allof them are? If all of them are integers or floats, then do something then let's say Brent,a plus b, plus C, maybe, or a plus b plus c, raised to the power to just print theirsquare, let's say else are if they are if they are all integers or floats, then do someinteresting task here some task. Otherwise, you can say okay, print,air. The input arguments are not of the expected. But it's fine. You have this function, let'ssay, let's call this function.The function was check arcs. So let's check arcs, check. arcs, check arcs, let's say three,four, or five. So now you have all of them are great. Let's say you have jet arcs. Andyou call this check ARDS.On,let's say, three, four, but this five is a string, let's say, Gee. Now we'll be havingan error. The input arguments are not all of the expected types. One of them or moreof them or whatever. Yeah one more thing the this function is expecting three argumentsif you call this function by less than three or more than three arguments you'll be gettingan error for example three four although this function is accepting three arguments, you'recalling it with just two you're getting an error because you have not specified all thearguments that the function is requiring although the the arguments that you have supplied theyare of the type that it is expecting, but you have not supplied the the number of argumentsthat the function is expecting. Similarly, if you call this function by more than threearguments, although it requires three arguments, you again will get an error, because it isexpecting three arguments and you have not supplied three arguments. later on. In lateron, we will see how to write a function that accepts a variable number of arguments, wewill see that but right now, in this particular way, if you write the function, if you definethe function in this particular way, you have to define the arguments the number of whateverthe number of arguments it is expecting, you have to supply exactly as many. Otherwiseyou are getting an error. Okay, so that's about the multiple arguments. Okay, what next?Well, next time, in the next video, we will see that what is the what's the importanceof order of these input arguments? What will happen if I just swapped message to win messageone? Will that will that change the behavior? Or is there any order? With the first mess?The first variable, the second variable, third variable? Is there any ordering inside theinput arguments? Yeah, there is. So let's see in the next video, in the last video,we saw, how can we pass multiple How can we define a function with more than one inputarguments, it is important to know that the order of the input argument is really, reallyimportant. So whatever argument at the call time, for example, if you call this particularfunction, the name of the function is f, that's not a great name, you should have a name thata descriptive but I recommend write good names, let's say this is f, that's a function andthe very first variable is C to the second variable c one, the third variable is C three.Now you let's say call this function like like this, let's say two, four and nine, whatwill happen is this too will be copied in C two, this four will be copied in this Cone and this nine will be copied in this C three. Now, C two has a value two, c one hasa value four and C three has a value of nine. If you change the symbols or the variablesorder here, whatever order you have written there, the first value that is passed at thecall time will be passed to the first variable whatever the name of the first variable is,the second value at the call time is copied in the second symbol, whatever the name ofthe symbol is. So, this ordering is really really important. One way to work one workaroundfor this is at the call time, you actually define the variable names and their values.For example, you call you call F and you say okay c one has this particular value, butthis way you need to know that there is the symbol name in definition is exactly c one.So, C one has this value, C two has this value, C three has this value, once you at the calltime, if you have defined your variable names along with their values, then you are orderfree. Now you change whatever whatever if for example, you call this way c two is b,c one is a now no matter in what order you have called these,this C one is going to be copied in C one, the C two is going to be copied in C two andC three is going to be copied in C three for the functions that has many more arguments,it is it is good to it is good to call the function in this particular way. If thereis a chance that calling a function in a different order may may may become confusing and stufflike so. This actually gives you more grip on this ordering issue. if if if you're ifyou're happy with if you're very smart and When you say Ok, I will always supply in aparticular order, I will always read the document string first, and then I will call that function,that's okay. Otherwise, this is also a feature that is available at the call time, you assignthe values of the functions that are there at the definition time. And now no matterin what order you are calling that function, see one occurs at third position c two occursat first position, the relative values will be copied according to their names. So andthat's a good feature. That's a very good feature. Let's see, for example, a runningexample of this in Python. In Jupyter, notebook, okay, define, let's say function f, let'ssay it receives a, b, and c, let's say three values. And let's say prints. A, is that'sit, Sprint, a, is a. And you'll say okay, B is B. And then it prints Okay. See, C, Cis, whatever the value of c is, that's the C, okay? Now, let's call this function f,with, let's say, two, three, and game. So, they will say, okay, a is to B is three, Cis game, fine, great. Now, this tool will be copied in a no matter what if we if wechange this, if we change this calling order, for example, if we if we change this order,we just we just moved to we just moved to this particular order, we just say okay, thisis three, this is game, this is to be called like, so now three will be copied in a gamewill be copied in B and two will be competency. And that, if if if that is the behavior youwant, then you are good to go. Otherwise, it is it is handy to call the function inthe following ways just fix, okay, a is a is to fine. B is three. And C is let's sayagain, if you want these numbers, now, if you call a function like so, that will happen.Now, if you change the order, no matter what order of add the calling time you come upwith, it will stay the same. For example, you go and say okay, C is at the first position.And a is at the second position, let's say two, and B is at the third position three,the output will stay the same. And that's a, that's a beautiful, that's a beautifulthing. So that's one way of handling with the order. If you if if you think at calltime it is important to define the variable names, but it has one problem that you needto know you need to know exact variable names. If the variable name is C one there, you needto know what it's see one, you need not to I mean the C one matches with C it must matchwith C one, C two must match with C two and so on. So you need to know these names. Okay,great. In the upcoming videos, more features of functions are are going to are going tobe discussed. So stay with us hope to see you in the next video. So we in the last video,we saw the ordering of input arguments in a function.And we saw a fix to it. I mean, if you if you if there is a chance that you may missa proper order, there is a way to fix that we saw that in the last video. Here, we haveanother another thing to discuss this x variable x input argument This is the variable thatis defined inside a function although the value it receives is copied from somewhereelse, but it is defined inside the function that is also the function variable or theor the variable that is in the scope of the function inside the function in the body ofthe function something like so it may be handy. For example, let's say you want you you computesomething you do some processing on your inputs. And whatever the result is you save that resultin another variable. And let's say now you need the value of this variable. to do somefurther process, let's say, what you do is let's say in a call time, that's let's saythis is the this of the function and say, This is the complete function. And let's saya is equal to 12. And B is equal to, let's say seven. And let's say you call the functionadd a, b, now the value of a will be copied in x, the value of d will be copied in Y,okay, and now, you need the Sum of a and b, to be received here, in a variable, you wanta variable in which the results should be saved. For example, let's say a variable isD, let's say, and then you want to do some more processing on D, let's say d doublestarfive, mod three, and maybe you need to apply an if condition on that if that equals tozero, then do some stuff otherwise, so let's say you need this variable out, what willhappen is this C variable is not accessible outside this function. And the reason is theC is defined inside the function when the function body completes its execution, theC is lost sees no more available, C is defined when the function call has been made, whenthe when when you're executing the statement C is defined and a memory location was createdin a C sometimes called the function space in the memory or process space that is createdin memory. But once all the body of the function executes all the functions that were insidethe variable they are lost, what how can you How can you receive this value? How can youreceive the value inside see outside this function? So, that is, that is question inthis slide, how can we do that further,this particular function can access all the variables that are not defined in this function,but that are available outside this function and are defined already. For example, let'ssay I have a function, f. And the function is let's say I have a function f. And so ifthis function is defined, like so f, let's say F is your function, and it has to findlike D, E, F, and that's it. And here it prints let's say, some variable, let's say a. Let'snow now you know this a variable is no longer in F not even defined in F, but as long asthis a variable is defined, before calling F for example, that's the cell where we arewriting the code and we say okay, a is equal to seven, and then we just call this F, becausea was available before calling f a will is accessible here. So, the functions the variablesthat are available before the call, they are available inside the functions, but the variablesthat are defined inside the functions, they are not available outside. That's the problemfurther, if we define this ad here is equal to two now, this a is sometimes called thelocal variable or the function where the variable there is local to the function. Now, thisa is is is defined inside the function and all the accesses to a will access this valueto rather than the sound considered sound has a separate location in memory, and thistoo has a separate location and memory, both have names a, but this a will only be referredto when the function is executing, after the after the execution of the function completesthis has gone from the from the memory and this will still be available, the seven willstill be available. So it is good to know and by the way, if a was not defined here,and you still call F, then either you will be getting an error, or this a might be aglobal variable or available in some package that you have already loaded or stuff likeso, in that case, this eight will be accessed if it's a global variable or accessible. So,it is good to know the the scope of the variables inside the function because when you're callingthem what functions if this if x is already defined, for example, if x is already definedlike 34 and then this x is 34, as long as this x is not defined here, if x is definedhere, this is this x actually is the local copy and that will be accessed inside thefunction. Once the function is gone again x will be 34. So, it is good to know the localcopies or or the function space itself. The but but the problem here is how to accessthem. This variable the value of this variable outside the function, because this is completelydefined insidehow to access that? Well, well, there is a fix, and that fix is called the return statement.If you write the return statement, for example, you return this value. So x plus y, you mighthave saved these values, you might have saved these values, for example, C equals x plusy, that's okay. And then you say, okay, return, see, what will happen is wherever you havecalled this function, d equals add, let's do three. Now, this value, this value C, whichin this particular case is five, that value will be returned in D, and all the propertiesof this variables are returned in D. So just like the C is copied in D, and this is availablefurther, whatever you want to do with this D. Okay, so yeah, so return statement is there.So, in the next video, we will actually code this in Jupyter Notebook and see the returnstatement running and we will see the scope of the variables and all that in Jupyter Notebook.So hope to see you in the next video. In the last video, we saw a scope of a variable particularlyif a function if a variable is defined inside a function, is it accessible outside the functionand if a variable is defined outside the function, is it accessible inside the function and viceversa? and so on. So we discussed those kinds of things, which is sometimes called schoolscope of a variable. And further, we discussed what if we want, what if we want a value ofthe function that is computed value value of some variable or some result that is computedinside a function? What if we want that to be accessed outside, outside the function?So we discussed that in detail in the last video, so let's see all those concepts ina running form in Jupyter. notebook. So let's see how it works. So first of all, let's definevariables, let's define a function, let's say define, let's say, my ad. And let's sayit receives two arguments, let's say a and b. And then let's say C is a plus b, let'ssay that C are our c value, that's a c value or some value, whatever, whatever you wantto call that value, some value. That's it. Let's say we did, we did that. Now we wantto access that some value from outside the function. paint some value. By the way, let'sfirst call this function, let's say my app, add four values, let's say two, three. Sotwo will be copied in a three will be copied in B. So then, let's access let's try to accessthis value, some value, it will throw an error. And the reason is this variable, some valueis not accessible outside this function. What if we want to access because this is definedinside the function? What if we want to access this? I mean, what if we want to compute someresult and then use that result outside the function? So the way out, as discussed inthe last video is return statement. Return Value. And now if we call that again, letme let me go if we call that again. Now, what we haven't actually registered, by the way,remember this, that's, that's a common error I got in that era, a lot of a lot many times.If you change the implementation of the function, you have to rerun that cell, you have to registerthe updated copy of the function to the Python, otherwise, you will be getting errors. Probably,yeah. What's the problem here? Now, when somebody Oh, we, oh, there's somebody is still notstill not accessible. Because some value is not is not accessible it is it is a variabledefined inside the function it is scope in, its the scope of this variable, is just thebody of the function. So let's receive this output in a variable D. And then let's justprint D and D is five. Great. So one more thing. Let's say we define a variable here,of variable outside the function, let's say that's a label name. That's a very lengthyname, but let's say that's the name variable. Well outside the function that saves valueis three. And thenthen let's define another function somewhere. Let's see, let's define another function downsomewhere, let's say define F, maybe G, and it receives nothing, but it prints this, that'sa variable. out side the function. And that's it. That's it, that's a function. Now, whenwe call this function, this variable outside the function that is accessible inside thefunction. So so and and, and if this function, and if this variable is not defined insidehere, and if there is this is defined somewhere else, and it is global or accessible, it willstill be accessible. However, if we define a function with the same name, let's say variable,outside, outside the function, let's say five, now, this function will print five, if webecause that's the local variable, that's the local variable in the function. Now, thiswill be accessed in this print statement. Let's see. Now the result will be five. Butif you print the variable outside, now the value will be three, because this variable,this particular variable that was inside the function, it got destroyed when the functionfinishes. And this is available again. So yeah, so you need to know, by the way, it'sa good practice whenever you want to, whenever you want to access a particular variable inside,it is a good practice to pass that variable as input argument to minimize the confusionsbecause this can create a lot of confusions. So it's a good practice, although the featureis available and sometimes useful as well. But it is always recommended to pass the valuesas input arguments that whatever you want to access inside the function. Okay, so onemore thing, this, this function g is returning nothing. For example, it is not returninganything, it is just printing, let's say something, let's say it is not printing anything, let'ssay, let's say this is a comment, let's say it is not printing anything. So this, andthen we call this and that's it. So it has no return value. By the way, in Python, evenif you even if any function, even if a function does not return anything, it still returnsa value, which is called none, which you can see here. So in Python, a function alwaysreturns a value. If you write a return statement explicitly, it returns that if you do notwrite return statement, when the function body finishes, it automatically returns none.Let's see the type of this output. What is the type of this output? What is the typeof this man, what kind of data type is this? Let's see. It's an n type, I mean, that'sa type in Python. So downs are non type, output, how fancy Well, one more thing, the returnstatement is not only used to return a particular value, if you for example, in a particularfunction, let me write a function here. Let's say d f, that's the function is H. And theninside that function, you do something, let's say print, a, let's say then you define avariable, let's say a equals to three, let's say, then B equals let's say five, and thenyou add those values A and B. And then you do some other stuff, let's say plant something.And then you just write a return statement without any output or I mean it is not returninganything. You can still you can still I mean continue writing the function body more andmore. But what happens is whenever the first return will be encountered,the function returns from there. So the effective body of the function is just that the functionreturns right from there. If you return a particular value for example C, you can receivethat value outside the function. If you do not return anything, just type a return statement.That means exit the function right away. It works like the break statement and loop. Rememberthe break statement it It resembles to break Excitement bulletin means just exit the functionright away, no problem. And by the way, when return is called the default return valuethat is returned is none type if the return is called without, without an argument here,so for example, let's run this function. Let's see. And let's call that function Ah, yeah.So it prints a, then it brings something and then it returns. And it returns, for example.It returns nothing but anon. It returns or not. And if you didn't see, for example, saying,then it returnsa C, value of C, which is eight. And this time this type, the return value is no longernone type, it is probably an integer type. Let's see. Yeah, here. So it's indeed a typeMake sense? Yeah. So return statement has two purposes, one, you can return a value,two, you can return, you can just return the control, you can just exit the function likethe break and loops. Just Just one more thing. return statement can return multiple values.For example, let's say we have defined a function, let's say J. Let's say G, G, we already havedefined, we can redefine it. But let's say our is our function. And we just have a equalsfive, b equals seven, and D equals let's say something. And then we just return them a,b, and A, D, and D. So return statement can return multiple values in a sequence. Now,if you receive those values, let's say X, Y and Z equals r, so a will be copied in ais a first return value, it will be returned in X, it will be copied in x, b will be copiedin y, and D will be copied in z just as a sequence as you as you keep the sequence inthe return statement, if you change the sequence and return statement accordingly. So whateverthe first value here is the first value here, whatever the second value, here is the secondvalue here, and so on. So let's run this and just print all these things X, Y, and Z. Soyeah, five salmon and something. So this return statement is really powerful. I mean, it canreturn multiple, not all the languages, actually, not all the languages, they have feature toreturn multiple values. But Python does have feature to return more than one values. Andmore than one values of any type A can have different types, you can have different types,you can have different type, and so on. So that's about the that's about the return statement,as well as the variable scope. And whether you can access a variable that is outsidethe function or inside the function, and so on, and all that kind of things. In the nextvideo, we will talk about what if we want to access arbitrary number of input arguments.I mean, we do not know how many arguments will be there inside. But no matter how manyarguments a particular user is giving, let's say we want to write an add function. JustJust to give you an example, let's say you want to write an add function that says defineadd that say add to another function, add two. Let's say it receives an arbitrary numberof arguments. D in I don't know how many and it has some implementation, then anybody whowants to call this add to it, if that person gives two or two arguments, then just twoshould be added. If the person gives three arguments, then three should be added. I mean,the person can give arbitrary number of arguments. How can we handle that because because thecaller the this is the call, this is the call, the caller can give five arguments, six arguments,seven arguments. And earlier we saw in the definition, the total number of variableswhen we specify, we have to pass those many arguments for sure. If a single argument ismissing, or a single argument is just more than the specified number of variables, wewill be getting an error. But how can we handle the situation where we have an arbitrary orvariable number of input arguments? How can we handle that? So to answer this, or to get,how can we do that? See our next video? It's coming. In the last video we were talkingabout how can we handle arbitrary number of input arguments. For example, let's let'ssay we want to write an add function. That should be a To add any number of let's sayinteger or floating point numbers that are passed in. Remember last time, we discussedin an earlier video, that when you are defining a function, the total number of variablesthat you are defining, you have to pause exactly those many input arguments. Otherwise, you'regetting an error. But but this may be required some time that we want to add a universalkind of add function that has that has capacity to receive any number of arguments. But nomatter how many arguments it receives, it, just add them all and return the result. Sucha function, if available will be very, very helpful. Because sometimes we might be callingthat function by just two arguments. Sometimes we might be adding might be calling that functionwith, let's say,three arguments, and sometimes more arguments or less arguments and so on. How can we havethis kind of feature available, but the implementation is just one time implementation? Well, Pythonhave a very, very easy way of handling this arbitrary or variable number of inputs. Andthe way you do that is when you receive when you are defining a function, you just writea star, and then just Brent let's say, one variable name, let's say arcs. And then afterthat, this arts will act like a list. And I mean, it will be having a lot of propertiesare this arts has a property, this this x like list, so all the arguments that you willsend in will be received like, like you're receiving those in a in one list. And allelements, which are the arguments in the list, they are accessed by different indices, wewill see lists in detail later on. But right now just think it is a collect all the collection,it is received by indices, for example, the ARDS, the very first element is indexed byzero, it is at the zero location. At the zero location, there is a three at first location,for example, the location index number one, which is actually the second look, the fourwill be copied at this and so on. Now, no matter how many arguments you pass a list,it will be of that size, and there is a function length le n that is handy to just check howmany arguments are there. Now if you pass two arguments, the arcs will, the length ofthe arc will be two, if you have three, if you have passed three arguments, the lengthof the arts will be three and so on. No matter how many arguments you pass this arcs, itwill receive all them in one by one and all the elements in that arc will be indexed by012, starting from zero until the length of the arcs. So see, for example, here, theysaid the sum sum equals zero, let's, let's say we want to add all these for i in range.And inside range, we just give the length of arcs for this example 12345, the lengthof arg is five. So I will start from zero till till four, because five is not included.So the very first time I will be zero, and our eggs in subscript zero is actually thevalue value of the first variable, which is three, so three is added to zero, then nexttime, I will be one and add the position one four is located. So three plus equals four,which means three equals three plus four, a sum equals whatever the some previous valueof the sum plus for the next time, the value of i will be four, you know how this loopworks, we discussed the loop and loops in detail. And as you move on, you actually exploreall these numbers. And this variable sum actually contain the sum of all the variables. Nowyou can return the sum and that at this particular function acts like a universal guide a functionthat receives arbitrary number of arguments. How cool is that? Let's see in Jupyter Notebookto get more convinced how it works. So let's say we have define, let's say we have anyfunction, my ad, they might add, let's say that function might add powerful, that's universalor universal. Universal might add universal, and it received receives star whatever thevariable name is, that you can read, you can write the name arcs or you can write any otherother variable limits. This is this is just this is just a name of a variable. Okay, thenlet's say we have let's say we have s equals zero, which is some, then we just apply aloop. I guess you know, the loops we have lengthy discussion on loops, in range, length,that's a built in function length arcs. Okay, then what should we do s plus equals r xi, which means access all the elements one by one. And this is again the same as S isequal to s plus r x i. Either way you write this way or that way, both ways are fine.Then when the loop finishes, s contains the Psalm, just return it, and you are done. Wow.Now, let's call this add function, my add universal. And let's call this function astwo, four and five for these, and let's just print the result. Let's just print the result.Okay, the result is 11. Well, because two plus four plus five is 11. Now let's callthis function for let's say, for for, let's say, five arguments. It works. It adds allthese five numbers. Wow, that is great. I mean, now we can add any, we have one function,we need not write a function for two arguments, and then another function for three arguments,then another function for four arguments and so on. Depending upon the number of arguments,we need not to write separate functions. We have just one function working in all scenarios.While so, yeah. That's doable. I've done in front of you. No problem. Yeah, Python allowsthis.Yeah. In the next video, we are going to see how can we actually handle the same kind ofscenario. But we want to handle the sequence of the input variables in a very controlledway. Remember, in some of the previous this this year, in this order of input arguments,remember that we receive three arguments and we pass the three arguments in a very controlledway. And then whatever these are, we don't care whatever the order here if we don't care,what if we want to fix the issue? Or we want to become more careful for input argumentorderings. But then we also want the arbitrary number of arguments. How can we do that? Yeah,wait for the next video. And I will show you how can you do that? In the last video, Ipromised you that I will show you how can you achieve the ordering of the input variables,but still having the arbitrary number of them. Remember, this looks like much familiar toyou, that's a call that can be made to a function. And remember, the function definition in someprevious slide was like C one, C two, and C three maybe. And then something. What ifwe want an arbitrary number of arguments to be passed, but we want their control. Forexample, let's say this particular variable symbol name that acts as a key, that's a variablename, and that's the value. So let me call the variable name as a key. And let's Thisis the value that is copied in the variable. That's another key that's a value, that'sanother key that's a value and so on, what if we have a lot of key value pairs? Whatif we have a lot of them. And we also want to check which value is of what key, let'ssay we want to specify those. But we want to specify an arbitrary number of them. Let'ssay here, for example, there are only three, let's say we want to pass five of them, sixof them, and then we want our function to perform accordingly. No matter how many inputarguments it received. Yeah, and and maybe inside the function, we may have applied acheck that if the key value is C one, then do this processing, if the key value is Ctwo, then do that kind of processing and so on, let's say, based on different variablesymbol names, we want to process the value differently, how can we achieve that, andstill having the need that these number of variables can be can can be in a variable,variable length, they can be an arbitrary number of those. So Python gives you again,a very, very simple way. Rather than writing a simple single star, you write a double star,and then you receive in whatever variable name. And now in this double double star meansyou are receiving a key value pair list. It's a list of key value pairs. We will see thatthat resembles two that resembles to a data structure in Python called dictionary. Wewill see dictionary later on in detail but right now just just consider that this inputargument this input variable C, it contains a, it contains a list of key values pairs,and then you just you can just iterate over the sea you can just apply a for loop to checkthe contents of this Remember, we have actually done that kind of thing in the, in the portionof loops. Yeah, here. Remember that was a key. And that was a value that was a key thatwas a value. And we did that thing, we could explore the we were able to explore the dictionary,just just using for loop. Yeah, it's the same thing here. It's not exactly but you can thinkof that that's exactly the same thing. So you can explore that, that see looks likea dictionary. Now this is key, this is value, this is key, this is value. This is key, thishas value, you can this x points, the first key, then C of x point to the value basedon the based on the key x, and then x point to the second key, then the second value andso on you that that is very simple procedure, you're just printing all the dictionary, butyou can, you're printing all the variable names and the values, but you can do verycomplicated processing, if you want to, let's go to our friend Jupyter Notebook to justget convinced that this indeed works. Let's see. So let's define a function first. Sod f, that's the function name is Brent, allvariable, variables, and values. So that might be a function name. While that's lengthy one,but descriptor one, maybe we can make it more descriptive, paint all the variable, variablenames and values, while that's more descriptive a guess. So it receives, let's say, doublestar.Any variable, let's say the variable name is again, let's say arcs or anything, whateveryou want, then what we do is for x in orgs, just Brent, let's say, variable name is justBrent x, and then the sprint x and then just continue, and value is value is our eggs ofx. So let's say you, you done this, you did this. So the variable name is this, and thevalue is this, okay, and you want to do this for all, all the all the variable and valuepairs that you that you send at the call time. So now let's call this brand, all variablenames and values. And let's call this let's say the variable first variable name, let'ssay is a, and its value is three. The second variable name is let's say B, its value iscapital B, let's say the third Will you third variable name is C, its value is CCC. Andlet's say the fourth variable name, I mean, you can define an arbitrary number of argumentshere. Wow, that's amazing. That's the fourth variable name is why its value is 6.7. Andfurther notice, you can you can pass variable and value all have different types, I'm indifferent number of them. And and much more. Yeah, you can do that. So let's call thisfunction by just having four variables and their values. Let's see what we got. So well,variable name is a and the value is three variable name is B, and the value is B, variablename is C and the values CCC, variable name is why and value is 6.7. You can give an arbitrarylampi list here if you want. And Python just allows you to do that. And it allows you todo that in a very, very simple way. That's amazing. That's amazing. I mean, that's, that'swhy a high level language or radio, a powerful language should should have a feature. SoPython does have this feature. I'm really amazed. I'm really, really astonished by time.By the way, I'm not saying the other languages don't have this. several languages actuallysupport this kind of feature, but Python supports it in a very easy way. It's very easy to dothat. I mean, it's not not a rocket science. Yeah. Okay, so now we have had an arbitrarynumber of arguments even when the ordering is really controlled.We have one or two more videos on functions. Just to explain a bit more than we will, thenwe will practice on Jupyter Notebook, we'll practice we will play with these functionsa lot. And we will be calling one function inside the other function and so on, we willbe having one better program just just program and noodle Jupyter Notebook just to get comfortablewith this functions. But before that, let's have one or two more things to discuss aboutthe functions. Yeah, let's see. So I hope to see you in the next video. Okay, I reallywant to talk about these default values for a function as well, because that's importantand mostly needed. The default value is a value of the input variable that you assignwell, while you are defining a function, and if the value is, for example, if you callthis F, with let's say, the input value three, then three will be copied in the sum and theprint will be three. But if you call this function without the input, then this valueacts as as if you have passed this. So this is the default value if you do not supplythe value, this is the value that is going to operate. And by the way, you can have multiplevariables with default values, some variables with default value is defined some variables.With default variables, a default value is not defined, and so on. So you can have thisone here must be taken here that the default value, when you actually define the function,and you compile this function, actually, you you run the cell shift enter in Jupyter Notebook.At that very time, this variable is assigned this value at that particular time, it isnot assigned at the call time. So sum equals to zero is already there, when you actuallypress Shift Enter for a cell that contains this code.Now later on, if you pass a value, that value will be overwritten on some, if you don'tpass the value zero will go on, it looks like very easy, but one care that I want to mentionhere that I haven't mentioned earlier, in Python, there are certain variables that arethat are referenced rather than copied, I will discuss the referencing in the copyingdata in detail in data structures. But let me just tell you 111 example, let's say youdefine a list, let's say one, two, and three. And then what you do you copy this list intoanother variable, let's say l two, what will happen is in the memory, this list in a particularway, this is not the exact view of the memory, I'm just showing you, let's say this is theparticular memory layout for which this L is pointing to this L is label for that ltwo is also labeled for that, which means actually in memory, this is not the copy ofthe structure that is made, I mean this is not like in variables. For example, if a isequal to three and b is equal to a, a will be a will be a position in memory, and B willbe a separate position in memory. That is what a view of the memory in ordinary variablesare. But there are certain variables in memory just for memory efficient and cost efficiencyand time. People have people have designed these data structures in a way that when youcopy them, when you just assign a variable to another variable, the memory view doesn'tchange the just it's it's another name for the same for the same for the same memorylocation. So what happens is if you change any value, and let's say l two, let's sayl two, at the very, the zeros and add the zero index, let's say you change that by minusnine, the because it is the same view in memory that changes minus nine. And now if you printthe elements of L rather than l two, you will get the changed value, you will see the changevalue. And that happens. Now why that is important in terms of these default values here forthe function. The reason is, if you are accepting a list, let's say the default is a list, andyou're accepting a list and you are also defining some default value for the list. If that'syour definition, let's say then this list this default value is assigned at the ad thevery first at the very first time, and this L is really a local variable inside insidethe inside the memory. Now when once this cell is run, not the call time at the at thesowhat call the compile time, when the cell is run this L is assigned this and that justhappens once. Now if you call this list with some other list let's say l to let's say twothree and four. Then if you call this L two, l two will go there it will be copied in Land everything is fine, but don't then expect this the contents of L to to stay same asstaying l because l is this default. values, they are assigned just once. And they stayas it is, every time you call the function, they don't change. They are not assigned atthe call time they are assigned at the compile time and they stay fixed. So that care mustbe taken. I will show you that example that particular example, in Jupyter Notebook shortlyat this, this might be confusing right now, because we have not defined, we have not seenlists in detail. But I just want to make this point. I just want to mention this becausethat's important difference with ordinary variables that I mean default values, just,I mean, just like like a value. And if you don't supply a value, the default value justworks. But with the variable that are referenced by variables, you may expect something else.And the Python function behaves maybe differently. And that's because these default values theyare assigned at compile time they are not are compiled time. Actually, this is not acompiled language, I should not use the word compiled compiled again. And again, just thinkwhen we define this function, and we run the cell at that particular time, the defaultvalue is assigned. And the default value never changes. It stays fixed. Yeah. So and I willshow you that example. Why don't we move to Jupyter Notebook and see that example? Yeah.So or why don't we do that in the next video? What do you think? This video, okay, samewith you. Okay, let's go to Jupiter and mode notebook and see the default values. For example,let's see.Let's say we have define a function, let's say GG, and the default value s is equal tofour, let's say that's a default value. And we want to print let's say s, if available.From the call time, if not available, then four will be printed. Now we print now rightnow we are going to print, now we are going to press Shift Enter at that time, S is assignedto for S has no value for it is assigned there. Now we call GG, let's say and we call GG withoutinput arguments. Now the four will be printed. If we call this GG with some input argument,let's say 56. Now the 56 will be printed, no problem, everything is fine. Let's seeabout the lists. For example, let's say the list is, let's say 123, that list, and thenl two is simply let's say l two is L, then what we do is we change the contents of Ltwo, let's say we change the very first value in L two, and we place that values minus nine,and then we print L. Now, you might be expecting that l is a different thing, l two is a differentthing. Because l and l two, they both are pointing to the same memory. This, the contentthrough l two actually changes the memory view and l also changes and that gives theresult minus nine in L. Well, the behavior that I want to show you is different in thedefault values. When we when we talk about for example, let's say we define a function,f f and it accepts a list and the default value is empty list, or the default valueis let's say one, two, that's the default value, let's say if, if no list is passed,the default list is one two. Now, in this particular scenario, if we just print, sofor example, for i in the list, brand, I let's say we just print all the list. That's it.Now we will press Shift Enter, and at this time this L is assigned this value, and that'sa default value that never, that is not going to change. Now let's say we have an L toolthat is simply let's say two, three and four, or let's say 12, three and four. And whatwe do is we call F and we just press Shift Enter. Now, why don't we call f f withoutanything. So, the default list is printed, if we call this f f with L to the L two willbe printed. Now the notice that this L two actually is copied in this L because we suppliedit. So l and l two you may tend to think that l is now also pointing to L to an L has alsothe same contents as l two. So if next time because because of the behavior of these listsbecause they are by Reference. Next time you make you make might be thinking that becausel two is past there, so l two L is also L, L two is copied in L in a memory view waylayout. So l has also the same data as l two and next time, if we call this function withoutinput arguments, then l might be pointing out to L two values. So, 12 three and fourmight be printed, but that is not going to happen, the default values they never change.So, again, you will be getting one, two, so, the behavior of these Reference Type variables,that is different ordinarily, but when you do that in in the default value structure,that, that, that might work in a different way. And the reason is, you, you must knowthat these default values they're assigned at, at the time when the function is created,not at the function when the function is called. And they are not going to change whatsoever.So, so that was about the default value. And by the way, the default if it was a simpleconcept, I guess I have made it too complicated by telling you layers and default values andcreation of these variables, at what time and at the call time, I made this complicated,I guess, I shouldn't have told you the list values and all that stuff. But but that'strue. And in whatever I have told you is true. Maybe I have told you in a very complicatedway, but it's true. Yeah. Okay.One more video on the functions and then we will be practicing functions in detail onon Jupyter notebooks. So just be or one more video with me. Hope to see you in the nextvideo. Okay, this is probably the last video on on the functions. Yeah, we will, we willbe having one more video. But but that will be like coding and practicing all the conceptsthat we learn about the functions not? Not something not not new theoretical concepts.Yeah. So let me ask you a question to actually, to actually make you understand about thisslide. Let me go to the Jupiter and ask you about a few questions. Let's say you have,let's say, let's say you have this particular function, and you, let's say my ad, my aduniversal, let's say we have written that function, maybe two or three or three videosbefore, let's say you have this function, you have written this function, and you arevery, very excited, wow, what kind of masterpiece you have generated, it can add an arbitrarynumber of values pass in it well, but this particular function is written inside thisparticular file, which is mastering Python zero to hero. Later on, let's say two or threemonths later, you are writing some code for some, some project or you are doing somethingsomewhere and you are writing code, and there you just needed.You just needed a, you just needed a code for adding a lot of a lot of values together.And then you just remember, oh, I have written some function somewhere. How can you use thatfunction? One way is to just go back to that file mastering Python zero to hero, and justcopy this function, this particular this code and paste in the new file, run that, registerthat and then call that happy. What if you want to use let's say, 100 different functions,let's say you have written a lot of functions in a lot of different files. And now you wantto use all of them. And, and let's say this is a repetitive kind of demand several timesyou notice that this usually happens that this particular kind of function, you requirealmost every almost in every project, let's say a set of maybe 50, or 60 functions thatare that are required always, one way to do that, as I told you is to jump just copy pastethose functions in every file, run them and do that. Another way is to just just I mean,make a module a file of containing just those functions. And whenever any of those functionsis required, just import that module into your coding file, which has one line of codeand then access all the functions as if they were they were they were actually availablein in the port file that you are working on. So that's about the that's about making modulesof so module is basically a Python file that contains functions that you want to use inseveral different coding projects or the functions that you don't want to write in your the functions.Having the implementation that you don't want to write in your grant coding file, so youcan have several of those functions stayed somewhere else in a different directory theyare residing there, whenever you want to use any of them, you just import the whole moduleand use the functions. So, so module is just a Python file that can that can contain acode for you that whenever you want to use, you can use it. Normally it contains functionsmaybe more than one function and several functions. Normally, it contains functions that you repetitivelyuse, and that you have written once in very careful way. And then now you want to useit again and again in several different ways. You need not to write the function definition,in every coding file you need, you just make one coding file, or that that is the mostimportant for you, that is called a module where wherever you want to use any of thosefunctions that are there in that module, you can call it, you can use it. So that's aboutthe modules we are going to make. I'm going to show you one example of making module andhow to use that. But but to use the module, we need to actually specify the path wherethe module actually resides using this cess module. So and then we have to do some thisimport kind of commands. And then I mean, there is some work that we need to do to actuallyget this module running in our code. So in the next video, I'm going to tell you whatthat extra work, very little amount of work what that extra work you have to do. So here,for example, my funks.py, that's my Python file, and it contains these two functions.And let's say I want to use one of these have both of these functions in some other file,and that file contains this particular code. So in the next video, I will show you howto how to actually make and use the modules. Yeah, so hope to see you in the next video.Okay, in the last video, I told you about modules module is just a Python file thatcan contain a code that can be used anywhere, if you want normally, that module. Normally,the modules, they contain a lot of functions, but they can contain variables and other values,and so on. So think about file myfonts.py, that contain this, these two functions, andthink about a different file, maybe Jupiter, maybe you're working in a Jupyter Notebook.And now you want to use these two functions. So you first have to import another modulecall the system module says you have to have you have to make this path available. Thereare a lot of built in modules that are already there in the path all the already there inthe search path. When you want to call a function, it is written in some module that is alreadyin the search path. If you're making your modules, you have to eithereither copy those, those modules into the modules that are built in or if you want tomaintain them separately somewhere else, then you have to add the path of these in the searchpath as well. And the way to actually insert this path is sis dot path dot append. Andthen you actually write the the path of the directory where this module file one or morefiles are located. Once this is added to the path, now you can write the import. And youcan import your file and your file as it is or you can import your file with some othername if you want, you can rename that on the fly if you want. Once this is imported, nowyou can use all the functions like the built in functions, the implementation of thesefunctions are not there in your coding file, you are just using those and you can now importthis module into some other file and use their and so on. for, for, for for very large kindof projects. It is good to make modules. Actually it is better to make packages, which is actuallythe directory structures that contain modules. But modules at least are really good too,for maintaining a large amount, of course, or actually the functions that you want touse again and again. So let's just let's let's make a module, why not? So let's make a module.Let's say let's go to Jupyter Notebook. Let's create another file. Let's create anotherfile, let's say new Python three and let's let's name this file as my IE let's say let'slet's name this file as my universal, let's let's use underscores my universal functions.Let's classify the name. Let's create another notebook. Right now it's just a notebook that'sdefined some functions. Let's say we want to define one function as jack, all orgs.Let's say that's the function it receives, let's say,let's say it receives a dictionary like input. And then it checks the date, let's say check,set check type of all arcs. And let's say, let's say you write a function check, if notnumeric, let's say, let's say you want to write a function that that just accepts alot of arguments. And you want to check whether any one thought, if any one of them is notnumeric, you want to return let's say, a flag. Otherwise, you want to return a true, let'ssay, so for example, you may you may need this function in several places. Let's sayin in your core, you're expecting numerical inputs. And if the input is, and let's saythere are a lot of variables that you are working on if and if any one of them is notnumeric, you might want to check all the all the variables and their values. One way ofdoing that is just to create a list. And that's it. I mean, that's and and you may have severalof those, I mean, you can check all of them. And maybe here, maybe here, we do not needthe dictionary kind of argument. So maybe we just are happy with just one. So let'ssay for so the output, let's say output is let's say, R or the return value that value.Let's say that is already true. And we will say okay, for x in ARDS, let's say for x inarcs. If x if is in stance, x is and float, if that is true, then we are happy. But ifthat is not true, if that is not true, then there is a trouble, then we say okay, if thisis not true for any value, then we just return. False. Okay, we just return false. I mean,we need not to break anything, we just return false return means return, whatever. Otherwise,if we finish this loop, if the loop finishes successfully, and there is no return statementthat is called already, then we return, maybe true, we need to do not need Actually, thisvariable. Let's see. So this function will return true if all the variables are eitherint or float. If any of them is not of this type, this function returns false. Well, wecan have another we can have another function, maybe we can write several function, the samecell or in different cells. Either way, define let's say another function, universal. Oradd all values, let's add all that's in Numerix, and all numerix. And it also contains, let'ssay, arcs. And the goal of this function is just to add all the values and return thesum. So let's say s equals zero for x in for x in ogs, as plus equals to tax, and that'sit, then return us, let's say these are two functions. And maybe one more the name ofthis, or some some variable, let's say you, I mean, these are two functions. Now we areout of the function we are writing something else. Let's say my name let's say that's avariable, my name this, this does not this my name variable does not belong to any ofthese functions. And my name is Python. Course let's say that's my. So that's it. That'sfile with name my universal functions. So what we do is we download this file as a.pifile.pi file. So what we do really is the Go to File, let me just zoom this out so thatyou can see the download options. We go to File Menu, we download this, as we downloadthis aswe download this as well as by file, so Python file. So let's download this, or we can writethis Python file as in some other editor if we want. So open folder, there is a Pythonfile here, copy it. Now copy that file. And now you're free to go to any, for example,any, any folder if you want, just, for example, you go to somewhere in your directory, andmake a new directory, maybe, maybe you want to make another directory. For example, goand make a directory, maybe in D, let's say, or maybe an E, let's say or maybe in C somewhereand then make a module anywhere. For example, in C, make a new folder, call that folderas my, or any name, whatever name you want, for example, my module or let's say utils,for example, utilities or whatever name, I mean, let's let's call it as, let's call itas ABC, for example, ABC, whatever. And you just made that and just copy that Python filehere, my universal functions.by. Now, if you go back, if you go back to your there, thereis a Jupiter, here is a Jupiter. Now you go back to your code, this is your file, go backto your code, let's say this file is no longer here. And what you do is you import Sis, that'sa system module and says dot path dot bend. Right the path here where the module is located.So the module right now is located at ABC, this is the part of the module. Once done,you can import what what was the name of the module, you need to know that that was mymy word. So I just I just don't remember the name, let's import my universal functions.How it appears, actually, when I when I have Eric this part, then this import command andafter the dab completion, just fetches that file. So that that that name might be verylengthy. So you can rename that as let's say, my apps or whatever name you want. So youimport that once you have imported that. Now you can use the functions if you want, forexample, you can check the implementation of my efs.if, you see dot add Numerix, youwant to check the implementation of that. Here, this remember this file is no longerin this particular file is located somewhere else. And you can call this function likelike the built in functions, my apps dot add all numerix. And you can have for example,let's say accepts the input arguments, let's say 234. All that says six. And that's it.That's the, that's the return value, you can you can save the return value in some othervariable, let's see. And then later on, you can print this see our do some stuff withthis. See, that's one thing. Another way of importing the same thing is let's say youdon't want to use all the functions, you just need this add all the metrics, let's say that'sthat's the only function that you want to use again and again. So you need not the otherfunctions, let's say for this particular file, you do not need the other functions, thenwhat you can do is you can just say okay, from my universal functions, import,add all Numerix and you can rename it rename this function as something and you can callthat function the same way. So you do that now. You need Not to write any dot kind ofthing, you just call add all Numerix because it is important now, and you say, Okay 234567and you'll save that in let's a D, and then you print the if you want, or do whateverwith that. That's it are you can import several multiple functions or you can import all ofthem. Other than modules, there are I mean, for complex codes, I mean, this is not onemodule that is there, I mean, there are several modules. And the several modules may be arrangedin in a directory structure, where the directory and the sub directory and the sub directoryand so on. So the modules that are arranged in directory structure, although they areaccessed, much like the same way, that directory structure is sometimes called package. Andthese are basically the packages that are that are most useful. And we will be seeingsome data science packages, like NumPy is a data science package. Then, we will be seeingpandas, that's a data science package, we will be seeing matplotlib that's a data sciencepackage for plotting and visualizations and stuff. So packages, just the modules thatare arranged in directory structures. So now you know what module is. And the old one,Venus two, we actually missed to import the name of have to see the name Vivi have saveda name there as well. So let's go back. And let's go back and do that and see how, howmany things are available. Let's go to some other cell and empty cell. So my apps dottab completion, my name is available. Remember, there was a variable. Yeah, that's available.So the name is Python course. So this module file does not require to only contain functions,it can contain any information, any data that you want to use in other files, other codingand stuff, and so on. So, yeah, that's about modules. In the in the next video, we willpractice about these functions a little bit, we will be seeing how to call a function insideanother function, how to make a lot of functions that are calling each other and so on. Sowe will be practicing more on about these functions, not theoretically, just in JupyterNotebook, just to get a better look and feel of of functions more. And after that practice,we will be then jumping towards data structure starting from strings. So hope to see youin the next video. Okay, before moving on, let's just practice some, some some, I mean,let's get a good grip on functions and multiple functions and handling those. And the bestway to do that is to solve actually a problem. Remember, we solved a problem when we whenwe, when we are done when we were done with if conditions, then we solved another problemwhen we were done with loops just to get a good grip on loops. Let's solve a problem.Let's just solve a problem using using the functions just to get a good idea of functions.What kind of problems should be solved here? Should we solve an older problem? Last timewe solve a problem using loops that are sorting a list? What Why don't we? Why don't we solvethe same problem, but in a different way? So let's go to Jupiter and see. See our fileJupiter file? We have actually solved a function, which somewhere using loops, just let me justfind that out. Oh yeah, they're here. So here. So given a list of numbers, let's this makeanother list or maybe the same list that contains all the items in the sorted order, from minimumto maximum, your result will be another list like this. And we solve that using loops.Okay, let's solve the same problem. Exactly the same problems that solve the same problemusing a different way using a different user using functions just to get a grip on functions.So let's say that's our problem we want to solve. So that's the problem again, and wewant to solve that. So how can we solve that? To solve that, let's first define a function.Let's just make a function.Let's just make a function that let's just make a function, let's say define, find minimumand the function accepts a list. And we're times the minimum value in the list not onlythe minimum value of the list, but also the position of that minimum value. So find minimumas well as find out Some minimum as well as the position of the minimum in the list. Sohow can we how can we solve that problem? That's that's one standalone function, nomatter what list you pass in, it will find the minimum. Okay? As long as the the minimumis defined for the items of the list, for example, the list items, or let's say allthe metrics, okay, how can we how can we do that? Let's see, minimum value is the list.Zero, that's let's say, the minimum value. And right now the index at the minimum valueis, let's say, is zero. Okay? like we did in the loops, like is, it is kind of the samegoal, but let's try it a function for it. Okay. So that's the function fine, man. Sohow can we how can we proceed? What should we write here? Let's see a counter. Let'ssee. Concrete let's or it may be that city counter right now is zero for x in L. K, ifx is smaller than our minimum value, if that's true, then the minimum value indeed is x.And the index where we found that is high, okay, great. Else do nothing I mean, elsejust go away. And I plus equals one. So move on. So AI is just the position so AI is movingon and on and on. As you follow the list, and M contains the minimum value and Id Xvariable contains the position of the minimum value. So that's the function for for readability,we might be adding an else clause just write balls. And that means the if condition finishes,I'm in do if this condition holds true, do that stuff, otherwise do nothing. That's justbecause of readability. If you want, even if you don't write the else clause and passstatement, even then everything is fine. So let's call this function just to test whetherthis function is working properly or not. So let's just find, oh, we haven't returnedanything. We need, we need the minimum value as well as the index. So return a minimumvalue as well as the position so return that. Okay. Oh, but we do view returning that insidethe loop that becomes in the body of the loop. Oh, no, no, no, no, no, that's bad. Becauseeven in the first iteration, the return will be called an even in the first iteration,the function will finish indentation, remember, indentation. Now that's better. Now this isno longer inside the body of the loop. Great. That was a bug. We fixed it, right? Okay.So let's go find, let's receive a B, so a will contain the minimum value, and we willcontain the index of the minimum value. So fine men, for example. And the list let'slet's give it the list. 13423409. Let's say now the minimum value is zero. And that minimumvalue appears that 0123. That's the third index. So b should be three a should be zero.So let's see, what's the value? What's the result? So Brent? A, B? So A is zero? Yes.And the position of minimum is three, I guess it is working fine. rate. So that's one function,find a minimum? Let's find another let's write another function. Swap. So define. defineanother function, let's say swap values. And what we do is it it actually accepts two indicesindex one that actually accepts list then two indices, index one and index two. Andwhat it does is it actually swaps the value of index. So index, one value should go toindex two position and index two value should go to index one position in the same list,and then it returns the list. Okay, great. So it would it so so that's, that's a goodexample it would, it accepts a list type variable, it accepts index type variable which are integers.Great. Solet's continue with let's define a variable temp that contains l ID x index one, juststore it in a temporary variable, then at this particular index, next one, just copythis value. Don't worry, we'll see lists in detail. Later on now list. Now at index one,the value of index two is copied. But it is not overwritten, because we already have savedthe value somewhere before that copying appears. So l at ID x two is simply damp. And now returnthe list. So that's how you can swap the two values if you want. Great. So let's just checkit, whether the two values are swept or not. So let's say list is 236. And seven, that'sa that's list. And let's say we want alto that is swept values. And let's say we passthe list and we want the values to be swept at position one, and position three, whichmay add position one, the value is three, because the position starts from zero, andat the third position, the value is seven. So we want these to swap. So the result willbe 276. And three, let's see what's the result? So let's print out two. And yeah, it worksgreat. What else? What else do we need? So we have find a minimum function, we have sweptvalues function. What else? So yeah, what should we do? Now let's write the main functionsorting. Let's write that function. And we will call we will use these kinds of functionsinside that function when you call these functions. So let's define sort list. Let's say that'sour function, it accepts a list and it returns a sorted list. Okay, what should we do? Whatdo you think? What should we do for the very first time? Well, first of all, we shouldcheck whether all these list it contains the list contains all the numeric values are notlet's say we're just doing this for numeric values. So, we should first check the allthe arguments are are of numeric type or not, for that, we should write a function thatshould do that oh, remember that function is all written in in a module remember thatmodule we made that module ourselves? So, we can import that module if we want import?My remember that my universal functions and we just need that function we just need thatfunction one just from from my universal functions import what import check if Numerix checkif not numeric, as you can write that function name something else, but justice. So you importthat function. Now you may be able to use that function. So after that, you can usethat function. If check, if not, numeric list or remember that function returns true ifall the values are numeric, otherwise, it returns false. So if it is true, then moveon the if it is not true. If it is not true, what should you do? If it is not true? Ifit is not true, then you might be printing an error. Error. Last does not contain numericvalues, maybe that and then you just return. Return. That's it. I mean, return. Don't needto write anything in return. Fine. Great. So else we need not to write else becausethis return will take care of that but it is for readability. That's good, right health.If all are numeric, then what should we do? Okay, what should we do? If all are numeric,what we do is we will be doing what we will be fine minimum. We'll be finding out theminimum and then we will be swapping the minimum fromwhat should we do what we we have already a function find a minimum that we can calljust right away we have a function swap values that we can call right away. We already haveused this function. How can we combine all these functions? How can we use all thesefunctions just to achieve the problem sorting, we want disorder list. How can you do that?Okay. Yeah, that's, that's, it looks like it looks like a different thing. Maybe? Maybe.So, let's just write out, let's just for x in the list, let's start thinking here forevery element that is in list for x and list what should we do? We should we should findout the minimum and slap the minimum with x r. So, we should find out the minimum aswell as the index of the minimum and should slap it with with the value x and everythingwill become great. Yeah, I guess Yes. Okay. So, what what we are going to do is we aregoing to maintain a counter right now, the counter is zero, which is just the index,which we are going to do is we are going to find out the minimum minimum and index wherethe minimum lies. So, by find minimum in the list, so, it will return us the minimum aswell as the index where the minimum lies and then what we do is, we will say, Okay, okay,what we want to do is, L is actually L is swap, swap values with index see swap valuesand list with index c. So, index c should be swapped with ID x and C plus equals one,will that work with that work? So, after this will the will the whole list be sorted. So,let's return the list is that true, I mean, we are finding out the minimum value one byone, the only catch is the list is updated here. And, oh, there was a problem. When weare finding out, when we are finding out the minimum, we are finding out the minimum fromthe list. And every time the same minimum will be returned. That's a big problem. So,looks like this fine minimum function is not doing our job, what we need to do really isthe, we should go to find min function and give it that start your stock your final minimumfrom a particular index. So, don't don't search the whole list to find the minimum, startfinding out the minimum from the following index, for example. So let's give a startindex and maybe an end index. But let's give a starting next. So start searching the minimumfrom right from there. How can we change all the code right now? Oh, that's bad thing.Let's change the code. Let's say that's the start index. Start index. That's it. Thisthe index right now is start index and I is also start up VB we may use a range functionhere, that might be much more feasible to us. So let's use a range function. Ratherthan this let's change the coding a whole lot. That's a bad thing we need to changethe code for i in rangestarting from start index, starting starting from start index, ending at length of thelist and doing a step of one Okay. Now x really is x is really list at the index i okay ifx is smaller than m then this is that an index is AI. Otherwise this we need not to do thisbecause this is this is happening automatically. And rest of the story is same, I guess Yes.That will work out. Okay, great. Oh, there is a problem. Oh, we just missed this columnhere. Great. We fix it. Okay. Now, so if value is there, maybe this works. Maybe Doesn'tmaybe there is a bug. Let's see, let's let's just call this function. So let's call thisfunction l two is sort list. And let's pass the list as to 153. Minus 870. Let's see.That's boss this list and see what it returns. If it returns fine, we might be happy. Otherwise,we will see where is the bug? If there is a bug, oh, this does not contain numeric values.Why not? list does not contain numeric values. Why is that happening? bliss actually containsall the American values. We read the problem, check if not numeric, let's see the let'ssee the implementation of check if not numeric. Let's see that. Check. If not numeric, let'ssee the implementation. And there is the bug. Because all these are numeric. So check ifnot numeric x in arcs, if not is instance then return false. So if everything is intor float, so if x is int or float, then return otherwise return true. So it returns trueif all our if all our numerix. So it returns true if all our Numerix so not true meansfalse. And why why does Why does returning for us? So that is just was let us just seewhy it is returning false. That's that's the bad news that something is happening wrong.Let us just see how this is working. So that is just check. Check, if not numeric. Andlet's pass the list this list. And let's see what is returned. Let's just print the returnthing. But it is either true or false. So it returns a false why it is returning a false.It is a bad thing. Why does they're turning a false? Let's go to the File. Let's go tothe File. Here. Sorry. Let's go to the File. Here in this directory. Let's open up this.Maybe open this in simply an old bad. Maybe an old bad, why not? Or maybe some other fancyeditor. Let's open this up and see what is happening. ad format font, let's have a biggerfollow on and see what is happening.Self face one of 20 bugs are bad, they're really bad for x and ogs. Okay? If not isin stance. So first of all is in stance this, it will return true always okay. If not true,which means false. Then we'll move on and the loop will be running if anywhere you whereit is finding out where it is finding out basically. So this this is working reallyfine. Let's, let's let's write this function somewhere inside our notebook and see whatis let's say rather than this. Let's say this function like check the metric to check numericto check it not numeric to let's call that function and see what happens check numericto it is returning false again. Why does returning false? That's amazing. Where is the false?So two is integer? Yes. One is integer. Yes. So true. True. True. True. All these are true.OH minus eight might be a problem. minus eight might be a problem. Let's see. Maybe. I don'tknow. Well, well, there is still false. I mean, I'm stuck here. Guys. I'm stuck here.I don't know what to do. I don't know what to do. I have to debug this function, I haveto go inside that function and see what is happening. So what we really are eggs. Ohmy god, the big trouble big trouble. Yeah, I found the air. We are passing a list. Andthat list is just one argument. That is not a lot of arguments we have to pass all thesearguments in in a different way. I mean, if you want to, you're getting you're gettingthe bug, the bug is we're passing one variable, not a lot of them 2153 817 these are not alldifferent variables. For example, if we just go inside and print x, for just first x, itis the all it is all the it is all the list. It is all the list. It is not the variablesone by one. Let's see. Yeah, I found the bug. Found the bug. Wait. Yeah, see, it is not?It is not a lot of it is not a lot of variables. It is not a lot of arguments. It is just oneargument that is in the form of placed variable. That's incredible. What should we do? Shouldwe go inside and add another function check if not Americ for lists, rather than variablenumber of arguments. What should we do? Let's write another function that check for thelist. Let's write here check numeric to it contains the list for exam just accepts listello or maybe l or whatever x or art just simply, you can call the or l list. And itgoes through all the list. And does does the same job as previous. So now this will work.So the function that was there in our module is no longer working, and it will not work.So we are not going to use the function that is in the module, we are going to write anotherfunction that will help us here. And we have written that, and here we go. It just chainedthat function to that. And we just we just throw that out again. And let's see what happensnow. Oh, there was another error whichever. Find a man missing one o v v did not findthis fireman is missing the starting index. So the starting index is C rate.Right? That's a problem. That's a huge problem. Let's just sorted Oh, my god list finallyis sorted. Oh, huge, huge, huge. So you see, you can call the functions inside other functions,you can call the functions from modules. If they are no longer working or no longer beneficialfor you, you can write new functions, you can call them you can. Yeah, all that stuff.I guess that that lengthy video taught you a lot of lessons, how to how to code actually.And this actually happens when you are doing tasks that are really big. You have to definedifferent functions, you need to define different functions for modular approach, and focuson each function as a separate entity. And that that makes much simplicity in managingthe code and bug fixing and all that stuff. You see, I fixed the bug by just noticingthat just by just focusing on this function. I have not thought anything else, just focuson that function go and see the implementation fix that everything else stays the same. Yeah,so too lengthy a swap here. Okay, now you have done a lot of practice about functions,loops, and a lot of stuff. That was all the basic programming in Python. In the in thenext video, from the next video, we will see the real power, a much more real power ofPython where you need not write a lot of loops and a lot of gold and still you will be ableto achieve a lot of stuff. And for that we need to go through the data structures thatare available in Python. So from the very next video, we will start seeing strengthsthat study or structure we will see less in detail we will see set in detail we will seedictionary in detail we will see tuples in detail. And after going through all thesedata structures and getting a good grip for the data structures. Then finally we willmove we will move to the packages that are available for data science, particularly NumPy,pandas matplotlib. And we will see maybe I include maybe I include one or two videosfor psychic learn as well. So hope to see you For the whole new phase in Python, thedata structures, so we'll hope to see in the next video. Okay, let's dive into the longawaited strings. string is basically just a sequence of characters. And it's a datatype, it's kind of a data type. In Python, it's much more powerful. The reason, the reasonof, I mean, making this a whole new data type in, in almost every language is, the reasonis that almost all the data all the text that appears in sequence of characters, so makingthat sequence of corrector, the whole text as one kind of data type, and writing specialkind of functions to, to deal with that text might be necessary. And that's what the stringis. In Python, for example, you can declare a string variable s, or any variable name,by just double quotes, let's say ABC, are our equal monthly by a single quotes, eitherway is fine, d f. So either way is fine, you can declare using double quotes, or singlequotes, either way is fine. One thing is, be careful, don't mix. I mean, don't startby a single quote, and think that now I will end with double quote, and that will be fine.So don't mix them together. If you're using single quotes, use single quotes, if you'reusing double quotes, use double quotes, don't mix them together, that might be much moreconfusing later on. So let's say this S is a string, Python is the best language fordata science. That's a D is another string that is defined by single quotes. In thiscourse, we are going to learn Python, then you can print s, different in a differentway, let's say you will call you can call a brand s, you can call a print to D. Or youcan just by the way, you can you can add two string variables s and D. And the result isa new variable. That's how the plus symbol works in strings is plus in strings meansjust concatenate concatenate them together. So first, you just copy this string, the wholestring, and then you just concatenate the other string with it. And the result is anew string. Now that's a new variable, you can use that variable and do a lot of stuffwith it. So let's go to Python and see actually, the brains in in the strings in in the runningform. So let's say S isstring, let's say, right on is good language, let's say. And let's have another string T,that is using single quotes. It's good for data science, sci fi. Okay, it's good fordata science, let's run these two, and see the type of s was the type of s. The typeis str string, str, that's what the type is. And if you just print s, that will be printed.Python is a good language. Remember, so far, we are using this sprint. And always we usethis kind of Hello or something like that. That basically is a string because by theway, the sprint function, actually, it takes an arbitrary number of arguments, we can printhello, then we can print anything in another type, then we can print another Hello, let'ssay hello to hello to that's a multi multi variable argument function print, then wecan have another string maybe Who are you. And then maybe a floating point number 5.9.So we we have used these kind of, we have used these kind of, I mean stuff a lot. Wehave used print function. And we were using these double quotes again and again. But butthese are actually strings that we will be that we were using later there. So the springfunction actually accept strings and all these kind of Normally, the whenever you use print,normally you're using it normally you're going to actually display some text, and maybe you'rewriting that text into some file and so on. So this string is highly, highly useful. Mostof the data is available in the text form in the screen form. And we want to processthe data we want to find the anomalies in data, we want to fix them again, we want tostay in the text. So it is good to have a data type that actually have a lot of functionalitythat handles all that stuff. So Let's see, for example, another another, let's see howcan we concatenate the two strings, for example, SMT. Let's say we have B, that is s plus T,that's concatenated. B. And that's francqui. And we is going to get an ad. While biconis a good language. It's good for data science. Well, it is concatenated. But there is nospace between two because wherever the first string ends, the second string starts rightfrom there. What if we can get in a three strings? s plus another string that just containsa space corrector? Then this string? Why do we whatever that is there in double quotes,or single quotes, whatever, one corrector to track character, all these things are calledstrings. So now we are concatenated, three strings together as a space, one space stringthat contains just a space greater than T. And let's see what happens now. So Pythonis a good language space, it's good for data science and so on. Well, soyeah, so that's basically the introduction of string. What if we want for example, toconcatenate? What if we want, we have a variable A, which is 12. And let's say we have variableb, which is the price of this book, let's say the price of this book, and a is 12. Solet's say this is our price. Now price is in integer form S is in book form, let's saywe want to make another string we, that contains the following kind of thing, the price ofthis book is and then whatever the private price is, that should be there. So what howcan we do that? So let's say s, plus, maybe, maybe another string is then maybe a space.So that after that the price appears? Now, if we right plus and right price, price isno longer a string, it is an integer, and an integer cannot be concatenated the stringin a straightforward way, like plus, how can we how can we make a message like the theprice of this book is, whatever the value of the price is, one way to do that is toconvert the variable price, the Convert the type of the variable of price, from integerto string, that means whatever the value, in this case, 12 is written, that becomesa string of characters one and two. And now it can be concatenated with with the restof the string, and we will contain the message that we want. For example, if we now see whatis free, that is, the price of this book is this book is 12. Oh, we don't have a spacebefore. So let's let's type a space, their space is also a corrector can be handled instrength, while so that's how we can convert different types to string. We can have a floattype, we can convert that to string, and so on. Another way of doing the same or achievingthe same kind of stuff is to write Brent, the price of this book is I mean, we can usethe power of the variable number of arguments of then price, that's exactly the same thing.The price of this book is 12, the price of this book, however, consider one thing, theprint function automatically adds the space for different kinds of arguments. You cansee that here, yeah, you need not to specify a specifier space, the space is automaticallyadded if it is if it is considered to be a different argument in the print function.Okay, great. So that's the introduction of a string. We are going to explore string muchin in much more detail in the upcoming video, so stay with us, we are going to see a stringin much more detail. Okay, hope to see you in the next video. A string might be verylengthy, or may span I'm in very lengthy and may span more than one lines. Or maybe theformatting is in a way that you want to even if even if it is not very lengthy, you willstill want the different chunks of the same string to be appear in different lines. Sothere is a way to declare multi line strength again using either three single quotes orthree double quotes. And then three double quotes or single quotes. Whatever conventionyou follow Then you write all the string in, no matter how many lines you want, and thatone variable actually contains a multi line string. If you now print, for example, ifyou call the print function on this multi line, that that's By the way, a variable name,multi line string that contains this data, multi line, multi, multi line that now thespelling our Spelling's around here, I just created multi line anyways, if you if youcall that print function, this will the print will display the string as it is like it isthere. So let's see the and by the way that the same multi line string kind of fashionedremember that that is used for comments as well. If you have comments that span on multiplelines, you can use this. So this multi line string really is if it is not saved in a variableand used as it is somewhere in the code, then that acts as a multi line comment. Great.So let's practice the multi line string in in Jupyter. notebook. Let's see. So let'ssay we have a variable A that is multi line string. And let's say the spring is this isline one.Then we have this is line two, and then we have this is last line. And this line is three.That's it. Okay, great. That's a multi line string. Let's see. How can it Brent a, whathappens? So this is line one, this is line two, this is last line and this line is three?Why this? The first this is shifted one corrector, right? Oh, there is a space here. Let's removethat space if not required. And run this again. While because space is a corrector that willbe printed if you want. Okay, what if you really want really want the following kindof stuff, you have, let's say brand. So what you really do is you want to bring the followingthe following options are available. And the options are, let's say dab, dab, dab, let'ssee a hyphen, a. And that does play from a that does nothing. And then we have let'ssay hyphen B and they're also also does nothing. Let's say you want our message to be paintedin in such a way, what will happen? Let's see. Okay, the following options are availablehyphenate has nothing hyphen B I mean, all this is a string multi line string, thesecrackers that you think they are not there, these are spaces and they are I mean the spacesare painted here, the spaces are painted here, we are saying nothing is printed, these arethe spaces that are printed there. So sometimes this multi line string, it helps to formatour message in a way that we like. So that's how helpful in most of the cases further ifyou write this multi line, by the way, if you write this multi line, comment in thestart and end of any good script. That means the if you write this multi line way of definingthe strings at the start and end of any good script, that code script is commented thatwe have seen several times earlier as well. So, for example, in problem solving, rememberthat we define all? Oh yeah. So that's the comment. That's a comment. Even if some codeis written inside that will not be executed. Right. Okay, so that's about the multi linestring. In the next video we will see because because the string really is, is basicallya collection of all these characters. What if we want to access a particular character?For example, this is the first graduate is d here, the second Gregory is at the thirdcorrect? Is it the fourth record is S, the fifth Gregory space and all? What if we wantto access particular characters inside the string? Because the string contains a lotof directors? What if we want to play with some of the directors inside the string? Howcan we access different directors for example, if we want to access seventh director of thestring, how can we do that? So, let's see in the next video, how can we index differentcharacters inside a string, I hope to see you in the next video. Okay, in this video,we are going to actually access different characters inside the string, sometimes calledindexing, the term slicing is basically more relevant to arrays, lists are actually theimmutable structures, but we will see,I'm just comparing, because you may listen this term slicing again and again, but reallythis indexing but we will see the indexing or slicing sometimes is you these two termsare used interchangeably, we will see the examples of slicing in detail in lists. And,and in more detail in NumPy arrays. But here, you just think that indexing and slicing arethe same things. index. So for example, I have this a let's say this is a array, andI want to access its fourth element here, the fourth corrector element is E. By theway, this a is a variable, if I want to access the very first corrector the the indexingthe number, the positioning starts from the integer zero, that's the first corrector.So if I want to print out of it, that will print g if I access for example, if I writethe index three, what do we mean that means the fourth element, the fourth element ishe what will be printed, what will be printed, if I access the fourth element of the indexfor a fi access this thing or space will be printed and you will be seeing nothing becausewhen a space is printed, actually, nothing colorful is printed there and you might bethinking Oh, nothing is printed, nothing, nothing has been accessed, actually a spacecorrector have been accessed. So yeah, a more we can we can we can actually access, we canactually access a substring inside a string as well. For example, we want to access forexample, a substring starting from index three, and all the way up to index eight, but doesnot include the index eight. So it will include the corrector at index three, which is hecorrectly at index four, which is space, let me write space in this way. Director at indexfive, which is Oh, correct, read index six, next record, which is F, then a space, whichis seven, and then the correct read eight. And so this is not included, to be accessed.This is included, this is inside, this is included. This is not included. So we canaccess a substring. So starting from three and ending at eight. Let's see, let's seean example. And you'll come back to this slide again, after after a few minutes. So let'ssay we have a spring as let's say, how are you? And who are you? That's it. So let'sdo that. So spring, okay. And what do we really want is we want to access for example, the,we want to access the element to access the elements, you have to write the square brackets.That's a standard notation. In Python. Whenever you have a collection and you want to accessdifferent elements, that collection might be a string that collection later on, we willsee might be a list. Maybe a tupple dictionary may be a set. Maybe a NumPy array may be apanda's structure, I mean, anything that is a collection, normally it is accessed by Ithas different elements, and we want to index them. The indexing division is square brackets.And indexing always starts from zero rather than one. In Python. There are some languagesin which the indexing starts from one for example, MATLAB, the indexing starts fromone but in Python and in several other languages. The indexing starts from zero, which has somebenefits or starting with one it has some benefits. So starting with zero is okay isokay. So let's say we want to access element at index five. The element at index five isactually the sixth element in the string starting from zero. So first, second, third, fourth,fifth, sixth, so our will be printed. So let's see. Our is printed. Let's check the let'scheck the type of this return value. Let's check the type of this this one element whichis our what is the type of it subtype of different elements in a string different charactersin a string? What are the typesSo what is the type of it. So the type is also string. So each and every corrector isalso of string type. In some other languages, the type might be a corrector. corrector isanother type, but in, in Python, each and every one character is also a string. Morethan one. correctness is also string, as long as they are accessed from a string. Okay,let's access for example, the element number three to element number, let's say eight.So the result is our so element number three, not three, actually starting from index three,which means the fourth vector, which is space, and then e, r, e, and then space, and thenwe finish. if you for example, move to from three to nine, let's say, and the the rallywill be our why or we may move to from for example, we may start from the very beginning.So for example, index zero, we may end at the index 10, but not including the 10. Sothe result is, how are you and then I mean, why Oh, and not the you included, becausethat's index number 10. And index number 10. The last index is not included. Great. Wecan have negative indices in strings as well. So a negative index is just just the indexingfrom the right side, not from the left side, for example, on negative index. So minus onepoints to the last corrector. For example, you similarly minus two points to the secondlast corrector, and so on. So minus one, that's a success, you. And similarly, we have minusthree, and that will access why, or we may have start from let's say, minus, start fromlet's say, minus eight, and go till minus three, that means go back to go back to minuseight index, and then move to minus three index, okay? And minus three. In this case,let's see what was the result are, what is that? Why are? Oh, this are, I guess thisare? Let's check it out. So this is this, you, this is minus one minus two minus three,that's an X number three. So three is not included. minus three is not included. Soit has to stop here. Okay. That's minus four minus five minus six, minus seven and minuseight. Oh, great. So that should be printed, it has printed. So let's say we have ratherthan minus eight, we start from minus 12, and be raised to minus three. So we're okay.Great. So we have negative indices as well. And by the way, this kind of fetching thiskind of substring is sometimes called slicing, I mean, we are just fetching the slicing,although the term slicing is much more popular in, in in mutable data structures. What Whatis a mutable data structure? What is an immutable data structure? Well, yeah, I should tellyou right now, you can change, you can not change any corrector in the spring. That might,that might look like a bad news for you. But once the spring is created, the elements inthe strings are not changeable. So for example, let's say at position number one, you wantto place a corrector. Let's see, that's not possible. And the reason is, the string isa data structure, the string is a variable type a data type that is immutable, immutable,are unchangeable. Once created, you cannot change its contents, they stay fixed, youcannot change them, you cannot alter them, you you cannot delete certain contents fromit. I mean, once created, it stays as it is, you can copy this into another string, youcan copy and paste, but you can get a substring and copy into another variable, for example,but the contents of s cannot be changed.So all the kinds of data types in Python that are unchangeable, the contents are not changeable.They're called immutable. And string is immutable. So so the the time slicing makes much moreI mean sense or it is more popular in the data structures that are mutable, that aremutable, although, you can use time slicing indexing both interchangeably. But it refersto roughly in reference to fetching the sub structure or substring. In this case, in thelist, it will be a sub list or so on. So that's what slicing is. Yeah. Great. Why don't wedo some more fun with this spring?Yeah,let me show you more fun with this rank, more indexing, let's say you start at index zero,you go to index 12, but not including 12. And then you jump, you take a jump of tworather than one, what we'll do is, it will fetch all the corrector starting from indexzero, all the way to index 12, but not including 12. But it will take a jump of two ratherthan taking the jump of two. So first greater than take a jump of two, then pick a corrector,then take a jump of two and then pick a corrector. So it will actually pick every other charactersstarting from zero. So let's see that. So for example, if you remember the string, that'sthe string. So it starts from h Fine, then it skips Oh, and go to W, then it skips bassand go to a then it skips R and go to E then a skip space and go to u and then it skipsOh, and go to a shoe and then the cloud achieved and we stop there. Wow. So the general wayof slicing or indexing the general way is you have a starting next start, then you havean index and then you have a step size. If you do not mention the step size. the stepsize by default is one that we were doing already. If you do not mention the end, thedefault end is the building and the total list size. If you do not mention the startthe default start is zero. For example, let me make that a comment and just practice afew for example. Let's start from zero we do not mention the start let's start fromzero and go to 12 if you do not mention the starting index that starts from the very beginningzero go till 12 Okay great. If we do not mention For example, we start from three and we donot mention the end that means go till the end starting from index three including thelast corrector Okay, if we do not mention the step for example, if you start from onego till 12 and we do not mention the step, the default step is one okay. There is oneway of reversing the string, I mean very beautiful way I mean, you do not you do not start themention and you do not mention the start, you do not mention the end, and then justtake a step of minus one in this particular way. The Start and End index they are theyare just swept and you get the string reversed way. While so that's the reverse great. Isn'tthat fancy? Yes, it is. Okay, a lot about indexing, you can find out the length of anystring by using l m function, you can find out the length of any substring if you wantto if you have a substring using again a lamp function, alien, that's okay. Okay, and nowyou've seen how to access sub strings and how we cannot change the elements of a stringbecause it is immutable, but we can access them, we can access them, we can just displaythem, we can analyze them and so on. In the next video, we will see some functions thatare supplied for string processing, what we can do with strings, I mean how can we manipulatethose strings, although we cannot manipulate the contents of a string, but we may copya string we may get explained, manipulate it and save it to another variable and howwhat kind of functions that are available in string in string data structure stringdata type. So let's see that in the next video. Hope to see you in the next video. Okay, let'ssee different functions that are available to play with the strings. In this dense stringdata structure, let's say you have the string a a lot of spaces, these are a lot of spacesat the beginning and these are a lot of spaces at the end there are some spaces in the middleas well. So, there is one function called strip all the functions of the string theyare called by taking a dot A dot something These are called methods you can loosely callthem functions, but those kind of functions that are related to some data structure andcalled with dot, they are sometimes called methods. The term method is more related toobject oriented programming actually string is a class. So all these are the methods Buteven without knowing that it's perfectly okay, you can call it method or function that'sperfectly okay. You can, I mean, it's okay. It's okay without knowing what a class iswithout knowing what an object oriented programming is, this a dot some function that operateson this a.One difference with method and function is when you call a function with a dot, and youcall some function that say, a dot strip. Then inside the definition of the function,this a object or the a variable is available, like, like you have passed that variable asan input argument. That's all you need to know about the difference of matter and function,the rest of the story is perfectly okay. Even if you don't know that that's fine. Okay,eight outstrip, it operates on a which means that a is passed in this function as justas input argument or it is available there inside the function implementation. And thenthe script function, what it does is it removes all the spaces that are in the beginning,and removes all the spaces that are at the end, and returns another string that has thathas no spaces at the beginning and no spaces at the end, and the new string is copied orcreated in a variable b, let's say whatever that we believe we can, we can have anothername of that variable. So let's see. Let's see the running form of this script functionin our friend Jupyter. notebook. So let's say a is a string variable. That's a lot ofspaces abcdef, a lot of spaces and hg gilwell, whatever. And then a lot of space, and that'sit, this is a and then we have B, let's say a dot strip. Okay, and that's sprint B. Sob is actually everything without spaces without the starting spaces. And without ending spaces,it does not hurt the spaces inside. So that's the script function, sometimes processingthe data. When we when we read the data from a file, it may have a lot of spaces at thebeginning at the end, maybe due to formatting issues or something like so and it is thisfunction is available. If we want to remove those spaces from beginning or from the end.Let's see more functions. Another function is lower, like the name suggests it actuallyit actually converts all the string to lowercase. For example, let's say we have a string, let'ssay, a B, A, let's say we have a string, a equals A, B, C, D, E, F, G, and some directors,some other directors and Q f, let's say that's a string. And now what we do is b equals adot lower. What it does is it converts all the string to lowercase. For the charactersthat are already in lowercase. It doesn't hurt it. For the characters that has nothingto do with lower uppercase, it doesn't hurt that all the characters that are not in thelowercase and can be converted to lowercase, those are converted to lowercase. And thisis available. Yeah. Great. So similarly, we have another function called upper for example,C is equal to a dot upper that the like the name suggests, it converts all the charactersto uppercase. Well, let's see more functions. Oh, there is a function replace the Replacefunction. What it does is it takes a substring and replaces that substring with another substring.Okay, let's see. For example, let's say we here we want to be have the same a, let'ssay the a is this thing. Let's say that's a and what do we want to do is we want toreplace the semi colons let's say with with with the semicolon, we want to replace thesemi colons with statics. So what we can do is we can say okay, d equals a dot replace,replace the semi colon with with let's say steric. Or, yeah, so let's see what D is.So each semicolon is replaced by a steric. By the way, if you if you want to replacefor example, a, a dark replace, if you want to replace one is there one semi colon Onesemicolon with a string. For example, the string is star star, and, and hashtag or someperson. That means one semicolon will be replaced by this, seek with this string, and the othersemicolon will also be replaced by this screen. And the result will be as expected, each semicolonwill be replaced by the screen. And that's the result what it is further if you want,for example, if you want, for example, let's say d equals a dot replace, if you want thisparticular substring, that contains the two semi colons, if you want the two semi colonsto be replaced by another substring, let's say two semi colons, let's say. And that isalso possible I mean, you, you replace one substring with another one. Right? There isone more function called split. That what it does what what the split does is, for example,you have a string, for example, let's say a equals a string, let's say, ABC, then youhave this colon, then you have d f, then you have semi colon, then you have ads g y, there'sDan semi colon, then you have y y 3223. That's it. That's your string. Let's say you readthat string from some CSV file and disappears. And now what you want, you want all thesevalues to be separated out that are that that are separated by the semicolon, maybe theseare different values, ABC is a different value, then it is separated by a semicolon semicolonmay be an indication or token that the next value started and so on. Let's say you wantto separate them, let's say you want to just split them all of them with a particular splitter.And here, let's say the splitter is semi colon. So what you can do is you can have a listand a dot split. And in the split, you can specify the corrector that that is used forsplitting after and before we split that. And remember, the split function actuallyreturns a list of strings, where this is the first element of the list, this is the secondelement of the list, this is the third element of the list, this is the fourth element ofthe list and so on. Because once you will split, you will be having different elementsthat are split it out. So if your brand for example, l we will be having a list of differentstrengths, ABC and all that, Oh, don't worry about the single code, the single core anddouble core is the same thing. Now we can access for example, the third element or ormaybe the second element by index one. And the second element here is D, E, F, and wecan work more on that. Okay. Is that it? I mean? Are these the only functions that areavailable? stripped function lower a birthplace and split function? Or is that it? That'sall the spring is about? Maybe there are more functions? How many functions are there instring? How can we use them? What are the what are the total number of functions? Whereis the list? We visit documentation? Should should we follow some book? Should we go tosome tutorial and find all the string functions and see how to use them? Well, if you wantto do that, you can do that. But there is another smart way. Let's say a is a stringthat you know, you write a dot and then a press tab, and all the things that that arethere in in string, they will they will appear in front of you on several things. You cango to this, you can go to that you can go to that and so on. So just you can check thedocumentation of a for example, if you if you press a and what it does, let's see. It'sa string object and all that stuff. Fine. It's a string. So further what we can do.So let's say a.we, press A and then we press tab. Is there anything that starts from aNope? Is there anything that starts from B? No. Is there anything that starts from C?Yes, capitalize case fold center count. These are the functions that are available thatstarts from C.Okay, let's focus on capitalized. Okay, what is that thing how to use it? That's presscolon, question mark and see what this is and what it does. Okay, so here is the documentationhere is a doc string returns capital. I used to worry enough the string capitalized versionof the string. Is that the same as upper? Maybe? So let's see. Now we know what it does.Let's just check it out, print a capitalized and see what's the result? Oh, it's got Ohno, it does not get delays the whole screen, does it? Did they the screen a was it doesnot capitalize the whole string? What What is a? Let's see what is a? A is the followingstring is the following string, so it does not capitalize the whole string. Oh, the differencebetween the capitalized maybe? And the upper? Is that the capitalize when it encounterswhen it encounters? No, no, no capitalized just capitalizes the first corrector. Letme let me read the doc string, again, returns a capitalized version of the string, morespecifically make the first corrector have uppercase and the rest lowercase. Okay, thatmeans if we have a string that has a mix of values, the capitalized will do the following.It will convert the first character to uppercase and all the rest of the characters the lowercase.Wow, that's awesome function. For example, if you have string, abs D, A, B and GG, killthat say. And then we call capitalize, capitalize, let's say. So what that does is it actuallycapitalizes the first director and all the rest of the directors there as it is. Andthere are other functions as well, a dot A dot, let's see count, what it does a dot countwhat it does not count. What is that thing? Let's check it out. Or maybe we can checkthat out using help. What is zero count? So let's see what is a load count. It's a builtin function called matters is an instance of and it returns a number of non overlappingoccurrences of a substring. Sub in Oh my God, if you I mean, that's what it what what iswritten there, non overlapping apprentice of a substring. Great Oh my god. So basically,there are there are a whole lot of functions of strings that are available, there are severaluse of the string, there are several ways of molding and playing with the strings, someof the functions that are available, some you can make your own, you can make your ownmodules on top of that, to customize your written to customize according to your requirements.A lot of these are available, and you should know how to use them. And first thing if youwant to do something with strings, or with any data type in Python, first check whethersome method is available or not. And one way to go that is just right away from here. Andother ways to go to internet and see I want to do this in Python. with strings, whetherthere is a function available or not the good chances are there will be a built in functionthat is available. And in that case, I will encourage to use that function rather thanto write your own one because using the built in function, or the method that is tied upthere will be much more faster probably than the function you will be writing at your endeven if you're too smart in algorithms. So yeah,so that's about the spring matters, there are so many other methods that are available.In the next video, we will see some more some more manipulation and processing and somemore working with strings. And then we will move to other data structures. Okay, hopeto see you in the next video. In the last video, we saw some methods of string. Andthese are just a few of them, a lot of them are available. We just we just discussed someof them. In this video we are going to talk more about strings in a particular way. Forexample, what if you want to find out whether a particular substring is there in a stringor not. Let's say you have a string and you want to know whether a particular substringis there inside a string or not? Well, you can easily find out that using the end keyword.And similarly not in means the reverse of that, or the complement of that or not ofthat. And in keyword always will return either true or Boolean or false. If it is insidethe screen, it will return true if it is not inside it will return false. So let's checkthis the implementation of that in, in, in Jupyter Notebook. So let's see. So let's saywe have a string ABC ABC. And we want to check whether this string is there in this particularstring or not. So the return value is false because ABC as a substring is no longer there.A is there. For example, here, a B is here, but ABC is no longer there. Yeah, so if we,for example, have an ABC somewhere, at least once, then the result will be true. In thelast, in the last video, or maybe in the very first video for strengths, I showed you thatyou can use plus with strings, can you compare two strings using less than or equal to? Imean, how to compare two strings, whether they are same or not, for example, ABC, that'sa that's a string ABC, I want to check whether that string is the same as ABC or not, whatwill be the result? So so so the question is, is this double equal to is used can beused for comparing two strings? Well, the answer is yes. Or what will be the meaningof less than a string as less than the other? Is that true? For example, ABC, is less than,let's say d f. Is that true? If it is true, for example, what does it really mean? Howcan we define one string is I mean, this string is less so than the other string, maybe this,maybe this operator is working based on the length of the strings. But if even if that,then this length is the same as this length. And to be more precise, we can change thatlength, for example, by just saying, okay, ABC, D, F, G, H, I, and I guess this stringwill be still smaller than the right string. So how this comparison is working? Well, Iguess the comparison is working based on the based on the alphabetic order, and you know,the alphabetic order, a B comes first and B and C and all the alphabetic order thatis there in English dictionaries. That's how the strings are working here. And the alphabeticorders for all the special characters will also be defined in Python, for example, that'sa special graduate, for example, maybe this string is this string smaller than the followingstring. Yeah, we've done for false, because there is particular ordering. In, in Pythonthat is defined for these characters that this becomes first and there's like, a becomesfirst and B, B becomes first and C and so on. So whatever the alphabetic order is, basedon that, or you can compare the two strings, no problem. So these are also available. Andthe third thing is in function that is also available to check whether a particular stringis inside a substring is inside or not to in another string. One more thing that I wantto talk about in that, for example, what if your goal is to print the following, let'ssay let's say you want to print the following, we are learning. And let's say you want toprint the string in double quotes. We are learning string here. Let's say you want toprint this, you want this string to appear in double quote, how can you do that in Python?Well, it looks like same. What's the difficulty? Let's Let's call the print function. And thenjust like here, we are learning. Then write the double quote here, scraping. And here.That's it. But there is a problem. The reason is, the reason is when we call this, whenwe write this double code, actually, the string ends here, exactly the string ends here. Andwhen we write this single code, and this double code, another string starts here. And thisis no longer a string. I mean, what it has no data type inside. Well, how can we theninsert these double quotes inside? Well, there are several ways. One way is to use escapesequence and escape sequences just like it is you use a slash and then whatever you useis considered as a corrector. Inside the string that is you're using it now if you want anotherdouble quote, you use a user corrector which is the backslash or maybe a forward slashand if you use that That means that means whatever that is coming in front of it shouldbe used as it is, rather than, rather than considering that that's a special string definingsymbol. Now in this particular case, you'll be having your double quotes available, andthe backslash will be just out, it's justifying that don't touch this double code, it hasnothing to do with defining a string. It is just because I want to highlight this word.Another more. Another more easy way is to use the single quotes, for example, we arelearning and use the double quotes as a corrector. Inside that now the single quote, whereverit starts and ends, they defined the string, everything else is correct. We do not needa escape cracker where we where we want, okay, great. But there are a lot of escape characters,for example, we have V, our backslash n, that means go to new line, we are now on an otherline. So this backslash n actually puts everything that comes after to a new line. That's anescape corrector. Similarly, we have an escape corrector, backslash D, that actually insertsa tab. Whenever we want Sophie, then a tab then now on another line, now on another tab,whatever. So there are a lot of escape characters. I'm in backslash, N, backslash t there areother. So it is good to know those. One more thing that is important. For example, let'ssay you want to print. Let's say you want to print some address on the right, let'ssee, Mac's slash back slash forward slash whatever that is called name, backslash Dr.Let's say you want to do that. And your goal was to just print that box, what will happenis this backslash n will be treated as a newline escape sequence. And backslash n will tellOkay, go to the next line and create the rest of the things. But because backslash D isnot any escape sequence, it is not listed inside, it is treated as it is and that waythis slash is also treated as a director. But here because if this slash followed bythis n, that's combination that is already there for a new line that is treated in adifferent way. If you want this to be used as a deus and you don't want these, you don'twant this behavior, you just want that all this should be greeted in a very literal orraw sense, then you should just apply and are there in our will tell, okay, that's,that's a raw string, everything inside just treat that as a raw string, there is no escapesequence inside. Great. So and there is much more about strings, we can talk but that thatwas the most important that I that I told you, at least to me, we can explore this moreactually, you should now explore the smaller What are other functions of string, how canwe play with strings in another way and stuff andso on. If I talk about strings, I can just I mean, I can give a whole course on stringsas well. But here I just give you a snapshot of strings. If you need more about strings,I mean you should be searching on internet of seeing documentations and seeing basicallywhat you want according to your requirements, search the functions probably they will beavailable. Okay. In the next video, we are going towards list topples, sets and dictionariessome other data structures that we were talking about earlier, we will be going to explorethem in more detail from the next video. Hope to see you in the next video data structureinformally or in a very naive sense is basically a collection of a lot of basic data typesthat contains data one structure contain a lot of data. And we can define sometimes severalmethods and several specialized kind of functions are customized and define just because ofthat data structure to perform efficiently different kinds of I mean for different kindsof tasks, we may have to define or we may have to choose different kinds of data structures.The basic data structures that are available in Python is a list tupple set and dictionary.These are the basic data structures that are available. We can create our own data structuresif we want to. But most of the problems almost all of the problems mostly they are solvedby these four basic data structures. Although a lot of these are not that efficient. Thereare efficient ways for customized kind of problems, we will see that efficiency whenwe will deal with the package NumPy that is, that is faster than all of these, but willbut we will see what kind of constraints are there to make it faster. Anyways, data setin a very loose term is collection, it is a collection of a lot of values a lot of datainside. And all these data structures list tupple set and dictionary, they they are acollection of data of heterogeneous types, which means one value can be integer anotherelement let me call an element, another element or item, another item or element can be ofstring type, another element can be off, let's say floating point number another elementis a whole list itself another element is a topple and so on. So different elementscan be of different types. And that makes this heterogeneity that makes these four datastructures much more applicable and much more abstract. And they can be applied to almostall the problems. So let's see one by one and let's compare them together because thebest way to understand four of these is just to compare them which can do what as comparedto the rest. So let's let's compare them and learn how can we use those in detail. So listfirst is list list is ordered ordered here means it is indexable which means there isa particular element number one is at position one element, there is an ordering of elementsfirst element second third 25th element, there is an ordering of element with respect totheir position. So that's what we mean by ordered changeable or sometimes called moremore reasonable term or more usable term is mutable. mutable means once the list is createdas contrast to string, once the list is created, you can change its elements for example, youcan change the third element with another element and that's perfectly fine you canchange it that what we mean by changeable or more popularly called as mutable duplicatesmeans the list can contain more than one one element more than two, I mean, at the positionnumber three, you can have the same item and position number five you can have the sameitem that so the duplicates are allowed tupple however, although ordered, there there isan ordering of elements there is there are indices of different elements, this is immutable,you can once topple is created like strings. Once the template is created, you cannot changedifferent elements in the tupple you have to create a new topple if you want to, butyou cannot change the items in the tupple and the duplicates are allowed again set onthe other hand is unordered which means there is no indexing there is no positioning, thereis no first element there is no third element, there is no Fifth Element, there is that'sa collection without it without actually indexingbecause you cannot access a particular element with index you cannot change it, but whatyou can do it you can insert more elements and you can remove existing elements if youwant to. Again, the set like in mathematics sets does not contain any duplicates. So oneitem appears just once we will see the examples Dictionary of very, very, very powerful datastructure. Again, it is it is dictionary is just like a set, it's a set it is unordered.Again, chancer bow, you can change them but you can change the items you can and the dictionarythe pocket and it does not have duplicates, because it's it's basically a set it is justlike I said, the power of dictionary is each item consists of consists of a pair and oneone value in the beer is called key and another is called the value for example, well is keyfor 12 name is key for band and and so on. So we have seen this dictionary before inloops and stuff in just a very loose way. But then that's really a very, very powerfuldata structure. And later on we will see in pandas basically all the data is basicallymanaged, just like a dictionary if you if you have a good knowledge of dictionary, youwill be having a very good grip very quickly on on a Big Data Science Library or Big DataScience package which is called pandas because each and everything in pandas is handled justlike you're handling a dictionary. So it's it's a really powerful data structure to knowabout.So, so solist is mutable dictionary is mutable set is mutable, in a sense that you can insertand remove elements. topple is not mutable. And that's a comparison theoretically Whatis there, all these types, each and every of them is a collection of different values.And the values can have different types. That's the that's the abstract power of all thesedata structures. So, in the next video, we will, we will, we will actually try to geta good grip on list topple set in dictionary and we will actually define them code andaccess different methods of those and we will be we will be trying to become comfortablewith with these data structures by coding them in Python. So hope to see you in thenext video. Okay, continue in previous video we were talking about data structures in thelast video. So let's go to the Jupyter Notebook and see how a list can be defined or declaredhow a tuple can be defined or declared set and dictionary, let's see how can we makethese data structures in Python? So then one by one, we will compare how can we accesselements of the list? How can we insert more elements in lists tuples are in dictionaryand and see the comparisons of all these one by one operation by operation. So let's see.So let's go to Jupyter Notebook, our friend this file is getting lengthy, lengthy, let'slet's make multiple files. Let's say this is part one. Just save it. And let's makeanother let's make another file. For example, let's just close this file, or maybe stateopened, let's close this file and make another file. Python three. Yeah, so let's name thatfile as this part two, let's start a new file that that file was on in that was okay tostay with that file as well. But just let's make another file. Okay. So that's just havea markdown cell. And let's have a heading. data structures. Remember the markdown cells,I just introduced them introduce those just in the very beginning. And then we just forgetthem. Because writing these description again, and again, we'll make the video length here.And the purpose is not to actually format the notebook, the purpose is just to showyou the power of Python. So I just omitted writing these descriptions more and more,but just write a few descriptions in the star and then we will forget again. Oh, that'sit. That's amazing. Let's see, find a list. So list. Any variable name, that's a variablein the list is, let's say this. You define this by square brackets and different elementsthey are separated by comma, that's a 134, point nine. Name anything I mean, or five,or maybe maybe three again. So that's the list. Okay. ductile, on the other hand, isdefined using parentheses. So let's say 134. point nine. That's the name. And that's athree again, that's okay, that's a tupple. A tupple is defined in. So when you writeparentheses, that means by default that topple the variable name has I mean, if you havewritten t that has nothing to do that it's a tupple. That's because the Python is dynamicallytyped. When you will write the parentheses that means the tupple is being defined. Let'sdefine a set Let's call the variable as S, the set is defined with with these curly brackets.So let's say 134.point nine, I want to tell you that all these things they can contain each element can havea different type. But then, even if we include this three again, because the set cannot containthe duplicates, later on, we will see only one copy of three will be there in the set,the other will, even if we want to include it will not be included. Okay? Then let'ssay a dictionary. dictionary is again defined like a set, but but each element is a pair,separated by a colon. Let's say the key value is 23 as a key value, that's the key and thevalue. Here is a string, let's saytwo,three, that's let's see the value. Now comma. Now one element is there. This one elementthat consists of key and value pair, another element, another element may have a key withstring. So so the keys can be of different types, the values can be of different types,and so abstract. So the key is, let's say, let's say B. and the value for this is, let'ssay 43, then maybe we can have another key value pair with key as, let's say, c. andthe value is, let's say, cc. CCD. That's a charge coupled device. Okay, anyways, so.So again, now you know how to define less how to define a topper, how to define a set,and how to define a dictionary. The difference is, is the main difference here is in dictionary,because one element consists of two values rather than one. Okay, let's print that andsee the types let's print all the types sprint died off. So let's paint them. That type ofL is. So the table L is just printed. That's L, let's print that. Let's see the other types,let's print the rest as well. So just copy them and B is the type of list L is that thetype of topple is D. And that's a D, then we have s and then we can just replace thisto the s. And then we have, let's say, D dictionary. And that's, that's D. Okay, so that's been,so the type of L is less the type of t is topple the time of s is set. The dive of Dis dictionary. Oh, great. So that's how you can define these lists. You can define listyou can find topple, you can define set, and you can define dictionary, no problem. Next,let's see how to access different elements from from these data structures. What arethe way for example, to access an element from a list, let's say the element numberelement that indexed with one remember the element that index with one is element numbertwo, because indexing starts from zero. So you can access that using the square brackets.If you want to access from topple again from the square brackets exactly like the list.In set, for example, you cannot index it because the set has no ordering. First, second thirdelement is no longer there. But you can you can, you can check whether a particular elementis there in the set or not using in keyword. In dictionary, for example, if you want tocheck whether a particular element or if you want to access value, for a particular key,you just create the dictionary variable name and then write the key and it will returnthe value. Okay, so let's practice this in in Jupiter. Let's just practice this in Jupiter.So let's say list value at index one. So that's brand new, this list added next one, the valueshould be printed as three brand topple at index one, again, the way of accessing thesame Brent Brent, whether three in s or not, the return value will be the return valuewill be true or false. So print will be true or false. And then print the and just accessthe value with the key 23. So let's see what happens. So l added index one is three tierindex one is three s, three years in S Yes.And what is the value with the key 23? The value is the value is two three. Let me justdescribe more about this D. What is the value at index B for example, now we have to givethe index B in the string format. That's 43. Yeah, so that's how we can access that. Let'ssprint s also let's see s because when we have defined as we have defined this duplicatethree But if you see the elements of s, there are no duplicates. And it does not maintaineven any ordering, I mean, we have defined s in a different way, it is maintaining everythingmaybe in a different way, one three. Yeah, oh, the ordering this way is the same, butthere is no index for the first or second or third element and so on. Okay, so that'sabout the defining, declaring or accessing different elements. In the next video, wewill see more about about the data structures actually, actually want to spend some timeon the data structures because that will be a basic building block for for the data sciencepackages, too. If we if we know very well about these data structures, these data structures,we will be very fluent in the data science packages and working with those. Okay, hopeto see you in the next video. Okay, in the last video, we define less topple set anddictionary and we actually access different values. In this video, I'm going to actually,I'm going to actually introduce more indexing, how to access list and topple in particular,because the both are very, very easily indexable like strings. And I want to show you thatall kinds of indexing that you have seen in strings, exactly works and list as well asin tupple. So let's go to Jupiter, and see what a list is, for example, a list, if youprint the list, that's the list, it has these kinds of values, if you just see the list,for example, starting from index one, ending at index three, that that means the same biga slice for example. So index one value is three, index to value is 4.9. And the lastelement is not included. So, if you get that you get three and 4.9. So exactly the same,the same kind of indexing that you have seen in strings, exactly there is working hereas well. So for example, if I say list, start from the beginning go to N but then I justgive minus one it will reverse the whole list, I mean the whole list will be reversed. I'min all the same all the things that that we saw in in string indexing stays exactly thesame in list as well as in topple, so topple For example, let's access element from let'ssay from the very beginning till the till the third element, that's not the third elementtill index three, which is actually the fourth element. So topple unless they are exactlythey will be exactly index as as it as it is. So all the slicing all the indexing allthe sub sub listings, all all the sub topples, they can be accessed exactly the same wayas you as you've gone through through the through the strings. One difference here thatI will explain later on, because list is mutable it is changeable, I will discuss one thingthat one use when you slice it, when you get a sub list then actually it refers to thesame memory and if you change the sub list contents, the actual list chord changes. Thatis that is true for list in slicing. And that is true for sets and dictionaries, in thecopying the references and so on. So I will discuss that later on. But rest of the thingsare roughly the same as as they're in string indexing. Actually, indexing is almost thesame everywhere in Python, it has this kind of slicing is almost the same if you knowthe index, how to index planes, you know how to index lists, if you know how to index lists,you know how to index couples and strings and, and everything. And by the way, if youknow how to index strength lists, you will be very fluent and NumPy. That's the verypowerful data structure. That's very powerful kind of array processing package. with withwith some defenses that we will see buteven the indexing is same in pandas when you are working with large amount of data datafile and stuff like so the indexing is more or less the same that you've seen in instrumentswe will we will cover indexing, masking and fancy kind of indexing in much more detailin NumPy. But this stays the same as, as you've seen in in, in strengths Okay, so now canwe can we expand the list can we add more elements? Can we insert more elements to thelist? The answer is yes. Because list is changeable. New trouble you can insert more elements.One way of inserting there is just to call an add operator, you can just add plus andyou just insert in other lists like like two strings are concatenated by plus two listscan be concatenated, or combined together again by plus, but there is a faster functioncalled append l dot append. That is sometimes faster than using this operator we will seethat topple because it is immutable. You cannot touch any content of the double you cannotactually insert any element to a topple you cannot delete any element to a tupple. Thereare workarounds for example, convert a tupple to a last change it then convert the listto a tupple. There are ways to do that. But tupple in its true sense, in the literal sense,it is immutable. You cannot insert any elements you cannot delete any element you cannot changeany element. However, you can combine two tuples. Together, you can concatenate twotuples together again by plus operator and save the result into a new double that's possibleset. The you can insert elements using an add function add function allows you to justinsert one element. If you want to insert more than one elements, then you can callan update function that actually accepts more than one that accepts another set that needto be inserted. That's possible dictionary, you can insert a new key by just the new keyequals to that you just assign a new value to a new key and key value pair is just insertedthere great, you can delete or remove any element from the list using D l Command Dl l one that means the this particular element is deleted from the list that is possible.Deleting particular element from the tupple is not possible However, you can delete thewhole variable whole topple that is possible, you can remove elements from the set usingremove function as dot remove, and then you just give the element that you want to removethat as possible, it will be removed and you can delete the whole delete the whole variablethat is always available. Similarly, you can delete a particular item from the dictionaryby just deleting by just calling the D of the value for example, whatever the key is,so you call with the key and call the Delete and it will delete everything I want to mentionhere for to remove items from the list there are other methods and functions that are alsoavailable that I mean there is a remove function, there is a pop function, these are available.Similarly, from removing elements from the dictionary, there are other functions thatare available. But just to compare them together, I am using this de l command, although thereare other ways of doing the same stuff, as well. So let's let's let's let's end thisvideo here. And in the next video, I will show you all these operations that concatenatingtogether, inserting more elements, deleting different elements, I will show you all thesethings in in Python. So So hope to see you in the next video. Okay, in the last video,we saw how to insert different elements to different data structures. And we for example,in the case of tuples, it is not possible. And we also saw how to how to actually deletedifferent elements wherever possible. So let's go to our friend Jupyter Notebook and seeall these concepts in a running form. So let's go. Okay, so let's say for example, we havelist, that's our list. Let's append an element to the list or maybe more elements, that isL plus. Let's say we can have another list for example, howarethat's six, and then you that's and these two lists will be appended and the new listwill be as you can see this similarly we can append an item using append function for example6.8 that will also be appended and this will contain these kind of values. So yeah, soboth arrays are fine. This plus is this plus can be used to append to append to lists andthis append function can be used to simply append a list with a with an element. Okay,great topples. You cannot change the topple, you cannot change the topple. But what youcan do is you can have two tuples for example, T two is a different couple. Let's say a Aand B, and let's say you have four or five, that's it that's supposed to, then you canhave a third double, that is just the combination of double one and double two. And in thiscase, you have double three, which is this. Yeah, so double one and double two are combinedtogether, but you cannot actually insert into the assembly, the tuple is immutable, youcannot insert another element, you cannot delete existing elements, you cannot updateany element and so on. Similarly, as the set, let's see the state of the set, that's theset set God add function, you can add anything, let's if the six that is added there, andthe new state of assets this, or you can call the update function. If you update method,if you want to insert more elements, for example, if you have multiple elements to be inserted23. Again, and let's say you wanted to insert an element that is already there. So for example,one, then the duplicates will no longer be there, but the new elements will be inserted.Now let's see the state of D, the state of D is this. If you want to add another keyvalue pair, you can add a key here, for example, the key might be new key, for example, newkey and the value might be the value might be, for example, a new value. Well, and nowif you see D, the D, the contents of the D has changed. Well, that's simple. Yeah, great.Can you concatenate two dictionaries together using a plus operator? Is it possible? Isit possible to concatenate two dictionaries together? Let's see I have another I haveanother dictionaries dictionary D two. That is that say the key is why. and the valueis why why? And then we have another key letter Z. and the value is. Let's sit down, can Ican get an A D and D two together? Can I? Can I just update my D and add these values?insert these values also there? Okay. I left you with this question. You try to answerthis. And in the next video will answer this question. But try to answer this questionyourself. And one way to try that is just to go in Jupiter and just dive and check whetherplus is working or not. Or maybe there is another method and stuff like so. Okay, great.Hope to see you. Oh, I have not used the D l delete and all that stuff, and so on. Sothis question is there, let me use the removing the elements. So let's say l is this list.If I want to remove an element, let's say element number three, if I want to removeelement at index three, which is this string name, I can use simply this delete. And theL is everything but without that element. Similarly, I can remove if I want to removeany element from S, I can call the function remove. And whatever I want to remove, let'ssay want to remove game, and the game will no longer be there.Great. If I want to remove some element from dictionary, again, let's say that's the that'sthe view of dictionary. I can call the Add I can I can remove the element with key let'ssay C, whatever the element is with key C, delete that element, and the dictionary hasthis particular state with this item, this particular item is gone. Okay, great. I cando that. But But d L is not the only way of doing that. There are so many methods. I mean,a lot of methods to do that. But just to just to compare all these, I'm just giving youthe most similarities and differences wherever available. Okay, great. So I have asked youa question in this particular video. Can we concatenate two dictionaries together, particularlywith a plus operator? If yes, then we are done. If not, then Are there other ways andstuff like so that's the question. So hope to see you in the next video with more onthese data structures.Okay, I asked you a question last time. Can we concatenate this two dictionaries togetherwith a plus operator? So what's your answer? Yes or no? The answer is Nope, yeah, so wecannot concatenate them together, we cannot insert another dictionary to this dictionaryusing a plus operator. Because this plus operator is not defined for dictionary, what we cando is we can call an update function, because dictionary is also a set, I mean, a set ofkey value pairs. But at the end of the day, it's a set with specialized function, of course,but we can call update functions, and insert the whole new dictionary inside dictionaryas as as follows. Yeah, so the answer is using plus operator No, but there is a way usingupdate method. Right. So next, we focus on the copy function, the copy function is availablefor less the copy function is available for set, the copy function is available for dictionary.So let's see the need of this copy function here, I want you to be very careful. Becausethat's, that's really important. Let's say we have a list, let's say, That's list. Andby the way, the same goes with set and dictionary as well, whatever I'm going to do with list,let's see a list. Now, what you do is you copy the list or you just make another variable,like you can assign the value of l to another variable l two, what you do is that now ltwo is also has this, now these are two different variables, L is this variable, l two is thisvariable. So you might be thinking l two is separately a completely a new thing. And Alicenew thing, you might be thinking that both are independent. But Python internally managesthe data structures, most of the data structures in a way that because the data structure isa collection of a lot of data it has it is consuming a lot of memory, what it does iswhen you assign a variable, or data structure to to another variable, it does not actuallycopy all the contents, it does not actually make a new memory, and store the contentsin this. It actually this variable also actually points to the same memory as this. and and,and and the consequence of that if you change any value, for example, in L two, let's sayyou change the index to value from this, the index to values 4.9. Now you're working inL two, let's say you change this L to value from 4.9. To Let's 4.9. Let's see you do that.So you might be thinking that this happens in L two, well, in L two, that has happened.But what it also does is it does the same thing in L as well. So l also changes. Thereason is L and L two, they both are pointing to this structure in the memory. And whetheryou approach that structure through L, or you approach that structure two l two, you'reapproaching the same memory anyway. And that is called referencing I mean, it does notcreate the data, it actually create a reference in the memory to actually create a new namefor the same memory. And both are pointing to or accessing to the same memory. And ifyou really want the behavior so that l two becomes different than L and what I what Ido with L two, that should not affect L, then you should call copy function. l two is Ldot copy. Yeah. So that's the function, I'll copy. Now you have l two. Now you do whateverwith L two, it will not affect L. So l two, for example, index at index two, you againsay okay, this is 4.9. So l two changes. Now, l two changes, but l doesn't change, l doesn'tchange, l stays the same. Now this is different copy, same concept, go with the set. And sameconcept go with with the dictionary. If you if you just make another way will s two nequals two s, then if you change the contents of s two s will change. If you don't wantthat, then copy it similarly copy the dictionary, because the contents of the topple they arenot changeable. The copy function is not available for double. Because even if you assign thisT to T two, you can now not change D two because it is immutable. So having a copy functiondoesn't make sense in tupple. Wait.One more thing regarding slicing. Let's say you have let's say you have Dell that's availableto you like so that's L and let's say you make l three another list by slicing Let'ssay a list from let's say one to five, let's say. So you start from index one, which isthree, and you go to five by not including five, this way, the L three is automaticallya copy, it is not a sub list, which is referencing. So l three. So l three is a different l twois a completely new list, a new memory view, if you change the contents in L, three, ifyou change the contents in L three, for example, l three, or index zero, it should go fromthree to let's say, three, if you change the contents in L three, these contents, thesechange will not reflect an L. So if you do the slicing, slicing picks a copy by default,it does not pick a reference. And that's a huge difference between this list and a NumPyarray, when you end it, we'll see that when we will see a NumPy array, the slicing actuallyalso, again refers to the same memory location. And that might be one difference in indexing,indexing in the whole Python, whenever you do slicing, you get a copy. But in NumPy,when we'll see NumPy in detail, in NumPy, when you do slicing, you get again a viewnot a copy, and if you change in the slice torian anything the actual the actual contentsalso changed. And there is a reason to do that there is a there are efficient reasonsto do that and stuff like so, again, the dot copy function becomes the copy function becomemuch more applicable there as well. So, so, so you need to know that even if you do ifyou do slicing in general in Python in any collection in any array, in any, if you doselect a collection for even for mutable objects like list, you get a copy, but in NumPy array,the things the things these things, this particular thing with with a lot of other things thisbut this indexing scheme actually changing, changes with with this kind of slicing. Okay,so I am this video here, I mean, you can explore much more functions of lists tupple, sevendictionary and what you can do with each of them, and what you I mean, in which scenario,what kind of thing is more suitable for the other that completely depends upon the problemat hand. But what we can do in what what we will do what we'll be doing in the less nextvideo, we will be seeing some using some functions of just list. And then I will be just justletting you to explore the the tupple set and dictionary and all their functions onyour own. And to see what function or what method is doing what for what, which kindof data structure. So in the next video, we will be seeing some methods just for listdata structure. Hope to see you in the next video. Like in screens. Let's Let's explorea lot of functions in list. Although in, in in sets and dictionaries and tuples tuples,as well. But many more functions are available in list. And by the way, let's see how manythings are there in this list. And let's say l dot tab, and tab will open up a lot of thingswith me for me abanda we know already clear copy, copy, we know already count, we don'tknow count, extend, index insert, pop remove reverse some of these functions. They makesense by the adjuster name. But let's see one by one. Let's see some of those. Whatthey do. One way to do that is go to internet and see some book or tutorial or somethinglike So another way is just write this apply. Maybe, maybe help function maybe apply a helpfunction, it may help you how to use that. Great this help function is great. So abandonedobject method of building list in stance about an object to end of the list. Oh, it appendsan object to the end of the list. Which meanswe may be able to append another list to to a list maybe. Have you thought about that.The append method just takes 111 object. Maybe it takes a whole lot of list. But then itmay be possible that a list is appended inside another list and that whole list becomes becomesone element because list can contain other lists as elements are that's a problem. Yeah.So let's see more functions. Yeah, so let's see clear what this clear What is this clearwhat it does? Sometimes I use help, sometimes it's used that remove all items from the list,oh my god, if you call the clear that the list is empty, okay? If you just call clearfunction on a list will become empty. Be careful. Okay, great. What else? So that see I havethis function maybe, Bob, what does Bob does watch. So let's see. So Bob removes and returnsitem at index defaulted the last, which means if you also that's the default value rememberthe default value. So, if you call a part function without an index, it will returnit will remove the index it will delete the last item and it will give you that it willreturn that are if you give an index, it will remove that value at that index. And it willafter removing it will return you that. So you can use it wherever you want. So thereare many more functions for example, you can see all of them one by one remove function,for example, reverse reverse, like, like, like the name suggests, if you call the reversefunction, the list will be reversed. Yeah, and remember, we have reversed the list inthe following way as well, we have a way of reversing any way, this way. So now if yousee the list is again reversed. So I guess both of them are working like so same. Similarly,you can explore several functions from a set, you go and say add Clear. Clear might be workingas same as intersection intersection and update is destroyed is a subset of the other. Yeah,add by default or update by default, actually take a union. So I'm not seeing update function.Here it is update. Oh, union is there update is there, which means the list you're seeingis here is not a complete list you may be writing, what are the functions that startfrom you. So here are the and and several others. Similarly, you can go to dictionaryand call for several functions clear copy from keys get items. That item might be mightbe interesting. What is this item? what it does? Oh, it has an error? What? So how canyou use this? How can you use this function? Let's see, oh, this is just an object, itis not a function? I don't know.Let's see again, are it is not listed anywhere? Oh, it is items not item. Okay, items. That'sa function maybe. So these are all the items 23 with this, be with that new key with that,and so on. Great. So actually, the purpose here is not to tell you each and every function,what it does, it will take a whole lot of time. You can go and explore all these functions.The purpose here is to tell you what kind of data structure has, what kind of propertiesand what are the similarities and differences in between. So if you remember this one slide,for list, double seven dictionary and some text that is written out above, you'll behaving very good knowledge of where to pick what kind of data structure in practice. Soin the next video, I'll be actually going to Jupyter Notebook as our as our style andI will be coding or solving some problem for you that will involve list topple set or dictionaryare one of them or we will be choosing based on problem what kind of data structure iswell and what so we'll be doing that. But before that, I just want to I just want toI just want to mention that list tupple set or dictionary they can contain any items insideany kind of type, which means a list can contain another list. A list can contain a set a listcan contain a dictionary, a list of dictionary can contain a list which itself contains adictionary, I mean, this is all abstract, this is all abstract, one thing can containthe other one thing can contain an instance of I mean, a list can contain multiple lists.And those lists can contain more or less and so on. So before actually going to problemsolving, let me give you a flavor of that how abstract these things are. Let me giveyou a flavor of that in in just just in a couple of examples. So in the next video I'llbe giving you a couple of examples based on the abstract mess of these data structures.And from the next next video, we'll be probably, we will be doing some problem solving basedon that. So next two videos are completely on Jupyter notebooks. So get ready, I hopeto see you in the next video. Okay, let's see the abstractness of all these data structures.Let's see just one example. Let's say we have l as the list, we have all rich top all thatstuff. So let's say we have set that set, let's say n, we have dictionary, that's adictionary. Okay? So let's say we have all these things that say available somewhere.So let's make another dictionary. For example, let's say D, D, Ma, that's a D tool. And thatdictionary has key value pairs less The key is a and the value is whole list l mastervalue is possible. Let's say the key is B. and the value is just to topple the wholetopple, that's the value. Let's say the key is C, and the value is the set. And let'ssay the key is D, and the value is the dictionary, the whole dictionary D it is possible. I mean,you can just do that, that that is just one example, oh, what's Oh sorry, I should haveI should have incorporated this way. Okay, so this is possible. Now, for example, ifI access, if I access the element with, let's say, a, I will, I will get the whole list.And not only that, I can again access the whole element. And then after that, for thatelement, I can access for example, the third element, the element at index three. So thisparticular, this particular first level will extract the list. And that will in that isjust the indexing or for that list. See, for example, ifI access D two, and inside the tool, if I access the dictionary that is inside, andlet's say I save that dictionary in k, then it I can see the contents of K but I can justfor example, this or I can just access all elements of this dictionary, or k by justhaving 4x in gay brand, for example, x and k of x, just do that i can i can just do thatwe have done that in loops as well. So I want to tell you that the these even if for example,if you want to create a list l let's say l three let's say you want to create a listthat can contain a whole list that can contain what will get Oh, I mean one element is thelist another element is to pull another element is the whole dictionary inside and then youhave some other elements let's Lee's game and that's perfectly fine i get i mean youcan do that, these data structures are much more abstract I mean now if you for example,access element at index two which is dictionary, that is completely a dictionary if you ifyou check the type of that element that that will be a dictionary object and you can extractthat element and play the way you want to play and whatever. One more thing if you can,for example lists we can let's say we want to make a list list very quickly for examplelist off all the squares till till starting from zero list of all the squares till till10 for example zero square one square to square let's say we want a list of that. So one wayof doing that is a quick shortcut is to just use the loops so in loops, for example, weright okay, x square for x in range. Then for example, so it will start from zero gotill nine, including nine and you will get x one by one. And all this index is for makinga list of x squares where x starts from zero and go to go to including nine go to nineone by one and that's how you can make a list and I'm in these kind of these are kind ofshortcuts. Again, you can make a sale For example, let's say you want to make a setof all the squares for x in range, let's say, starting from starting from two, ending at20. And you want to take a step of, let's say three. So, start from index two go till20 do not include 20, but take the step of three, and you can now have a set, which iswhich is this. I mean, there are, there are a lot of ways of working these working withthese. One, one can explore more and more about these things, but what what what thebasic thing about these data structures are, they are very, very abstract, they can I mean,a list can contain a dictionary, and that dictionary can contain a topple and that willhave an element which is another list and so on. It is that abstract, it allows youto do each and everything in that way. Okay, so I end this video here in the next video,we will actually solve a problem using these one of these data structures or we will tryto choose one of those. And that video naby lengthy may be small, because we may havebugs inside. And we will we will play around with these data structures in the next video.So do attend the next video because it's really the practice and you will get your hands youwill get a very good grip on the data structures in the solving the next problem that we arethat we are launching for you, okay, hope to see you in the next video. Okay, let'ssee a problem just to get comfortable with these data structures. So let's let's designsome problem and solve that problem here using using these data structures. So the problemthat I'm thinking is, let's say the following. Let's say let's say you are you a teacher,should I type all these things? Okay? Let's say you're a teacher, you are a teacher. Andyou havedifferent student records to learn records containing containing ID of a student andthe mark marks list in each subject, where different students have taken different numberof subjects. And all these records all these records are in hardcopy. You want odd copy,you want to enter all the data in computer and want to compute the average marks of eachstudent. And display. That's the problem. So the problem let's say is, you have forexample, you have a hardcopy you have you have some papers, upon which you have differentstudents, each student have a different ID. Some students may have taken seven subjects,some student may have taken three subjects, some student may have taken eight subjectsand so on different students may have taken different subjects. Regardless there, youwant to first enter each for each student, you want to first enter the records, I meanall the data that is in and then you want to compute from that data, you want to computethe average marks of each student. For example, if a student have taken five subjects, thenthe marks for all the five subjects are available, you just add all the marks and divide by fiveand that's, let's say, the average marks. So first of all, let's ride away two way tocompute for example, the to just collect the data, how to collect the data. So let's writea function for that. So let's say define a function, let's say get data From user orteacher, let's say, let's say that function, and it returns data. Okay? So what I do reallyis I say, okay, whiletrue,I made a loop while true, just take the data from the from the user, and the data is inthe form of you first say, okay, ID, student ID, let's say that is inter, or actually input,enter student ID. So he enters the the person enters the student ID. Yeah. So adopt, youmight have define a dictionary, maybe a dictionary D, that is empty right now. But you may, youmay add and remove different values. So what you do is, you add a student ID, you get astudent ID, and in the string form, and then you get the you get, for example, the inputas the marks list. So marks list as input. Enter the marks,bycommaseparated values. So enter the marks using for example, if you have five subjects, justwrite the five subject marks by separating each with the comma, okay, then this, let'sseemorestudents is equal to let's say input,enter,yes, or no.foradding more students, so if for example, you have more data to insert, then press Yes,otherwise personnel. So that's, for example, our setup. So we will keep on getting moreand more, we will keep on getting more and more data from the user user will keep onincreasing the data. But one thing that we must know is that if for example, a studentID, student ID is already in D, if that is already in D, then we should give a messagebrand. brand that student ID is already inserted. So that might be a message else. ls we wantto do something else, what we want to do is the following. What we want to do else iswe will make a dictionary, we already have a dictionary with a student ID as our key,that's our key. And at that key, what we do is be the pick the marks list, and just splitit using comma because you're expecting and all the marks they will be saved as a list.So that will return a list. List of string values. These are not indeed values, theseare string values. But all these lists they are tagged by this ID. So that is a dictionarythat will be that we'll be getting populated on and on and on. Further if we check F forexample, more students dot lower, for example, let's call the lower function because theuser may interest at a lower form or if that is equal to let's say no, that is equal toNo, if this is the case, or if there is no enter for example.Nointer no inter Know, to quit when insertion, insertion into node with insertion. So let'ssay that's your message. So wherever the user inserted, if that's a no, then you returnthe and that's it. Otherwise, you keep on moving. So that's the whole goal. So you keepon asking the, the, you keep on asking more and more values. If whenever the teacher entersa no, then you just return. Otherwise, you keep an up, you make another equation, youmake another equation and keep on moving. That's how you get the data. So the data willbe available to you. Once you are done with that, then after that, we will see how toonce we have this data collected from the user, then we will see how to compute marksfor each student individually average marks and so on. So let's just check whether thisfunction works or not. So let's say we have our dictionary that says student student datais equal to get data from user, let's just call that function. Let's see what happens.Okay. Enter student ID, let's say ID is 12. Okay, in remarks by comma separated values,let's say, well, one, let's say24,comma 65, comma 87, let's say the first two in just the first tool and just have thesethree subjects, then internode width, so I will enter something else. And oh, what'sthe problem? There is a problem. If more students taught lower is more student is not defined.More student that's, I guess, more students, more student here, oh, the spelling mistakes.That's a huge mistake. So I just copy there, these bugs are there. That's part of life.Part of programming life, actually. So I guess now it will work. So let's do the processagain. So 12, let's say, and the marks are the six comma 45, comma, let's say a bad subjectwith let's say, 13. into no to quit. No, I will intro something else, I will keep onmoving. The other student is the student ID is 45, let's say. And the marks that thisstudent has gained, actually, let's say this student has, has registered has already registeredseven subject or let's say five subjects. And the marks are, let's say 44 to five, sixto 677. And let's see a bad subject, let's say four. Okay, then internodal, quit. No,I want to insert one more, so do anything else other than No. So student ID, let's saynow the student ID is 12. Again, let's say, let's say want to insert another ID again.And whatever the marks, let's say 45, and 45. Again, that's a now internode width, nosomething else. But now, the message is there, the 12 is already inserted, because the IDthe key value index, now you cannot repeat, and so is the student value. So it does notinserted the because this may be my mistake, so it asks again. So now let's say I enterID, let's say 23. That's the ID or maybe a different ID. That's the ID and the marksare let's say 45, comma, 45. That's it. And internodal grid. So let's say I enter No.And that's it. So now I have received the student data, if I show you the student data,that student data is student data. That's a dictionary, that's a dictionary with thewith key 12. And that's a list. But this list contains all the values that are our stringtype, we will see how to handle that. That's a 45 as a key value, that's ID and that'sthe marks list. And that's the ID in that small list. Okay, great. Now we have studentdata. Let's write another function that helps us working on the student data, basically,we want to find out the average marks of each student. And then we want to print those.So let's define another function and get average marks of each student. And that function actuallyreceives this dictionary, let me call it as D, any any variable, that's a local variable.Okay, so what we want to do with that is the following. Average marks for each student's,so we will define another dictionary, let's see everage marks dictionary, let's say thatis empty in the beginning, maybe, and then what we do for x in D, let's icreate overx and d, what we really do is we go to the we find out the list of located at ELLs arelocated at x L is basically D sub x. So that's it, that's our list. That's our list thatis located there. So then what we do for i in L. So for all i that is an L or let mecall it for marks, marks in L. In this particular list, what you do is you actually have thissum of sum is equal to zero right now,there is no marks. So what you do is s plus equals two marks, but convert the marks tointeger because they are already in string format. We have we have saved everything instinctstring format, so you populate all the list. Once you are done with this loop, the S willcontain the sum of all the marks, then what you do is you compute the average and justsave that average in ABG. Marks decked dictionary, let's say on average marks, just just don'tuse the word deck, for example, you can but let's stay gradual and add x, you just writethe average marks. And the average marks can can be computed by s divided by length ofthe list, whatever the list is. So that's what the list is. Yeah, so that's the averagemarks. And once you have an N one by one, all the average marks will be populated. Andonce we receive all these, we will then begin then we can then just display by populatingthe average marks. So let's see, let's call that function. So let's call that function.So ABG marks for example, equals to get a VG marks, and let's bond these student datainside. And if there is no error, then it will return everything. Then just print theaverage marks for each student for x in a Vgm. brand, let's say student and Brand XGod average marks as then you just Brandt okay ABG m of x, x, and that will displayeverything Oh, if there is an error, non type object is not equipped. I prefer nine typeobject why non time object? We have done some mistake. Yes. Maybe. Let's see. Let's see,for example, when we run this, so let's run this and create a cell Let's run using altEnter to create a cell everage m What is that thing? Oh, that's nothing. Why oh, we haven'treturned anything. That's a bad programming. Really bad programming. We have not returnedactually. The the value that we need. So the default value is none. raid actually not sogreat. Okay, great. You have this and now we have something in Emirates marks. Yes,this is and now we can just populate that and we have this student 12 got average marks38 student 45 core average marks 90 49.2 and student 20 He got average marks as 45.0 Okay,great. So that was just a review of split function of string, type and marine throughint, and functions in general input function, and, and dictionary and list and all thatstuff. So although it was a just a tiny problem, but it gives a good flavor of the data structuresand strings and all that stuff. Okay, that's about the data structures. From the next video,we are actually diving into the data science packages. And we will start from NumPy andwe will spend some time on NumPy and then we will be moving towards pandas, which isvery, very powerful built on top of NumPy and after that, we'll be moving towards matplotliband we will also try to give you some snapshots of psychic learn as well. So hope to see youin the next video. Okay, the next few videos will I will discuss NumPy which is the whichis the very very popular package for numerical Python. Actually NumPy is like list but itis much much faster than list.One one restriction if we restrict the list of Remember, a list actually is a collectionof a lot of data objects. That was so abstract, as we saw in previous videos, if for example,we restrict a list that all the objects they must have same type all elements in the listfor example, they have same type then that list with all the same type, there is whatthe NumPy looks like, but NumPy is very, very more faster. And the reason is, even if youdefine a list with all the elements that are let's say of same type Yeah, but because listin abstract way can handle heterogeneous kind of objects, the functions that we will applyon these items, they will no longer be faster further to store each element we have to storethat information or metadata for that element in NumPy, it is both I mean, it is efficientwith respect to memory, because if the type is saying we need not to save informationabout each element, because we need just to save the information about the type becausethe type is same for all elements further when the type is same, we can write functionsthat are much more faster than then then a list. So NumPy is very, very popular, it hasvery very fast universal functions available the methods that are available in NumPy. Andit's a package i mean it's it's a whole directory structure containing a lot of packages insidea lot of modules and so much at the end of the day, it's it's it's simply or in laymenterms, it is like a list with all the same type objects and it is much more useful whenall these objects are numeric type, although you can have a NumPy array with with springdata types, I mean all the strings are all general objects as well, but the the mostthe power mill the power of NumPy array will be will become much more evident when we willbe working on numeric type data. So in this particular in this particular course we willfocus more on numeric data then other kind of data. So that's how you you write importNumPy is installed or if you if you have installed Python using Anaconda NumPy is already installedthere it is in the side packages kind of a built in package. So import NumPy we can stayas it is but we can rename this NumPy just NP that's most popular name, we can writeany other name but if you see the books or internet or somewhere this NP somehow becomesmuch more popular. Okay. Now we can define an array for example NP dot array that arrayis just a method of NP kind of function. And we can define an array using list this isthe list of several numbers or we can define array as as a topple as well. So whether wegive a topple whether we give a list an array is defined and then we can see the contentsof this array, this NP array so let let's just go to our friend Jupyter Notebook andget our hand Well dripped on, on this NumPy. So first of all, we need to import NumPy package.And we may rename as for future use as NP. So let's say that is imported. So now let'ssay a is an array, let's say NP dot array, that's a function and we may have a list andsay, let's say 12357. Let's say that that's right, we can also define the array usinga topple rather than a list, it's our choice. Which way we define the array either way.235 Let's, that's, that's another array for example. So if we print for example, a itwill give us a but if we just see the type of a it will no longer be list it will bean ND array numpy.md array that n dimensional array, okay, great. So, there are so manyattributes of this a and this B. Same. Similarly, if you see the type of B although we havedefined this be using the tupple. But the type is the same the it's a NumPy object ratherthan a list or a topple.So that's how you can create the the array 1111 more thing that is that is importantis to check the attributes of a for example, k dot d type, that will tell us the data typein a so for example, a stores all the data that is integer 32. At defined time, for example,we can we can specify the data type if we want we can specify the type if we want. Forexample, in teacher that means as in teacher here, we can here we can define, for example,the type as float, for example, so data type becomes float. There are several other otheroptions that are available to define the data type but, but even if we don't define thedata type can be defined automatically based on contents. That's what the dynamic typingmeans. So if we now define type that is, if we, if we now check the type of a that is,again in digit 32, but if you check the type of be the type that that might be a floatnumber, yes, that's float 32. Again, there are 64 bit support as well, I mean, we candefine here there are several options here available. So that's the that's how we candefine the NumPy array that's just getting started with NumPy array. In the next video,we will play with these arrays a bit more. So hope to see you in the next video. Okay,in the last video, I introduced NumPy. And we actually declared a NumPy array using alist as well as a topple. In this particular video, we will be seeing some of the propertiesof the NumPy array variable or sometimes called the object that variable there are severalproperties, but I will discuss for example, last time I discussed one property which isd type a dot d type, and that store actually the that actually stores the information ofthe data type of the elements of the array of NP array, remember NP array, all elementsof NP array they must have same data type it cannot store heterogeneous arrays as itis. Okay. Now, there is another property sometimes called the dimensions are n them. That tellsactually, what are the dimensions of of the array, I need to explain this term dimensionswith the following example. Let's say for example, that's, that's that's an array justconsider that a list for example, 123, that's one list. And if it is if it is an array,for example, if np.if this is NP dot array. With that list, we will say that array asa one dimensional array, because we only need one index to access that. For example, ifyou need to access any element in this array, you only need one index either 01 or two,only one index, that's okay. So in this case, we have just one dimensional array. On theother hand, for example, if you see here, that's one array or one list, that's anotherarray, another list. And that's another list that contains lists inside for example. Let'ssay that array one, and that's array two. And that is simply an array of two differentarrays. That's, that's an array and that's an array. For example, a One is this arrayand a two is this array. Now if we need to access any element in this particular array,we need two indices. First of all, we have to locate whether we are going to talk abouta one or a two, we need one index for that, for example, if we want to locate a one, thatmeans we are going to access with elements zero, let's say this, this whole array isa So first of all, we say okay, zero means we are going to access from from a one anda to one of those. So zero means the first one, okay, now a one. Now inside a one whichelement, this is the zeroeth element, this is the first element, this is a second element,let's say we want to access the first element. So that means we are going to talk about weare talking about this. So very loosely speaking, the total number of indices that are requiredto access an element inside the array is called dimension of the array. And m them that actually,that actually defines that that actually describes the this property, the total number of dimensions.Consider, for example, this is a 2d array or two dimensional array, let's head out totwo dimensional array A one, and let that's another two dimensional array a two, that'sanother two dimensional array, a three, for example, and let's say this is an array oftwo dimensional arrays, let's say NP dot array. Now, that's that whole array, whatever thatarray is a three dimensional array. And the reason is to access any element, we need threeindices. First index will define which one of these we are selecting, for example, let'ssay you're selecting that. So one index is needed that index is one for example, theninside this structure like so, we need two more indices to locate a particular particularindex. For example, because it is a two dimensional array, it has two one dimensional array, sowhich one dimensional array you are, it has more, it has many one dimensional arrays,so which one dimensional array you want to pick, let's say the sixth one will index withindex five, now you have located the fifth or sixth array. Now in that array, what elementlet's say the eighth element. So we need three indices to access a particular element. Sothe dimensions of this array is three. So let's play with that in Jupyter, notebookjust to get more comfortable with with the term dimensions. So let's say for example,we have an array, let's say a is NP dot array. And let's say it contains a list, let's say123. And then we have another array, one dimensional array, let's say four, five, and six, that'sanother array. And that is an array of these two arrays. So that is basically a two dimensionalarray. It is array of arrays. list of lists, equal entries. So that's a for example, oh,what's the problem? Oh, we haven't imported NumPy, we should have. So import, import NumPyas NP? Okay, we need not to import that every time. Actually, I'm recording this video aftera few after a few hours. And I'm really I have restarted all these things. So I haveto import now for the first time. But once imported in the notebook, as long as a notebookis running, you need not re import anything. Okay, so a DOD for example, and then Iraqand them. So that is to hear because there are two dimensions. For example, if I wantto access element number three, this element, so this element is located in the first arrayof the two arrays, which has so the first array, there are two arrays with index zeroor one. So I am going to look into the first array, which is 123. And in that array, I'mgoing to look for the element number two element with index two. So that's how you can accessthe elements of multi dimensional arrays are arrays with more, more kind of dimensions.Let's say we have another array just to just to get more familiar with NP array, let'ssay, and we have a list. And that list actually contains that list actually contains threeone dimensional arrays. Not only that, actually Oh, I'm confusing you a lot. Let me know Letme just, let's say we have 123. Let's say we have three one dimensional arrays. Let'ssay we have another 2459. The the sizes of arrays, maybe, maybe, maybe, I mean, maybedifferent. Yeah. Is that true? maybe different? Yes or no? Let's see, for example, the firstarray has size three, and the second array has total size. Does that okay? I guess, yes.And now if we want to access, for example, an element of an element with a, let's say,I want to access this element five, so that is in the secondary index with one, and thenin that array, it has index two. So I've accessed this element, oh, we're not too many indicesfor an array. Why?Why is that? Why too many indices, for for an array, B selects a B dot n dems. And thenthat is one y one dimensional, I have to, I have this one dimensional array. And thisis another one dimensional array. And I have made a list out of it. I'm in this is 1d arrayand another 1d array of concatenate them together, so I shouldn't have accessed this element.The problem is when you are going to define multi dimensional arrays, the the number ofelements for each dimension, they should stay consistent. For example, if the first arrayhas three elements, the second array must have three elements, or if the secondary hasfour elements, and the first must have four elements. If that is not the case, the arraywill not be defined like a multi dimensional array. For example, if we, for example, extendour first array with let's say, minus one. Now, B will be having two dimensions, no problem.And now we will be able to access for example, this element five, like so. So we will goto B again, we will see okay, select array number two, and in that array, select index,select the value indexed by two, which is five. So accessed no problem. And that staystrue if you if you're going to define for example, a three dimensional array, let mejust give you an example of three dimensional array that's a C equals NP dot array. Andlet's say we have one, two and three. And then we have another array, for example. 456,remember or so let's say that, that we can have one more for example, we can have onemore list, why not? So let's say we have a 00 minus one, let's say, and that is whatthat is. That is a two dimensional array. That's a two dimensional array. Great. Let'ssay we have another two dimensional array. Let's say we have another two dimensionalarray with same kind of consistency, the number of elements and stuff. Let's say these elementsare our minus of the, the other ones, let's say there's minus, minus, minus and this isplus one. And now we have this, if you see this thing, that's a 2d array. That's a twodimensional array, that is also a two dimensional array. An array of two dimensional arraysis basically a three dimensional array. Now, that's a three dimensional array. This one,C, so if you Oh, we have some, Oh, I should have defined this with commas. Rather thanrather than spaces. Actually. Yeah. The reason I did that is MATLAB. I worked in MATLAB also.So MATLAB allows this space separated list, but I just confuse the things with with Pythonas well. But Python requires comma, they're okay. With MATLAB. By the way, just as a sidenote, MATLAB allows you to have commas as well as spaces, but this Python is just restrictseverything to comma. That's great. Okay, that is C. So now, if you check c dot n them thatis three, if you for example, want to access this particular element, what should you do?First of all, you select the, the one of the 2d arrays, there are two 2d arrays. So thisis the first 2d array and that's the second 2d array. And if you For example, want toaccess this particular element, this particular element, which is minus three, if you wantto access that, you first have to access one of the two 2d, two dimensional arrays.So let's access the second one with the index one. Now you are in this particular 2d arrayin that array with list which 1d array you're talking about. So I'm talking about the veryfirst 1d array, so the very first 1d array is indexed by zero, and in that one D array,which element you are talking about. So I'm talking about this element that has indextwo in this particular array. So now, if you press enter, you will get minus three Wow.So that is basically how and by the way, you can make a four dimensional array, a fourdimensional array will be an array of three dimensional arrays, and so on, you can make,you can make, for example, n dimensional arrays, and that's one reason why we call this asnd array, n dimensional array, not the type of C's nd array n dimensional array, you canadd as many dimensions as you want. Great, we will continue exploring this NumPy moreand more in in the upcoming videos in particular, I will talk about this shape property of thisNumPy we have already discussed D type we have discussed and then in the next video,we will talk about shape and we will discuss more about about NumPy. So hope to see youin the next video. Okay, in the last video, we discussed this number of dimensions orending property of any any NumPy array. And we also saw an example of defining a threedimensional array in Jupyter. notebook. Let let's discuss another property which is whichis the shape property. Let's see what what this shape actually represents. So let's goto Jupyter Notebook and see what actually this shape represents. For example, you haveseen this C as in the last video, we define the C as a three dimensional array that containstwo arrays of 2d. And each 2d array contains three 1d arrays, and each 1d array containsthree elements. So what do we mean by shape? So if we just say shape? What is that thing?So shape is 233. And let me tell you what that means. The return is tuple. So that'sa tuple. That is returned to three and three. This two means how many two dimensional arraysare there? Here we have two. So in each two dimensional array, how many 1d arrays arethere? Well, three in each one, the array? How many elements are there? Well, three.So basically, this C dot shape, zero, tells you the total number of two dimensional arrays,that is too. And this shape. For example. One tells you in each 2d array, how many 1darrays are there, these many? And this shape, for example, to tells you in each one thearray, how many elements are there? Well, three grade? That's awesome. Yeah. Can I tellyou 111 screens kind of thing? You can you can define a NumPy array, for example, a asNP dot array with just one element, let's say two. That's an array raid. What's thenumber of dimensions here? What do you think? What is that? Is that a 1d array? What arethe number of dimensions? Strange? It's a 1d array. Yeah, it is. see another thing?For example, b is equal to NP dot array. And you define it with let's say three. And whatare the dimensions of B, it looks like the same, the dimension of B should be one asas their the dimension of A is one, it looks like the dimension of B is also one. No, it'szero. Because that's an array. If you pass it as as a list. It's an array of one D ifyou just define just one number that can be defined as an array NumPy allows you thatbut that one number is just as a yo D array. Now if you can get in it, a lot of zero days,you get one day if you concatenate the last one days, you get a duty. If you're gettinga lot of duties, you get a 3d and so on. Get a look and feel Yeah. So that's what it is.So yes, In this video, I discuss the shape there is another There is there are so manyproperties, let me let me discuss some properties, let's size that actually tells the total numberof elements complete total number of elements in the array. So, how many elements are therethat is size. There is also I guess m bikes property, that tells the how many total numberof bytes that the destructor is taking inside the memory. And there are several other Imean properties, if you just apply a tab and get certain things, you will see a lot offunctions. And you can you can check a lot of properties that some of these functionswe will explore later on. Sometimes they are called the universal functions, we will seethem because they are very, very fast. And these functions the vectorized implementationof these functions. That is the reason why NumPy is so so fast, and why it is so popular.Anyways, so in the next video, we will go to explore the NumPy a bit more. And we'llshow you more fun stuff with the NumPy. So hope to see you in the next video. NumPy actuallyprovides a lot of functions to create arrays, special kinds of arrays just for testing.And sometimes just for. I mean, there are a lot of ways to create arrays from scratch,for example, what if you want to create an array containing all zeros, so there is afunction in NumPy NP dot zeros that tells you how to do that. Similarly, if you wantto generate a lot of generate an array containing a lot of ones or all ones, there is a functionto do that and stuff like so, there are some functions that are actually used a lot andI want to discuss those. One function is NP dot arrange, actually, this is a single R,this is not a two Rs, this is single r NP dot arrangement, one R and NP dot arrangedfunction, what it does is it creates an array for example, if you say NP dot arrange, itcreates an array for example, if you say okay, 100. So it creates an array that it createsa 1d array that starts from the the values in that array starts from 012, all up to 99.So that's an array. That's a quick way to create an array with all the numbers till100. Yeah, so let's see, let's see running example of this NP arrange method in JupyterNotebook just to get a better look and feel of how it works. So let's see. So let's saywe have a equals NP dot arrange. And let's see 100. So that's it. If you want to seewhat is inside a, you can see this is an array with all the values starting from zero upto 99. Maybe you want to create an array that starts from a particular number ends at aparticular number. Maybe those two numbers are different. And maybe this arrange functionactually allows that. Let's say I want to start with 20. And I want to end at 100. AndI want to create all the array that does that. So let's say this. So that's okay, start from20 and 100. But the last element last index is not included. That's possible. Last butnot the least, if you want for example, to start from 20 and add 100. And let's say youwant to take a jump of three. That's possible. Remember, does this does this resemble withsomething that you know already? Remember that? Yeah, let me pause for a minute, butnot for a minute, just for some seconds. Let me pause. Do you remember this arrange NPdot brains function? It looks like something like what? Remember that for i in range? Yes.for i in range, for example, start from 20. Go 200. Take example three. Remember that?So it has some resemblance with range function? Yeah. Although range is an arbitrator.What's an arbitrator? why I'm telling you that? Okay, let me tell you an arbitratoras well here, just just just just spend a few seconds on on this range function. You,you might be thinking when we call this range, let's say starting from, let's say range them,you might be thinking that it returns a list of numbers, starting from zero to nine, butthat doesn't happen. It returns nothing. Actually, when you actually call it when you actuallycall it it returns just an object. When you call it in a for loop or somewhere. It progressivelydo. rounds one by one element one by one. So it returns an element, then it hydratesand return another element that it never creates a list of elements, it now creates a listfor you. That's awesome. Actually, it generates numbers, it generates the next number andthe next number as you move on. So it saves a lot of memory and these kind of objects,they are called I craters that I played, they they never played. But if you want, for example,to get a list, if you really want to get a list, then what you can do is you can callthe range, let's say in the same way, and you can just write a list. So provide me alist don't just provide me an ID. And that will give you a list. How cool is that? Right?Anyways, that was just a side note. It has nothing to do with this arrange function anyways.So NP dot arrange, it actually returns an array does not it is not like an iterator,it returns an array, complete array the way you want. So that's what this arrange is ithas resemblance with this built in range function that mostly used in in for loops. Okay. Next,let's discuss this NP dot random dot permutation NP dot random is a package. And P is a package,it has a lot of sub packages inside random as a package. Random has a lot of modulesone module is permutation. There are a lot of other modules. So let's see this random.Let's see what it does. So for example, let's say a equals NP dot random dot, permutation,let's say permutation. And what I do is I say okay, np dot arrange, let's see 10 whatit does is, this NP dot arrange will return an array containing all the values zero tonine, these are 10 values, and then this permutation function that resides in the package and Pdot random that is in the random packet of MP, it actually shuffles all the values andrearrange all the values in random fashion. And he will now be an array containing thesame elements, but in a different order in a different random order. So let me know printthis a, it will be having all the elements from zero to nine bought in a really shuffledaway. And that shuffling is completely random. Yeah, you see that? Sometimes you may youmay call some function, you may want to write some function on arrays. And you may wantarrays that are that that do not have a particular ordering, there are just random arrays, justto test your code just to test how it works on any kind of array. In that case, one wayof getting shuffled kind of array. One quick way is to just use NP dot random dot permutationfunction. The NP dot random package does not only have this permutation, there are a lotof other functions and be random, for example, np dot random random dot Rand int, for example,Rand int, that creates a random integer. That's, for example, if I that's that, let me callthis and we have, how can it be used? Okay, you can give a low value from the very start,we can give a high value, I mean, and it creates actually, random integers starting from lowending at high. So that's how it can be used. For example, let me call it as NP dot randomdot Rand int, create a random number between 20 and 30, create some random integer, andit will return some random integer between 20 and 30. If we call it again, it may returnsome other is it is returning 30 again, 29. Again, and again. Now two turns 2932. Maybewe want to maybe want to generate random integer between 20 and 30. So it creates a randominteger. One thing that you might be noticing what is the what is the return value? thereturn value? Is we for example, what should be the type of E or do you think? Is thisV is an array? No, it is a number. It's an integer, the type of VA should be an integerbecause it is returning a random integer it is returning an integer but it is selectingthat integer randomly from 20 to 300. So it should be integer and it is Yes. Wow.Yeah,so we will be exploring some more functions in the random package of NP and then we willbe moving towards this fascinating function score function called V shape. So there ismore to come for NumPy so hope to see you in the next video. Okay in the last videowe saw a range function that's a very useful function to just create a test testing arrayand just see see the output of a particular operation or algorithm, just on differentkinds of arrays. Further we saw permutation functions permutation function in NP dot randompackage. And we saw that this this permutation function, actually, it reshuffles, it shufflesdifferent kinds of odd if if array is applied to this permutation function, it actuallyshuffles all the, all the elements of that array in a random way in a completely randomway. Today, we will explore this random package a bit more, and then we will see a reshapefunction, but that reshape does basically this reshape, for example, if you have anarray, let's say, array, is let's say we have an array with, let's say, 10 elements, andif we call a dot reshape, and we give, let's say, two by five, so it will make a two dimensionalarray out of a, which is B, and that will be a two by five matrix R, that will be anarray, or a matrix with two rows and five columns. And now we can, we can just workwith this B, just like it's a two dimensional array, and we can just, we can just treatthis B as a two dimensional array and work with that. It is it becomes handy sometimesif for example, we want to, we want to test certain operations on on matrices. A quickway to make a matrix is just to call arrange function, and then whatever the result isjust reshape it into the desired order matrix and test the algorithm. So let's go to thelet's go to Jupyter Notebook and check this random package a bit more and then see thereshape function. So let's go to Jupyter. notebook. Yes, so there are a lot of waysto generate these random numbers. One for example, we already have seen Rand int. Andother way for example, array, an array can be generated, like MP dot random dot RANDfunction. So now, if we create this, if we create, let's if we pass let's say 1000, randomvalue array will be generated in a and a each value of a will be a random number betweenbetween zero and one. So all these numbers are just random between zero and one eachnumber is zero and one random number. And, and this distribution basically is the distributionof this random number is all the distribution is uniform. If for example, you want to plotthe histogram, the histogram or the distribution of a it will look like uniform. Let me justgive you give you one or two plots, using matplotlib package, although we will see matplotlibpackage later on. But let's assume that this is just a plotting package. This is just apackage that helps us plotting just import that import mat plot lib.pi plot as PLT importthat. And after importing that, you just plot a histogram PLT dot hist, for example, andpass a and you can see the histogram is roughly uniform. I mean, everything is equally likelywe can make more bands, for example, we can have bands, equals let's say 100. And we cansee almost all events they are I mean just look like uniform. If we make more and moredata set, then they will all look uniform. One more thing we can we can have, for examplethis. And let's say B equals NP dot random dot Rand n, and that generates normal randomnumbers, or Gaussian random numbers, let's say which which the distribution of the numbersare is the bell shaped curve, for example, so let's just PLT dot haste B. And then let'ssay equal to 200. And we can see a bell shaped curve because the distribution of this datais is Gaussian distribution looks like so. So this this random packages, this NP dotrandom is really important package. It has different, it can create different kinds ofrandom numbers from following from different distributions and doing in machine learningor in statistics, sometimes we need to generate these kinds of random numbers for sometimesfor testing purposes, sometimes for adding noise of a particular type to test our modeland stuff like so. So it's good to have a good grip on NP dot random package. Okay.Next we see reshape function. One more thing. For example, if you want to create, for example,a two dimensional array of just random numbers, let's say you can call NP NP dot random dotRand. And you can just call a, you can just pass two arguments, for example, two by three,and the C will be a two by three matrix. If you see the C, it will be a two by three matrixof four random values. If you see c dot, and then it will be having the dimensions aretwo. And it's a two dimensional array. Further, we can create, for example, a four dimensionalarray c equals NP dot random dot Rand, maybe two by three by four by two. And that's afour dimensional array with this particular order. So if you see this C dot m, then thatwill be level b, this. Yeah, so let me let me just give you an interpretation of whatthat thing is. There are two arrays that are three dimensional. And there are two of those.Okay? Now, each three dimensional array has three two dimensional arrays. Wow.So eachtwo dimensional array has four one dimensional arrays, and each one dimensional array hastwo elements in it. So that's what the structure is. Yeah, get a good look and feel. So let'ssee the reshape function. For example, let's say we have d equals NP dot range. Let's saywe have 100 values. And then we say reshape these 100 values to let's say, let's say fourby 25. So this D will be a four by 25 matrix. So if we just get the shape of D, so thatwill be a four by 25 matrix or a two dimensional array with four rows and 25 columns. Yeah,so sometimes we want to work on matrices, and we just, we can just plug in these arraysfunction to generate a bunch of numbers. And then we can reshape those and build a matrixquickly, and then just test the performance of our algorithm or stuff like so. So, notonly the reship not only returns the, the I mean, you can you can reshape a matrix,and you can reshape an array into more than two dimensional array if you want to, forexample, arrange 100, let's say dot reshape, maybe or as four by five by five, it's a threedimensional array. Now, this D will be a three dimensional array containing different values.Yeah, so now you can access it and do whatever you want to do. So not only the reshape, arrangeand permit random, there are other functions as well NP dot zeros. For example, if youpress z, and you just see the zeros, and then you just press the question mark, you willknow what that function is how can we use it and so on. Similarly, you can have severalother function there is an important function once for example, you can call that function,and that will generate an array of all ones, you can see how to call that function here.There is NP dot empty, there is NP dot empty, like there are so many functions just to createsome matrices very quickly. And you want to test your core algorithms based on those.So yeah, so there are a lot of functions that we want to that we can work on. So next, sothere are a lot of functions that can quickly create a NP array and an n dimensional array.That we can quickly create an array test or algorithm or use the array wherever we wantto like we're everyone to use. And we can move on just a few functions like arrangedones zeros, they are there are random dot Rand random dot Rand n, and other functionsthey are available. For In the next video we will be seeing we will be seeing the indexingor slicing inside NumPy array and we will also be seeing the difference of that indexingwith or slicing from the array In the list or or are the ordinary data structures? Whatis the difference in? What is the difference of slicing in NumPy? with for example, withthe list, we will see that in the in the next video, hope to see you in the next video.Okay?Here is my favorite topic in NumPy slicing. Actually, indexing or slicing in NumPy isthe way you access sub arrays is just the same as the way you access sub strings orsub lists. And you already have seen, how can we how can we use the slicing or indexingin lists and in strings, the difference here in NumPy is in list for example, if you sliceyou get, for example, let's say B equals a one colon five, if you slice that thing, fromNumPy, then B is not a copy, it is actually accessing the same memory view as an A. Now,if you change any element in B, the corresponding element in a will change as long as as a NumPyarray. However, if A is a list or any other data structure, ordinary data structure, thenthe slicing this, this kind of slice gives a copy rather than a view. So that's an importantdifference, we need to know that rest of the indexing technique is almost the same. Youdo this kind of indexing that is how you can reverse this a start and step all all thethings are same, except How can play How can we play with the two dimensional arrays. Let'slet let's see that. Let's see some examples of indexing one by one in in Jupyter Notebookand see how the slicing actually creates a view rather than a copy. So let's go to ourJupyter Notebook and see how can we play with different indices, let's say a is NP dot arrange,and B dot arranged, let's say 100. And let's shuffle them. Let's say as it is, let's saythat's a now a, let's say, let's bring some certain things. Let's A B equals a big allthe elements starting from index three, ending at index nine, Sudan is not included. That'sB, that's blank v. Let's see what's B. So b is this array. Okay? Now what I'm goingto do is I'm just changing the contents of b, this NumPy array is mutable, you can changethe elements inside, no problem. So I'm going to change the elements, let's say one elementin B, let's say, I'm going to change element numbers zero, and B, which is three, and I'mjust placing that element as minus 100 minus 1200. That's it. That's the case. Okay, nowthe contents of B has been changed. We are but now let's see the contents of a the contentsof a also has changed. That's a big difference between slicing an ordinary Lester adini datastructure or slicing a list, when you slice a list, you get us you get another label,but that label or that variable is accessing the same memory, the memory actually is notcopied. There is one memory view. And these two different names, whether you access thoseelements using B, or you access those elements using a the same memory is being accessedif you change the memory using B or A you will see the effect in both of the variables.So that's one difference. Now, after having knowledge of this difference, if we reallywant this behavior to not happen, one thing that we can call is we can say okay, a, forexample, a, let's say three to 10. And then we can call our famous function, rememberthat copy, you can copy that and now B is completely a different array. It's it's adifferent memory view, if you change B now, the effect will not be seen in a so copy functionis there whenever you need copy. One thing if you are not going to change elements thenumber is applies you very fast implementation of slicing by not changing the memory viewif if you are aware, your algorithm is not going to change the elements slicing willgive you much much efficient access to the elements or the or the sub blocks or sub arrayswithout actually making the copies inside the memory which can take time and space both.So this is one plus of NumPy Over the over the other data structure that we have seenso far in Python, okay, let's play with indices,let's say what do you think? What is that thing? colon, colon to what? Or colon colon,let's say five, what it will do, it will start from the very first index, which is zero,it will go to the last index, but it will pick every fifth element. So let's see. So,it picks zero then five then 10, then 15, because the jump is five break, what do youthink what this will do? Let me just let me just teach you by example, what this willdo. Yeah, what it will do remember, if you apply a minus here, the end and the startand end they just get swept, and this becomes a step from from the end. So, what will happenis the same kind of impact, you start from the very end, then you take the step of minusone from the end, and you just based every element, so this is kind reversing the arraywith with kind of step starting at the end rate. So, another way of reversing the arrayis if you want to reverse the array as a whole display minus one, which means start fromthe end and pick every element from the end till the beginning and the end, and the arraywill be reversed. This element is there, remember that this is there, let's chain that element.Let's chain that element. So, so a adds position. So, I want to find out the index, where thisminus 1200 is located. So Id x is equal to a dot index I guess there is a function indexYes, he has a no index Oh, there is no index there. Is there an MP dot index and P dotindex? I want to find out the index where so in DAX there is no index function indicesor something, I want an index function is there any index function I want to find outthe index? Where minus 200 is located? There are several ways but I want to find one. Sofor example, for example, let me see whether there is an index function and not availablein NumPy or not. No, it is no longer there. But there is in the CS function, I guess.So in the CS, what that does, I guess that does the same job. Let me see MPR indicesreturns an array representing the indices of a grid, okay. So I have to give a gridand then it returns for example, the indices of all that grid, how can I use that? Well,it becomes it becomes difficult, there may be a find function, or how can you locatethe index where the minus 200? Is, is located? How can I How can I do that?Huh?Yeah, very difficult. Seems like very difficult. Oh, why don't I rather than finding out afunction? Why don't I just play with play with the NumPy? Why not? So let's say a equalequals minus 1200. That gives me a Boolean array comparing each and every element withminus 1200. So, the array the returning array, let me call the index array or the Booleanarray, let's be that array is true or false array or zero or one array, wherever thereis minus 1200, that index is one that value is one otherwise it is zero, completely zero.And then what I do is, I just multiply that with with NP dot arrange NP dot arrange withwith saying that a dot A dot A dot size, so whatever the size of A is, so because theseare the indices Okay, then what that's point wise multiplication grade. So, when I willmultiply them together, what I will get is is what I will get from multiplication, Iwill get, how can I How can I find out actually, a train lost here literally, how can I findout how can I find out the index where Where am I? So that will give me what? Let's see,what is B. Now, the B is B is just an array. B is just an array, and there is this three.That is looking at it. So how can I find out? Where is this three? How can I, again, theproblem is finding out the index. Okay, that's, that's really a bad thing. Can I call thisaid dot indices? And just give a minus 1200. And everything just worked out? No, thereis an error, there is an error. Oh, I'm lost here. Literally, I'm lost here, I need toknow how to find out the index where this particular element minus 1200 lies. Sothat's aquestion for you as well. I'm also lost. So let's see you in the next video. And we firstwill solve this problem to finding out the index of a particular element, or maybe alot of elements. And then we will continue from there onwards to see more indexing. Okay,great. So hope to see you in the next video by first solving the problem, how to findout the index of a particular element in a NumPy array, or maybe more than one elementsin a NumPy array. And then we will be practicing more about these slicing examples. Okay, hopeto see you in the next video. Okay, let's say this element is there. And let's say wewant to, we want to locate that element in the array, we want to just know where thiselement is in the array. So array has this element. Let's let me paint array as it is,this array has this particular element, and we want to know where what is the index ofthis element inside the array, there are several ways of doing this. One way is to find outtheir index is simply you call the function arc where arc where for example, org, whereA is equal to minus 1200. And that will return a 2d array. And if you just want any one index,then you return that kind of thing. So if you write this thing, you will get the indexexactly of the element that is there. So the index is three, if you want to change thatvalue, for example, the value should be three here, if you want to change that value, whatyou can do is you can right, okay, ie x is equal to three, and is reverse to its positionwherever it was created, okay, great. Now, let's play with the two dimensional indices.Let's do dimensional arrays, let's say we have a equals NP dot random dot, Rand, let'ssay, let's say we have a five by four matrix, let's say a two dimensional array, let's roundall the values by multiplying them to 10. What it does is because all the values thisRAND function, all the values it generates are the values between zero and one, whatthis multiplied by 10, what it does is, it actually scales up all the values to 10. Andthen round function, actually, round downs are actually rounds the values to the integers.Now a will be worse the problem round that third round method is no longer there. Okay,maybe there is NP naught round, maybe that NP dot round, maybe NP dot round is theirYes, and B dot round. So round function of NP. So this a is a is this array, for example,that's five by four, a four, five rows and four columns. So let's say I want to accessthe second row. First of all, let's say I want to access this particular entry. Thisparticular entry is second row and third column, which means the index is one comma two, becausesecond row means the row row first has index zero. row two has index one. Similarly, columnone has index zero, column two has index two, a one and column three has index two. So thatis what this particular entry is. What if we want to access the whole second row, forexample, we want the second row. So that's how you call that's how you slice. A normalmeaning of this is you the role should be one and the columns, all the columns, so That'show you access the whole second row. If you want to, for example, access the whole thirdrow, for example, or a whole second column, let's say that means you say this, okay, thecolumn number second, and all the rows, which means the whole second column that is accessed.That if you see, that's the whole second column six, four to 10. And one, that's what thesecond column is. Further, once you have a, you can, you can, for example, access a submatrix, let's say you want, you want row number one to rule number three, not including three.And then of these rows, you want column number two to column numberfour, let's say. And if you do that, you access the whole sub matrix. First, it actually picksrow number two and row number three, because row number two starts from one. And then ofthose rows, it picks these columns, and you can just pick the pick the sub matrix insidemore, you can, you can do a lot of processing on these matrices. For example, this is matrixA, if you just type a dot transpose, that these four transpose, the matrix just is takentranspose of it. Further, there is a complete library, linear algebra library in NumPy.For example, if you just import NumPy NumPy dot linear algebra, as a for example, thenthis linear algebra library in NumPy, has a lot of functions, Eigen values, chelskidecomposition, computing determinant of a matrix, finding out inverse of a matrix andwhat not. For example, let's say we have la dot inverse, and here is NP dot random dotRand, let's say, some three by three matrix. So what it returns is, it returns the inverseof this matrix, and this linear algebra library, and there are other libraries as well. Butthis is one scientific library, that may be most of data science experts who actuallywant to do research, they might be thinking, this linear algebra library, that that specifiesa lot of functions related to related to these matrices or two dimensional arrays. So thatis there. Okay, so that's about indexing. We can play with these indices a lot if wewant. One more thing, just just one. One last thing, let's say this is our a. And what wewant to do is let's say we want to sort this A with respect to the columns, we want eachcolumn to be sorted individually, what we can do is we can call sort function, and wecan pause X's equals zero, access equals zero, that means sort all the columns individuallyand the result will be if you see the result, the result will be every column is sortedindividually. If we want to sort for example, every row individually, we will say okay,sort x is equals one, and every row will be sorted individually. And if this is a multidimensional array more than three more than two dimensions, then x is can be two x's canbe free. So which with respect to whatever axes you want, your sorting can happen. Itcan do that, if A is one dimensionally, then dot sort function without an access, justsorts just sorts the one dimensional array from beginning to the end. And if you wantto descending order a sword just sought them sorted first and then reverse it using indexing.Great, I mean, there is a lot to discuss, there is a lot to discuss, I'm ending thisslicing here. In the next video, I'm going to show you kind of masking or sometimes calledthe fancy indexing that is much more powerful and useful in a lot of different contexts.So hope to see you in the next video with more NumPy indexing. Okay, there is anotherway of indexing a NumPy array. In the last video we saw we can, we can do slicing notation,for example, start from here and here and stuff like so. There is another way of accessinga NumPy array as we have an array and we can just give the give an index array inside forexample. Let's say a is one dimensional array and then we just give 146 that means big elementat index one, pick the element at index four, pick the element at index six. So this kindof array inside can be a list or an array. That is called an index array. And you canjust pick the elements that you want to pick, for example, you want to pick all all elements,you want to pick first element, fifth element and 17th element, you can just create an indexarray and pass it. And in an index your and access your elements using that index arraythat's possible in NumPy array. Further, you can access different elements using a Booleanmask as well. So Boolean array, for example, true, true, false false, wherever there isa true pick that element wherever there is a false, don't pick that element and returnthe elements that are picked. For example, assuming here that you have an array, whichis one dimensional array, let's say, assume that has eight elements, 12345678 elements.Now you pass a Boolean mask inside, where with with obviously, eight elements, a trueor false values, wherever there is true. So pick the very first value, pick the secondvalue, pick the don't pick the third value, don't pick the fourth value, pick the fifthvalue, pick the sixth value, pick the seventh value, and don't pick the last value. So thatis also possible in in NumPy. One thing that is important is if you do this kind of indexing,which is sometimes called masking, if you do that, if you do if you supply an arrayindex, or index in a Boolean form, you by default get a copy as as as compared to slicingin slicing, you get a view that's a separate copy, you need not to call a dot copy function,it is by default, a different copy. And this is a difference between the ordinary slicingthat you do, for example, start from one go till 50, take a jump of let's say two, ifthat is your indexing style, that is called a slicing, the return value is a differentview having the same memory. However, if you do the, if you use the array index, or theBoolean array called masks, then you get a copy of rather than also so which means ifyou if you get a new array, you change the elements in the new array using the arrayindices. You're not getting that change happen to the original array. So that's the differencebetween slicing and masking. Okay, this kind of Boolean indexing becomes really handy.For example, what if you want to exit? What if you want to get all elements that are smallerthan eight, one way to do that is just write a and then apply a condition is less thaneight, well, a is less than eight, we'll create a Boolean array. And everywhere where theelement is smaller than eight, there will be a true otherwise it will be false. Now,the inside array is a Boolean array, and you access all the elements with respect to thatcondition. So it will return all elements that are smaller than eight. How how fancyis that? Further, you can you can have these conditions in a combined way. There is onedifference there is an AND operator A and D and, and there isn't an operating in a differentway. So I'm going to discuss the difference of this and this and as well in this in thiswhole in this video. So let's go to Jupyter Notebook our fan and see how can we play withthis masks.So let's say a is again and B dot arrange, arrange, let's say 100. That's it. That'sour a. And what we now do is we access the elements of A, B access, for example, thethird element and the fifth element and the sixth element. Let's say we want to do that.And that's our B. So that happens, let's say, so what B is B is this, something that youneed to know is if you change the elements of B now, because that's a copy, let's sayminus four, that change does not happen in eight that happens in B for sure. But thatdoesn't happen in a, a does not contain any value that is minus four. Because using thesekinds of indices, the array index By default, the result is a copy rather than a view. Further,let's say you have this a and you want to access all the elements that are smaller thanlet's say that are smaller than let's say 40, access all elements that are smaller than40. So that is possible now even contain only the elements that are smaller than 40. Allthe elements while further if you want to access all elements that are that are smallerthan 40 that are smaller than 40. And they are bigger than they are smaller than 40.And they are bigger than 30. Let's say you want to access all the elements that are between30 and 40. You can just access those elements like so there is a problem. A dot any a dotall what's the problem here? The truth value of an array with more than one element isambiguous use a.ne or a dot all. Okay, this a is less than 40 is a Boolean array is greaterthan 40. That's a Boolean array. So what's the problem? What, why can't we not use this?What's the problem? We should have used that. So use and, and, yeah, I guess we were missingthese, we were missing these brackets because it might be confusing this 40 with this aand stuff like so. So use parenthesis rate. Now, B contains only the elements that arebetween 30 and 40. Now, one thing, what's the difference between this particular andand this symbol and the difference is this and AMD an operator It is used when both ofthe sides of this end has what is one object and it has one true value either true or false.And this particular symbol is used when the left side and the right side can be arrays,and each element of that array can be true or false. And so, so, you can think of thisand is using arrays, however, this is used when both the sides are single objects. Sothat's the difference. Other variants of and I mean, the end is like this, that these arethese are the same things, but remember the use this is used for arrays, this is usedfor single objects. Similarly, there are other symbols likeorthat is used this way or or that is used that way. Similarly, there is a not not for arraysis used like this way and not for otherwise, is used like that way. So remember these theleft side, I have symbols, they are used for arrays, the right kind of symbols, they areused for single objects that has true or false values. So these, this kind of masking isreally, really powerful. Later, we will see in pandas accessing different kinds of datawith particular kind of conditioning, that becomes really handy if we if we are comfortablewith these kinds of indexing. And that's really powerful indexing. Okay. So, I've told youthe difference here between Aaron and I've told you that this is copy rather than a view.So just bear with me some more time on NumPy. And I will tell you some more truths aboutNumPy. And then we will move towards another package called pandas. So before pandas moreNumPy is coming, I hope to see you in the next video. Okay, in the last video, we sawmasking, which is sometimes called the fancy indexing as well. And here we are going todiscuss one more feature of NumPy, which is very powerful feature called broadcasting.I think, for example, you have an array, let's say two, three, a matrix, that's a two dimensionalarray 235 and nine, and you want to add, in every element, you want to add a number, let'ssay five. So one way to do that is create another array with 5555. And just apply thisadd operator and you are done. Great. But this NumPy allows you to just write let'ssay this is array, a NumPy allows you to just do this particular thing. And this five isautomatically broadcasted to match with the dimensions of its other operand. And additionhappens you need not to do this explicitly. And this broadcasting is not just one scalarvalue. For example, if you have one variable, let's say a is this and you want to add, forexample, this particular column, let's say one three, you want to add this particularcolumn in the first column as well as in the second column, but then you need this onethree to be copied again and make a bigger array and then you do that well, broadcastingallows you if you just write this as a plus one three, it will be automatically broadcastedto match the size of the other operand, wherever the book broadcasting is possible, there arecertain rules to to know when broadcasting is possible it is not possible each and everytime. For example, if you have this matrix 239 and Jeff 421 Let's at this matrix andyou want for example, two one and six two, for example, if you want to do that, the broadcastingmay not happen because in this way, if I want to broadcast this structure, the structuresshould be if if the structure is broadcasted to in horizontal way, the the two columnswill be arrayed and the addition cannot happen. If it expands to a vertical way still theaddition cannot happen. So, this here you will get an error because broadcasting iscannot happen, but in several cases when you want to add for example, a scalar multiplywith a particular thing wherever possible this broadcasting is possible and broadcastingis just a I mean it just a feature of NumPy that allows you to not repeat to match thedimension of the other operand to apply a particular operator it does it by itself great.Next, we see some more important functions to no one is horizontal stack. That means,if you want to concatenate two different array two arrays that are that can be concatenatedtogether horizontally, you can get out you can call at stack function and that will concatenatethe two arrays together and returns another array. Similarly, V stack is if you want toconcatenate two arrays vertically, if they can be concatenated vertically, vertically,similarly, there, there is another powerful function sort, and there are a lot of otherfunctions, these kinds of functions, they are called Universal functions. And they arevery, very, very powerful, very, very fast their implementation is vectorized, whereChrist mean the implementation the all loop kind of layer is deferred to at the compiletime and the things are really faster when you do a vectorized code. So, having saidthat, it is always recommended to not use explicitly for loops to achieve these kindof,to achieve these kind of results, whenever a universal function is available, use thatbecause the efficiency of that universal function will be way, way way more than then whateverloop loop or whatever function you will be writing other than the universal function.So, and by the way, there is another function concatenate as well, in which you can specifyaxes. And it will either act as horizontal stack or either act as vertical stack, dependingupon whether the x value is zero or one, whatever. So, let's just get comfortable with these,these three functions, just quickly neural Jupyter Notebook and see an example of, let'ssay, broadcasting as well. So let's say we have a function, and let's say you have anarray is let's say, np dot random dot Rand, let's say that is two by three. And then Ijust multiply this with them. Remember the last thing and then we just NP dot around,we just round everything. So that it becomes it becomes whole, in this particular way.Okay, that's a, let's say, so that's our a, that's the now if we say a plus three, threewill be added everywhere in a, and that happens through broadcasting. Well, if we if we do,for example, a plus, for example, np dot range, let's say just do values, and then we justreshape it, reshape it, to reshape it to let's say, a two by one matrix. If you do that,then still, what what will happen is just apply the parenthesis just to show that thisshould happen. First, what what will happen is there will, there will be a column thatwill be added to every column A, and that again, will be happened through through thebroadcasting. So broadcasting is that powerful. Next, let's see the stats. So that's it, thisis a, let's say we have the that's another way, let's say NP dot random dot Rand. Let'ssay that new array is two by two. And again, let's say it is multiplied by Dan and NP docround just to avoid the decimal points. That's it, this is B. Now a is two by three arrayD is a two by two array, if I just concatenate them horizontally, I will get another arraywhich will be two by five. So C equals np.at stack horizontal stack, at stack, and I willcall these A and B. One thing that you need to know is if you if you want to call thisx stack, horizontal stack or vertical stack, these arguments in B that you want to concatenateyou have to give them in a topple or you may you may want to give several values to concatenatetogether maybe you have maybe you have 10 matrices to concatenate together horizontally.You have to give all these as a tuple inside a All right. Now similarly, we can do a verticalstack if we want. I mean, one on top of the other. And we can call it and getting it functionas well, if you want. Third is sort function. For example, if we want. If you want to useNP dot, let's say a is NP dot random dot permutation, let's say NP dot range, let's say the 10 values.Let's say that our a, let's say, this is a, and we want to sort this array. Oh, this isalready sorted. Why is it sorted? No, it is not sorted 1/4. It is not sorted? Yeah. Let'ssay we want to sort it a dot sort. One way of doing that is just call a dot sort, andyou're done. That's the value of a another way, which is sometimes more readable, althoughexactly the same is to use a universal function, using NP dot that thing that also is the samething. Now sort by default sorts in ascending order. If you want to sort in descending order,then what you can do is you can sort aid or sought, for example, do that in ascendingorder, then what you do is you just reverse it, minus one, and just copy that in a again,now he will be sorted. While sorted in descending order. Yeah, great. Um, one more just justjust just to give you one more flavor, if you create an array, for example, np dot arrayof strings, for example, ABC, and another string is, how are you and vai maybe we haveanother string? Whew, 785. And maybe we have another string, one, three e r, that's it.That's a string. That is possible. As long as all the objects have same type, you cancreate an empty array. Now, you might be wondering, what we'll do this sort function on a becausethese are all strings? Well, the answer is it will sort the strings according to thealphabetic order, whatever the alphabetic order is, whatever string according to thealphabetic order should become first that will become first and the other strings, theywill they will just join. Yeah. So yeah, so that's about something that is not that isnot the numeric value. Okay, great. There is a few more things to come about NumPy array,and then we will be moving towards panda's library that is built on top of NumPy arrayfor better processing of data, I hope to see you in the next video. Okay, in last video,we saw horizontal concatenation, vertical concatenation sort function, we also saw somebroadcasting and stuff like so. Universal functions, it should be speed here, sorry,it should be speed, speed. Universal functions are really, really speedy, I always am talkingabout NumPy. Whenever I start NumPy, I said, it is fast, it is fast as fast, I never showyou how fast that is. So let me give you an example. Let me let me just create an A NumPyarray with a lot of numbers, and then just apply an ordinary function, let's say wantto add all the numbers in this array B, let's apply an ordinary function that is not inNumPy. And then let's use universal function dot sum, and see how speed differences there.If for example, we apply apply a universal function to achieve a particular task howspeedy that universal function is, because a vectorized implementation, as I told youis much faster, how faster let's check that out in new Jupyter Notebook. That's a magiccommand time ID that will tell us how much time this particular task has, has taken.And if you run this command, it will it will call this function again and again severaltimes. And then we'll report an average value that will be much more stable than just callingonce. After that, we will also we will also write our own sum function using loop. Andwe will see whether that is even closer to a universal function speed or not. Let usjust check the speed of universal functions that will give you a look and feel of howmuch NumPy implementation is faster. So let's say we have an array, let's say B and B dotrandom dot Rand. And let's say that array is huge, really huge. Let's say that's thecase. Now what we do is we let's say we we call a function sum. So let's say we calla function sum. That's a built in function. In Mumbai, that's a built in function that'sa built in function in Python, not a NumPy function. And then let's say we do the sametask using NumPy universal function and P dot sum, that's the same as NP dot sum isthe same as if we if we write, for example, b dot sum.So whether you write b dot sum, or you use NP dot sum and be passed and passed, as anargument, both these things are roughly the same. So let's run it, it will take a whileIt will take a time because, okay, the sum function takes 307 milliseconds, that is nota universal function in NumPy. That's a Python function. That is not written in NumPy. Thatis not a vectorized code, nothing. It takes 307 milliseconds to perform to take the sumof the elements of this array. And it does that by applying seven rounds in in Santaloops. However, the universal function takes just around three milliseconds, I'm assuming2.7 milliseconds, how will how are you going to compare this 307? With three? How muchfaster you are around? Around 100? times your faster? I mean, yeah, I mean, this NumPy isliterally faster NumPy, the universal function will faster, maybe you attempt to know that,okay, the sum function might be too slow. Let me write my own function. To do that,let me define my son, and my son just take an argument, let's say something, let's sayG. And what it does is for, let's say s equals zero, what it does is for x in g, s plus equals2x X plus equals to x and then just return as nothing. That's your function. Let's sayyou think that this is really a great function. Let's do that. Okay, let's compute the timefor this time it my son. And let's pause the rabee and see how faster this is. This isroughly the same as your calling the sum function, but this NP dot sum or the universal functionis very faster, fairly faster. So, use universal functions, avoid for loops, avoid your ownfunctions, if the same task has been a can be achieved through universal functions, wheneverpossible, avoid loops when you are working with NumPy. That serious suggestion, followthat, because the universal function written in NumPy, they follow the vectorized code,all the interpreted slowness that is deferred to the compilation layer. And the NumPy becomesreally really faster and shows its power when you are working on large arrays using theuniversal functions. So I can speak more about NumPy. But I have told you some basics ofNumPy. And we end the NumPy here and from the next video, we will be moving towardsa very, very fancy and beautiful kind of package called pandas to handle data. And by the way,the pandas library the pandas package completely is built on top of NumPy. Everything thatis there in pandas is built inside is built on top of NumPy as all the indexing and allkinds of stuff, slicing and speed. All is there in pandas that is due to the NumPy.So we will see one more package after pandas which is matplotlib for for plotting afterwards.And we'll do a project at the end using scikit learn as well, just to wrap up all these thingstogether. But for now I'm ending NumPy here and in the next video, we will start pandashope to see you in the next video. Okay, welcome to pandas data science package that is very,very powerful of handling data, manipulating data and used a lot in data munging and datacleaning and data pre processing and whatnot. This pandas basically is built on top of NumPy.So most of the features of NumPy is also available in pandas.Let's let's dive in. I mean, this pandas is a very, very fancy library, very, very fancypackage, that you can handle very large amounts of data in CSV files or an Excel files. Whereverthe data is located. The missing entries are there. You can handle all the data you canmanipulate all the data you can prepare all the data in just a few lines of Using thispandas package, so let's just start pandas package. There are two most important objectsof pandas. One is series and other is data frame that we will see later on, there isone more index. But the most important one is, or the useful one is the series and dataframes. So let's just define, first of all, you need to import pandas package import pandas.And you can rename this as PD, that's a, that's the most popular renaming, although you canrename it any. And then you just say okay, PD dot series, and then just like a NumPyarray, you pass the data that you want. And you can create your own indices, for example,like, just like dictionary, this a is a key value. This is a key or index for this point,two, five, this B is index 4.5, C is index 4.75. And these index four one, so you canyou can, you can supply your explicit indices as well. If you do not supply the indices,the default indices are 012, and three, but you can define your own his own indices inthe way you want. Now, once this data object is created, you can call the data values andyou will find out the values you can call the dollar index and you will find out theindices let's see in the Jupyter Notebook just to get comfortable with pandas. Firstof all, import pandas as PD, maybe or something else. So okay, let's import it, maybe we cancheck what we're going to reveal working in PD dot worryin. The version of pandas we areworking in right now is 0.2 4.25. Read. So let's create data or whatever variable let'ssay a as PD dot series buzy dot series and there we just give a list of some values 2345let's say these are the values. And then we can give index as another list. Let's saythe indices are a maybe the indices need not to be strings, anymore, anything AB, C, andlet's say the index of fighters. Let's see. So now the series object or the pandas objectseries is created. Series basically handles one dimensional arrays, later on, we willsee DataFrame handles multi dimensional arrays, I mean more than one dimensions. Normallytypically two dimensional arrays, but okay, a dot values. So let's call the values, values,and you will get all the values inside the series. And by the way, this values arraythat you get, let's check what's the type of that array was type of battery? A dot values?What is that thing? That's a NumPy array. Wow. And what's the type of a itself thatwill be a pandas object. Great. So everything inside pandas, the NumPy is playing all therole inside pandas. Great. So now, let's check the index a dot index. That's also a NumPy.That's also an array of index type, that's a different actually index is also an objectin pandas. That's an index type object with these kind of indices, we can access for example,this a, just like we are working with dictionary for example, a dat returns a value, we canchange the values, we can add different, we can add more key value pairs. So just thinklike these.Just think this data I'll just like the dictionary object that we saw this, these are the keysand these are the values. And this is one one very good way of remembering what theseries does, and manipulating series The way we want. Okay, one, we can access a z likethis, we also can do slicing. Let's say we want to access from A to let's say C let'ssay we want to access all these one difference is when you access like this, in the normalslicing using implicit indices, for example 123 or zero, the final index is not included,but if you access like so, using explicit indices that are there, the final index isalso included. So that is one more fancy way of indexing using in this pandas. Okay. Great,that's a serious object by the way, we can create a serious object by first creatinga dictionary for example. Let's let's go back to our slides and see this example, let'screate a dictionary. For example, of plates, let's have a lot of students with Grade Agrade A minus Grade B, red b minus, and let's create that dictionary, then we can just createa series object or panda's object, by just passing this dictionary inside, we can makeanother dictionary for example, and we can make another series object. So a one way ofdefining the series object is just to is just to pass the data as well as index in otherways to just first create the dictionary and just pass the dictionary variable inside,and the series object will be created. Okay, that was just an introduction to series, wewill move on and see more features of pandas, as we as we explore it more and more in theupcoming videos. Hope to see you in the next video. Okay, let's say we have two differentdictionaries, let's say we have a lot of students and the a grade is defined to be four anda minus grades defined to be 3.5. The b grade A has a number three, the B minus grade hasa number of a numeric value that is 2.5. And similarly b grade has an American value let'sdo and then we create just a series object using this dictionary, let's say rather thanjust the numeric values as GPS or something like so let's say a grade also is definedat 85 marks in total, a minus graders defined at 80 marks in total, and similarly theseand then we create another series object, let's say named with Mark marks using thesePD dot series. So let's go to Jupyter Notebook and just play a little with these dictionaries.And build the series object, let's say marks, or let's say grades. dictionary equals, let'ssay, a grade, is has has an eighth grade has number value for RGB value for let's say,let's say we have a b grade with GPA value, let's say B is let's say it's 3.5. Let's saywe have C grade with GPA value, let's say three. And let's say Finally, we have d gradewith GPA value, let's say 2.5. Let's say that's a dictionary. Okay? What we do now is we createa grades series object, let's say using PD dot series, and just pass this grades underscoreteched. Now this capital a capital B, capital C and capital D, they will act as indicesand this for 3.53. In 2.5, they will act like values. So for example, if we call her andjust now called grades dot v dot values, so we will get, for example, what is that? Thatjust values, let's say, beget this grade stock values, and we get all the values that areavailable. Similarly, if we find grades or index, we will find out A, B, C and D. Let'sdefine another dictionary, for example, marks dictionary dict. And there is let's say again,a while the total marks are 85. For the a grade, let's say, for b grade, the total marksare let's say, 75. Let's say for C grade, the total marks arelet's say 65. And for D grade, let's say the total marks are 55, let's say. So let's saythat's another dictionary. Now, let's create a series of objects, a series object PD dotseries, series, let's say marks dictionary. So now again, we have if you just write thismarks, just like so, you will see the marks is 85, b 75, c 65, D is 55. And all the valuesthey are integer 64. Ghana values, now we can access. Now we can play with this marks,for example, if we just want to access for example, what are the marks? What are themarks between, let's say, for example, what are the marks given a at a we can access thatwe can change that we can just play like a dictionary. What if we rather than using theindex In a, we use for example, slicing, we want to start from the very beginning. Andlet's say we want to go to two what will happen? Let's see. Yeah, so, the slicing is therefor example, if you want these are explicit indices A B, C, D, these are explicit indicesand they are there. For example, if you can slice the you can slice the data using explicitindices that you are given that you are given or implicit indices that are the default indices,the first value index at zero, the second value is index two one and so on. So, youcan do that as well, one catch here for example, that we will see later on, there may be aproblem that your explicit indices they are also numeric, and then you do the slicinglike so, then the series object may be confused whether I have to use the explicit indicesor implicit indices inside we will see how to resolve that issue, but by this pandasallowed to use explicit indices as well as the implicit indices. Okay, we were here.So, he just so, yeah, so, we were here. So, we have created these grades a series objectThis marks as a series object, these the series object is good for one dimensional arraysor data with just one dimensional list or dictionary, kind of with just one dimensions,later, we will see data frame that actually is is actually the extension of curl can belooks like it can be looked like as an extension of series towards more than one dimension,we may have, for example, two dimensional arrays or two dimensional data structures,something like so. And we will be seeing this data frame which is much more powerful, particularlyfor reading data from files and manipulating it and stuff like so. We will see that inthe next video data frame that running form of data frame in the next video, hope to seeyou in the next video. Okay, in the last video, we were discussing series, and I told youthat data frame is basically if if the data has if the data in the form of different columns,for example, a record as an array, then you have another record, then you have anotherrecord. And each element in that record is a different attribute. So this particularway of two dimensional data is very well handled using data frame inside pandas rather thanseries. So but you can make these data frame objects using different series objects. Forexample, you have a great object that grades object that we created last time, you know,marks object that we created last time, let's build a data frame using these two and seewhat it looks like in in Jupyter. notebook. Let's see that. So remember, we have a marksseries object, and we have a grades series object. Let's now make grades. Maybe, maybethe name is rates, okay? The name is like grades. Okay, so grades object, this one,let's make a data frame.Let's say D, or maybe whatever name you want to do data frame with, again, that data framecan also be defined using a dictionary. Again, now we have let's say, marks is the key fordata marks. And grades is the key for data grades. Let's say let's say we define a dataframe like so. And now if you see if you just display this D, we get a very beautiful lookand feel of I mean this as the index is the explicit index at index a, the marks, themarks is 85. The grades are for at index B, the marks are 75, the grades are 33.5. Andso on that that looks like so not only that, you can just transpose it like you have transposeto a NumPy array, and you will get the flipped version or the transpose variant if you want.Great. So that's how and you can have for example, more dictionaries to concatenatetogether and more columns will be added here. And that's what the real data looks like.I mean, it has a lot of columns, which normally are attributes. And each row is basicallyone record or one sample of the data that you want to work on. So this data frame isreally, really ideal data structure for working with files, having a lot of records and youwant to manipulate the data and stuff like so. So yeah, so one more thing, let's let'saccess the D, for example, that's brand D, that's the, that's the D, let's access thevalues inside D, other than No, so what are the values, so, the values inside D is completelyagain, a two dimensional array that is completely like so. So for example, if we want to accessthis particular element 65, that is row number three, and column number one, excluding theindices at row number three and column number one. So we can access that particular valueT dot values, just assuming that dimensional NumPy array, row number three is to indexwith do and column number one is index with that, and we will be able to access 65. Wow,great. So that is there. There are more things that are available d dot for example, columns,d dot columns, columns, it will give us what are the columns, the columns are marks andgrades. There and there are other properties. And there are other several properties thatwe need to know Rs, for example, this there, we define this as di d dot index and stufflike so. Okay. One more thing that you need to know is we can repeat right now we havethat sub D, that is this one. That's the D. Let's say we want to add another column here,just we want to add another column here. And that is the name of that column is scaledmarks. And the scale marks are what if we have computed marks, rather than from 100?What if we have computed marks out of 90? What are the scaled marks up 90? So one wayto do that, and very quick way to do that is just like a dictionary, again, like a dictionary,you just add a new key, let's say, scaled marks, that's a new key. and the value issimply all the marks column divided by 90. So is that true? No? divided by 90, if wehave just completed all the marks by 90, and then how can we? How can we compute the marksfrom 90? It is rather than 100. It is from 90, I guess? How can we compute the marksfrom 90? If you want to compute the marks from 90, I guess they will look like and dividedby 90. And maybe 100 is multiplied here. I guess maybe the formula. I guess that thatthat's what it is, I guess let's see. So now if you see D, there will be another columnthat is there. And oh, it does something else. Anyways, it does something that Yeah, so somethinganyways, so we see we have just, I mean, we've just computed this, we justwe just found that we just inserted that column inside that I'm in, there is a process foreach of these kinds of values. Maybe we have added this column in a very wrong way. Andlater on, we suggest that okay, we should delete that column. Well, that's very simple.Again, using the concepts again, just like the dictionaries, delete this, and this columnis deleted from data. And you're again with the data that you had. So you can add columns,you can delete columns, and indexing is really fine. I mean, indexing like like masking,let's say, you want to bake for example, or you want to bake the DataFrame such that youwant to pick all the records such that the marks are the marks are. The marks are greaterthan let's say, greater than, let's say 70. You want to pick all the records where thebulk of the marks are greater than 70. This is that simple. All the data will be willbe copied into g with this condition. And this condition can be arbitrarily complexusing ands and ORS and combinations and all that stuff. And you have seen this kind ofstuff in NumPy as well. I mean, this is called Okay, great. So that's available in pandasas well. Okay, so that's how you can index in the next. In the next video, I'm goingto basically show you one type of problem that normally happens in real data that isthe missing value problem. Sometimes you read a data and some of the attributes or someof the row column p values they are just missing. I mean, they are not available due to certainreasons. How can you How can you handle those values? And how actually pandas suggest youto handle those kinds of missing values, which are sometimes called Nan values or non typevalues. Also, they they mostly used interchangeably in pandas. So in the next video, we are goingto handle or see how to handle missing data in pandas hope to see you in the next video.Okay, in the last video, we saw data frame object. And we saw actually how to add andremove columns how to process data, how to index how to actually mask or how to applyconditions and selections in in bond as we saw that very briefly, but in this particularvideo, we are going to see one kind of missing value, sometimes called name or not a number,or maybe not anything or sometimes this nun type none, which is the default return typeof any function. In Python. This non type is also sometimes in pandas is treated asNan or Nan is treated as none or interchangeably. Any anything. Let me give you what do we meanby that, let's say we have two dictionaries, let's say one dictionary is a with key valuea and value is one, then B and the value is two. Okay? The other dictionary is B and C.So for example, that is one record with columns A and B. So a and b are the columns. On thefirst record, the value of a is one, and the value of b is two. Now let's say we want toinsert another record in the same data frame. Now the value of b is available in the secondtime, well, if b is available, which is three, and the value of c is available, which meansa C column is added now. But for the value c the first row value is not available. Sowe will say this value is missing here. But in the second row, we have four similarly,the value of a is missing for for the second row, and that is a missing value, which issometimes called Nam. So these are missing values. And they are typical. When you areworking with data. And you're reading data on you're getting data from, from out fromsomewhere or large files and stuff like so. So pandas give some methods to handle thesekind ofthese kind of I mean, this kind of situation, let's say let's say a equals PD dot data frame,data frame, again, a dictionary, let's say we have a,one and B, let's say four, that's the first row or record. The second record, let's sayis another dictionary, let's say B is minus three, and C is let's say, nine. That's it.That's it. That's our data frame a. So now if you bring this a if you see the data insidea, you will see Oh, what's the problem? Is this and be heavy? Have you played somethingin a wrong way? Let's see. Oh, we have to create a list. That's okay, we have to createa list of it, you have to create list of dictionaries, that's the proper way of calling it. So wemissed just this index list of that. Okay, right. So now we have this A, B, just callthat a and this value is missing and that value is missing. And in large data files,this is typical, I mean, there are a lot of values that can be missing. One way that pandassupplies to hell these missing values is to just fill these missing values with some somefixed number for example, there is a fill na function, fill any function and let's sayyou supply as zero that means wherever there is a not available or not a number value,fill that with zero, or maybe any any value you want to fill that with. So that is Oneway to do that, and now if you see the value of a is all the non values are filled withthat, another kind of function that is available in pandas that is sometimes used a that isdrop na that that function drop na, what that does is it drops all the records that containa missing value. Sometimes if that is visible, I mean dropping all the records that containmissing values, if that is visible, then go for that. But if if the if the missing valuesare a lot and they are spread over a lot of rows, then dropping all those kinds of records,they will create a lot of I mean data loss and and then it becomes really, really importanthow to how to handle these missing values. However, you can fix you can fill the missingvalues using fixed value or you can drop them and later on we will see in scikit learn thatthere are other ways of handling the missing values as well, you can fill the each columnmissing values in each column using an average or using for example, a regression there areways to to handle these missing values. But in pandas, these two functions are right awaythey are you can fill all them with a fixed value for example or you can drop them andyou are ready to go. Okay great. Next, we are going to see oh as as I mentioned earlier,what is the what is the confusion between what if there is a confusion between implicitand explicit indices. And that I will discuss in the next video basically, just to giveyou a look and feel what if the explicit indices you supply they are one three and five. Andwhat if you call this this particular command one colon three, will it call the implicitindex or the explicit index, that's a problem. So we will see because 1.1 colon three, oneand three they are also explicit indices. And whether this one colon three is referringto the implicit indices that are default indices, or they're referring to these indices. Sothis confusion is there and we will see how to handle that confusion. Using this lock,LLC function and index lock ilsc function, we will see that in the next video, hope tosee you in the nextvideo. Okay, in the previous video, I mentioned a confusion that can be there, if you havesupplied the explicit indices that can conflict with implicit indices. In particular, forexample, if this is the series object, or maybe a data frame object if you want to iffor indices, let's just think about the series object, it has these values ABC with indexone three and five, if you for example, access a particular element let's say data with indexone that means the explicit index for sure, but if for example, we slice the values forexample, one colon three, the default behavior of slicing if you give an American disease,that is to use implicit indices, and by implicit indices, we mean by we mean that what is atindex one at index one this is b, so B will be printed for example, or B will be fetched,and then you move to do which is C then C will be fetched, and these are the valuesthat will be printed, but the behavior might be different, you might be expecting to useexplicit indices, which means access one colon three, and when the explicit indices are used,the last index is also included. And in that case, you might be expecting the index oneis of a so as should be printed, and index three is of B and B should be printed. Andthis configure might be there if if this is there. So to handle that there is there aretwo functions one is called l OC. And another method is called i l OC, whenever you callLLC, that means you are using explicit indices. I mean, you're forcing to use explicit index.And whenever you call, I LSE that means you're accessing elements using the implicit indexwhat whatsoever. So let's, let's practice this and see the confusion. See the detailof this kind of confusions in in here Jupyter Notebook. So let's say we have a series object,let's say a equals PD dot series. And let's say it has values as a, b, and c, NASA value.These are the values and index as let's say One, three and five let's add these are theindices let's say this is eight Okay, let's say we access a using one that means thatmeans the explicit index and that is this let's say B access and using the slicing operator.Now, this will use implicit indices and it will access I mean it will access these Band C because one colon three using indices implicit indices results that and we mightbe might be expecting that use this kind of stuff. So, if we are really interested inusing explicit indices, what should we do is we should call the lat function a lockand then one colon three that means, use explicit indices there is to remove the confusionsnow, it will use the explicit index one and three and if for example, we are interestedin using implicit indices, then it is good to use ilok function Yeah, now, one one columnthree is to use implicit indices and the implicit indices are like these. So, and like in seriesobjects you can you can you can do the same in data frame objects. Once you are usinglock and ilok then the further indexing inside these square brackets is exactly the samelike NumPy. So, whether you use log or ILOG, the indexing mechanism is exactly that theslicing mechanism is exactly the same like, like you you you have used in in NumPy. Imean all indexing that stays the same log means you're using explicit index ILOG meansyou are using explicit implicit index. Let's say for example, we have our data frame, Iguess D, that's our data frame available to us. Let's say I want to access d dot ilok.Let's say I want to access the second row completely the second record, oh, the recordthat is indexed at look at an index at two, which is a third row completely, let's sayI want toaccess that. Now this two is acting as this two is acting as, for example, if you seethe the second row or the or the row at the second index, which is a third row that iscompletely this edit returns that once you have used a lock, for example, and mostlypeople use ilok. Sometimes lock is also required. But I log is just to explicitly mentioningthat I'm using I'm going to use the implicit indexing scheme. Again, you can consider holdthat thing as a matrix. And once you have applied this eye lock, then you're free toplay with the indices, like you play with two dimensional arrays, for example. I wantto for example, I want to reverse, for example, all the rows and I want to reverse all theall the all the structure, for example, let's say I want to do that. And you can see everythingis reversed. I mean all the indexing like like nine by all indexing is there in, inpandas. I mean, once you have used ilok inside is just just remember the NumPy indexing andeverything like so. Okay, so that's the log and I log function. In the next video, weare actually going to going to just practice the pandas to actually to actually work onour data file that is saved as a CSV file. So we will, we will show you how to how toactually add how to actually manipulate read and write the data and play with the data,the data, the real data that is there in in some CSV file, and how pandas will help youto to manipulate the data very efficiently and very quickly. So hope to see you in thenext video. Okay, in this particular video, I will be talking about real data set. Thedata set I have chosen just to show you some some functions that are available in pandasto work on real data set the data set I've chosen as COVID-19 data set that was availableon kaggle. And it's surreal data set that contains information of victims recoveredthe total number of recovered people in per country per province, the total number ofdied people and the total number of number of reported people per date available thatthat data is available. Let's see the look and feel of that data in a file. Just to justto see what kind of data we are talking about. Let's say this is our data. This is the serialnumber column that contains just the record number. That's, that's a column called observationdate. That's a date, that's a province or state. That's country or region that's lastupdated when the record is updated was the time and how many confirmed cases were thereat that date, and how many deaths at that date and how many recovered at that date,as the date is moving on and on, you will be seeing that the number of confirmed casesand the number of recovered cases they will be increasing, maybe the number of deathsthey also increase. So let's see this data. Let's read that data using pandas and do somemanipulation of this data and see the look and feel of that data. In Jupyter, notebook.Let's go to Jupyter Notebook and see. So first of all, I need this pandas library and pourit that maybe somewhere I need this NumPy library as well. I'm also learning a psychiclearn SK learn library because I want to, I want to use impute function, just to handlethe missing values, it is just more powerful to use the I'm in the SK learn library thereis also a Data Science Library package that is particularly a machine learning library,or our package that actually gives a better support or a larger support of handling missingdata. Although here I have used this SK learn function just for an example. And but butI could have used this data frame fill any function or something like so but I'm justusing that one. Okay, after importing all these, what I did is I just call PD dot readCSV function, and I load that data and then I did this stuff one by one. Let's, let'slet's spend some time on all these commands one by one. And let's see in Jupyter Notebook,what is happening, let's go to Jupyter Notebook and actually read that file and do whateverwe are doing here. So first of all, import NumPy that is already imported. Import.For example, pandas that is also already imported, then from SK learn dot impute import simpleimpurity. So let's let's use that or let's Okay, let's do that. From SK learn dot imputeSK learn dot impute import simple in pewter, okay, import that because that's a new thing,we need to import that now read the data, for example, data frame in df. So df equalsPD dot read CSV. There is a CSV file read CSV. And it contains the path of the file.The path is located in my directory, it is located at this particular location COVID.And the name of that is COVID, underscore 19 ESCO data. So COVID underscore 19 underscoredata dot c s v. So let's read that file, the file will be read, if you just see that someof there is a function, let's say head that gives the top records or the records thatappear just the very top that's that's what the data file that I was showing you in Excel,it is showing just the first five records, I can show the first 10 Records, for example,just by calling the head function in this particular way. Okay, great. Let's say I justwant to remove this real number because I think that is not required. And let's sayI want to remove this particular column. Because that is also not required. There are multipleways of doing that. I can call an t l function on this. And I can call the L function onthat. But there is another way of doing that by df dot drop df dot drop and in that youjust give the columns that you want to drop one column is serial number, I guess, what'sthe column name? That's s and No. So you want to you want to drop that column and then youwant to drop this particular column with herring last update. So that is last update. So thatis I guess what is thereXs one in place Drew. So Xs one is justments. Mentioning, do do that stuff with columnsin place, equals true. That actually is, is telling that whatever this operation you aregoing to do reflect the changes in this df frame. If we do not write in place to it,we'll do everything and return onto a temporary variable or underscore variable or whateverwe are saying, but the DF the data frame will stay unchanged. So in place true means dothat changing in df variable itself. So now if we see df dot had flat say, it will nolonger be showing us the serial number column and the last updated column. What next wecan do we may we may want to rename this, this name to just date. For example, thisto maybe another, let's rename all these columns, using using the Rename function, df dot renamecolumns equals two and then we have that dictionary again in place equals two. So let's use let'suse this read in function, TF dot rename. Let's do that. And here we have columns, columns,if I spell right columns, and then that is dictionary what columns you want to change,I want to change observation date, I want to change that to simply date, let's say andI also want to change province slash state to simply simply state, our province provincethat say simply that and I also want to change this country slash region to simply country.So, maybe I want to change this country slash region to simply due to country cru and trycountry and I want all that should be happen in place. So in place equals true. So afterthat, if you run that, on this particular step, and now if you see the state of df,you will get likeso. Okay, these many, so they province country, confirm debts, and so on. So this is muchnicer form than earlier. Moreover, we may have a lot of missing values, oh, one way,this date format, the date format is not in a format that pandas internal date format.So let's convert the date format into into into the internal pandas date format, usingto to PD to date time function. So let's say df date equals to PD to date time, and convertthis df date in that particular format. And now if you run this TF dot had to might beseeing the date format in a different way. See that that's the that's that's the dateformat that the pandas is expecting. Now, we that that is just showing showing somerecords if you want to see more records, we can see those let's say I want to just I wantto just count or let's say let's just describe all the data at TF dot describe there is adescribe function that describe all most of the statistics of the data, I mean, the totalcount of confirmed cases are these the deaths are these recovered are these these many columnsare there these many values are there. The mean is that and standard deviation is theminimum 25. And these are the statistics. Let's say there is another function info dfdot d A dog info. If you call that function info, it will give us the more informationabout the null increase and the nominal increase and so on. For example, if you see the totalnumber of data columns are six, the total number of records are 6162. The date increaseis always available. The province entries are only 3700 available, the rest increaseour null increase, so province increase most of the increase or null increase and theyare there, maybe we want to drop those or maybe we want to impute those increase andstuff like so, but they are not increased that are available in the province column,some of the province, some of the province values are no longer available. Let's seethat here. For example, this is not available, this is not available, this is not available.And that's what the real state of the data is this is not available, this is not availableand so on. So this can happen. Okay, next, what we do is, we actually be actually usethe simple computer just to impute the missing values. One ways to do that using simple mburofrom SK learn. Another way is, as we already know, just df dot fill na fill na with, let'ssay a bit let's say not available with let's say a string, some string not available, that'sit that string and with that, if you fill that fill any using that now, after that,we will be having all that data, the missing values will be filled according to Let's seesome missing values because in the province there were some missing values. Now you cansee for example, let me go on and left Yeah, so not available not available, we can wecan use that or we can use a fancy kind of thing that is available by a psychic learnand so on. Okay, after that, if you now see the information info, now, you will not beseeing any null value, all the columns are there, oh, this was not in place. So don'tfill na that is let's change the DF with it. So this doesn't happen in place, df just changedthe DF. Okay, df changes. Now, if we now call the info, there is no null value anymore.Yeah.So I am this video here. In the next video, I will show you this group by command to justsee these kind of stuff in a more detailed way. Because this this particular video isgetting lamp here lanthier. me I'm stopping here in this particular location. Next time,I will show you the group by command in the in the panda's data frame. And I will showyou what that does. So, we will explore all that code that is written here. And we willhave in the in the upcoming videos when we will see the plotting and matplotlib we willbe using the same data file to work more. And to get more insight how the how this pandasand matplotlib and NumPy in combination how they can actually how they can actually playa very important role in analyzing a very, very large real data files. Okay, so I endthis video here. I will start the next video right from this command. And I will tell youwhat is happening what is the scope baikman so hope to see you in the next video. Okay,in the last video, we were discussing this COVID-19 file, and we reached here but wedidn't use this SK learn in pewter, we just use the fill na function of data frame. Nowlet's discuss this group by command or a Curie in in pandas that is much more visible. Let'ssay our goal is now for example, if you go to go back to Jupiter, if you see your deardf dot head, or all, at the D f dot head, let's attend records. If you want to see thatthere are so many records, let's just see 10. Let's see, what you want to do is youwant to just see how many, how many total confirmed cases are there in each country,regardless of their date. And, for example, you want to just see all the all the all theconfirmed cases, all the deaths, and all the recovered cases in each country for all thedates and for all the provinces combined together. One way to do that is to write a group bycommand for example. That's a df two equals df dot group by and in group by what you seeis for what kind of columns you want to you want to group all these all this data. Sofor example, you want to group by country. country. So that's your grouping. Now aftergopeng What do you want to see what kind of what kind of what kind of, for example thevalues you want to see because now you're dropping? Well after grouping I really Wantto see because data is gone once I drop, all the dates, they are grouped together all theprevents that are grouped together. So, what I really want to see is just the country andI want to see the confirmed cases. So, pick all these records confirmed, and then I wantto see deaths and recovered. So, for example, if I want to deaths, and let's say then Iwant to see the recovered cases are E and just I want a big group all the countriestogether group all these things together and add all the records under each country. Sosum all of them, and maybe we want to reset any index if it is there. So for example,preset, we set index. So that So, after this Curie For example, this group by query, whatwill happen is this df two will contain a summary of the data with respect to each countryand the total for example, in this particular country, the total confirmed cases are theseall confirmed cases till now, and the deaths of these and recovered as these for this countryfor each country, now, each country is describing Australia for example, in our till, till now,Australia has total these confirmed cases, these total deaths, and these are recoveredcases and so on. So, that is if we want to group all these with respect to country, whatif we want to group all these with respect to country and then date for example. So,first we want to group them by country, so country and then for each country, displayall the dates, and then do the same stuff, the the Curie will stay almost the same. Agroup by command will say almost the same with one kind ofwith one kind of let's say we want to first group by country, once the, it is groupedby the country, then I want to group them by date. And now I want to see all the resultsin the form of I want to see the data as well. And what will happen now is for each country,its trend with respect to all the dates that will be displayed here. So let's see df twonow, df two. So if you see df two now, you can see, for example, this particular country,it has just one record in this country, it has one record, then this country for thisdate has this record for the same country and other date has same record and all thedata is also sorted. I mean, now you can see all the records in a very incremental way.So that may give you a very good look and feel of what is happening or, for example.Another thing What if you want to what if you want to, for example, find out all therecords, all the records, you just want to find out all the records? Let's do three,four, which the the confirmed cases, for example, the confirmed cases are are more than 100.Let's find out all the records. Let's, let's let's let's get just let's just pick all therecords for which the confirmed cases are larger than 100. And let's copy all theserecords just those records in this. So if we do that, we have d3 available, and we haved3. This, I mean, these are just the records in which the confirmed cases are for surelarger than 100. Just those. Yeah, so we can do. I mean a lot of a lot of data analysis,the real data analysis, a lot of a lot more, I've just shown you a very small snapshotof what we can do with pandas on the real data set. I mean, there is a lot more thatwe can do with this pandas library, on real data sets on multiple data files, combiningthem together, joining them together, seeing their correlation, a lot of stuff. And thispandas really is a very, very fancy and very high level library, very high level packageto work with data. So due to time limitations, I'm just ending this pandas here althoughthere is much more to explain in that, but in the next video we will be jumping towardsmatplotlib just we will see some some functions of matplotlib. And we will see very brieflyhow can we plot How can we analyze data using visual graphs or stuff like so. So, that thatsometimes this visualization of different attributes of the data give very good insightto the data wherever possible, wherever possible. If the visualization is possible if the datadimensionality in a way are the visualization techniques are in a way that you can visualizethe trends in the data, that gives you much more much better insight than the numbersor statistical results, but it completely depends in what situation you can visualizethe data there are situations, high dimensional data, for example, is not always visualizable.So, in those cases, the statistical results of the numbers may play a more important role.But in more in many cases, visualization give a very good initial insight into the dataand the design process can become very, very fast if you know something about the data,whether you get that information by visualization or by other statistics or whatever. So, inthe next video, I will be just explaining some very few functions of matplotlib. Andthen we will be, then we will be exploring the same file, and we will be doing some stuff.Doing some stuff using the plots and matplotlib. And doing, seeing the trends of death rates,seeing the trends of I mean, we'll be playing with this file a bit more using matplotlibas well. So hope to see you in the next video. Okay, in this video, I'm going to discussmatplotlib a very powerful package for plotting graphs and scatter plots, line plots and 3dplots and plots on the globe and whatnot, I mean, very, very powerful tool. The mostimportant module in this matplotlib, or the most popular module, or the most used moduleis biplot. So we can import matplotlib.pi plot as PLT. Another way of writing the samekind of stuff is we can we can write like from Matt matplotlibfrom matplotlib import by plot as PLT. So either way is fine whether we write this asa documentation or that one that is fine as MP is for NumPy. So let's create some points,just just just make our first plot. Let's, let's make some points starting from zero,let's say all the points starting from zero till 10. And let's create 1000 points in between.One way to do that is to use built in function or a method in NumPy, which is linspace orlinearly spaced points starting from zero ending at 10. And there are 1000 of thosepoints. Let's say this is our x and this is our let's say y which is NP dot sine, thesine function is actually will apply element by element on this NumPy array. And then thisPLT will plot will actually plot x comma y all the points in front of you. So let's goto Jupyter Notebook and actually see this matplotlib in running form for the very firsttime, oh, we have seen this matplotlib. When we saw NP dot random, we only plotted a histogram.While this is not the first time we actually have seen this once, once, once before. Soimport mat plot lib.pi plot as PLT. That's your import command. For example. Now PLTis available. Let's say x is NP dot Lin. space. Let's start from zero. Go to 10 and generatelet's say 1000 points. That's it. That's your x, y might be your MP dot sine x. That's it.That's your y. And then what you do is you say okay, PLT dot plot, x comma y point bypoint, and then you press Shift, enter. That's it. Oh, this plot is there in front of you.That simple. I mean, that simple. Can you imagine? This? Is that simple? Yeah, thisis that simple. So I'm in plotting. This is a line plot. For example, if we want a scatterplot,we can say okay, PLT dot scatter, there is a scatter function that allows us to plotall these endpoints form rather than rather than this line form. These are all these alot of points. That's why you you're not seeing these scatters. So let me let me let me takethis n x s viewer. Let's see. Let's take x as let's just take a few points, let's sayjust just just 30 points. Let's see the corresponding 30 points, see, they remember the indexingof NumPy arrays and just using that. So now use the scatter plots, and you have this,oh, that's a scatter. Maybe we want to use, let's say, start from the very beginning,due to end and big every, let's say, attempt point. And do the same with why, just to justto see a plot in a better way, just sample some points. So that's the scatterplot. Itis just like I'm in the points and so on. It is not a it is not a continuous plot, likethe line plot, it's a scatterplot, we're going to annotate this scatter plot, we can changethese colors to any color we want. For example, we can we can have a prop property, for example,color is equal to let's say, red, and everything will become red. Yeah, so that's right, wecan have I mean, we can label it we can x label it, we can via label, there are a lotof properties. But but the but the main point is plotting is that simple plotting is thatquick, using matplotlib. So yeah, this matplotlib is really, really powerful, we have just seena snapshot, just a plot function and a scatter function there, there are a lot of propertiesto be said, there are a lot of things to be considered. And we will see we will see actuallyone one lanthier good use on this COVID-19 file. And we will we will actually analyzethe data trends and the confirmed trends and some trends that and we will plot them andsee the trends really using matplotlib. So But before that, let me let me show you that.If you call for if you call this plot multiple times, for example, maybe with different colors,then you will be having a lot of curves on the same on the same plot, for example. Sofor example, let's see PLT dot plot x comma y, let's say with with color, let's say colorequals to blue.You can write blue, the whole or you can like write just be that's fine PLT dot plot, x,and let's say NP dot cause x and the color you are interested in, and let's say the coloris, let's say green. And that's perfectly okay. And that will give you two plots inthe same figure, sort of, and you can just good to go. Well, yeah, so that more you can,for example, you can plot with a green, green color, and you want the solid line, or youwant, for example, Seon color in a dashed line, or you want a dash and dot black lineor, or maybe you want to completely dotted line in red color. So there are several thingsthat are available in matplotlib. This is just a very few very simple snapshot. AndI have given you a very quick start in and actually actually the whole point is usingMatlab is that quick, I mean, you can you have your data, you just plug in their data,you just call the plot function, and you're good to go for analysis. Okay. In the nextvideo, we are where we will actually walk through the we will actually walk throughthe COVID-19 data set. And we'll actually analyze the trends and to add the death ratetransfer each country individually, and then we will see the depth confirmed and the recoverytrend of the overall world till the 16th of March till the day till the data data is available.So next video will be actually the viewer will see the running form of pandas and matplotlib.Together, so hope to see you in the next video. Okay, I already have shown you the COVID-19file. And here I have a notebook on that that uses matplotlib and pandas to find out thedepths conformations and recovery trends using using different plots. So let me import allthe packages that I need. I need a plot by plot function from matplotlib. I need pandassomewhere I need NumPy. And I'm using a simple mburo here for missing values. So let's runthis. Let's run this command. And yes, everything is imported. Now let's load the data thatI've shown you earlier. The data is available now. And let's run this thing that is thefirst 50 Records. Yeah, remember that? Yeah, so that's the data that is available if ifyou just want another view another view of the data That's the data file, which is COVID-19file. And it has observation day province country, last update, confirm, to date, deathto date and recover to date for each country and for each province individually. Okay,great. So that's what we have. Now what we can do is, now let's drop the serial numbersand last update using in place that and rename the columns that we did already in a previousvideo as well. Let's convert the date into the pandas built in date, frame. Okay, let'suse the psychic learn in pewter, sk learn in pewter, using the constant strategy, thereare a lot of strategies there, let's use a constant strategy. And this period or dataframe, in pure dot fit transform that will help imputing all the missing values witha constant strategy impure. So that's there. Okay, next, let's apply this group by commandand group all of all the records using country for each country. And for all the dates, let'ssum all the records that sum all the values of records deaths and confirms using this,but now let's first country and then all it state, then the second country, then all itstates and so on. We have seen that in one of our previous videos just running that again,just for a double check. So that's what the data state is. So country one all it statescountry to all it states. So this country has a lot of dates, then another country andso on. Next, let's see how many countries are there. In total, how many unique countriesare there. So what I, what I do is I find the column, I actually pick the column withcountry and call a unique function on that. And that gives me all the countries withoutrepetition. And I just compute the length length of countries tell me how many uniquecountries are there in this data file?There are 171 countries. So now my goal is for each country, I want to see what is thetrend of with respect to the date as the data is moving from the first day till 16th ofMarch? What is the trend of death? patients? What is the trend of recovered patients andwhat is a trend of confirmed patients as the data moves on. So because we have 171 countries,so let's loop over each country again, again, and again, let's loop over what we do is forID x in the range of this, that's the loop you remember that. And what I do is let'sfind out the indices where the country is like this, let's find out the index all theindices where the country is like that. Then what do you do I make a scatterplot. That,with starting from this, and that, I just pick the confirmed cases and all the confirmedcases for this one country, I just pick those. And I look, I do that using this scatterplot,then I use another scatter plot, just to get all the recovered cases, then I do anotherscatter plot to get all the depth cases. And then the title of the title of my figure becomesthe country name, the x labels the days, days since the first suspect, the wire label isthe total number of cases, the legend command actually will be there that will show whateat that is in. So these kinds of labels that are rewriting here, they will appear in thefigure, then we force them to show that in each iteration show the show the fourth. Sothis will show the trends of confirms to cover some deaths for all 171 countries one by one.So if we run this command, we'll be having 171 plots in front of us. Let's see all ofthose one by one. So yeah, so this is for the country. It has just one such thing. Thisis for that this is for Afghanistan. As these moves on the confirmed cases that are evenblue, they are moving up. These are the number of cases. These are the number of days sincethe first day. And the green is the number of recovered cases for Albania. That's thetrend for Algeria. That's the trend. I mean, these are each and everything is a separatethat is for Argentina. That is for America. This is for America till 16th March, by theway, today. The new says that America is really in as dangerous position anyways, that's forAustralia till till the date we have to do that is for Austria. Yeah, so these are allthe trends for all the countries. You see I'm in the matplotlib how powerful that is.Although I walked through this code very quickly, but you can see this video again and again.And then check how that happens. Yeah. So that's what this is for Finland. Oh, Finlandis also in trouble. So France. Okay. So that is for Germany. And yeah, so all the countriesthat are available in data set, they have these kind of plots. This is for Hong Kong.And this is for India. And this is for Italy's or Italy's. Yeah. So that's it. So that isfor each country individually, what if we want the overall trend, or the overall confirmand the deaths and the recover trend for all the world together, so what I do is I bigI grew up all the data with date. So I pick the first date, and add all the records, thenthe second date for all the records for all the countries and so on. And then I plot thetrend using the scatterplot, again, confirmed record. And that's for all over the worldand see the trend, where the world is moving. So that's the trend of the world. As the daysare going on, these are the depth grand, that's a recovery trend. And that's a confirmationtrend that is moving on. Although I walked through or this notebook, the notebook willbe available to you. I walk over this notebook very quickly. But the goal was really to showyou the the I mean, that was a file may not be that informative, if you see that in Excel,but now it makes much more sense. When you see these blobs you know what is happeningand you have insight in the data. And later on, we may we may want to predict we may wantto make predictions. And the next date what is going to happen, we may want to predictusing this plot or using some Machine Learning Library like psychic learn or TensorFlow orsomething like that. Okay, so that's it. I can talk much more about pandas NumPy matplotlibof there are so many other data science packages, very important packages, one of those is SKlearn, we can that is for machine learning basic machine learning. Then there are otherpackages like TensorFlow for deep learning by torch for deep learning. There are a lotof packages with a lot of speciality is in data science and stuff. I just discussed afew of those the most important of those do to manipulate the data to make predictionsto make classification or regressions. For one, one way is to go to SK learn or psychiclearn. And if the data is huge, and you have a lot of large amount of data, and you havegood expertise or deep learning, then you should go to either TensorFlow or pytorchthese are the Python packages that are available for predictions, classification, regressionand a lot more, but either way, whether you are going to use scikit learn whether you'regoing to use TensorFlow or pytorch either way, you have to use pandas NumPy and sometimesmatplotlib to pre process the data and to make the data ready for for these kind oflibraries to to perform predictions, either a either in the form of classification orin the form of regression. So so so this whole course was about for for beginners who wantto who want to learn Python, specifically, I discussed a lot about the in a lot aboutPython in general, then then then I spend some time not a lot amount of time sometimeson exploring the data science packages as well. But, I mean, there is no end we canexplore more, we can talk about the packages more we can talk about other features of Pythonmore, a lot of I mean, input formatting, output formatting, modules, packages, standard templatelibrary, file handling Internet Access database,I mean,this is a whole universe, I have discussed a few things for beginners. But But thesefew things were very carefully selected for data scientists. The if you have this courseavailable to you as you have gone through all the course, you now have a very very goodunderstanding and now you can you can move towards further edit advanced courses towardsdata science and you will be ready to implement the concepts in Python using using the packagesI have discussed so far. So I thank you all and good luck.EnglishAllData sciencePython pandasC++RelatedFrom freeCodeCamp.orgRecently uploadedWatched
-
字幕プレビュー