Python for Data Science - Course for Beginners (Learn Python, Pandas, NumPy, Matplotlib)
"WEBVTTKind: captionsLanguage: enI'm going to talk about the focus of our coursemastering Python for beginners in data science.So let me explain what kind of areas in thisparticular 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 anyexperience 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 problemsolving for a bit. And we will actually startfrom the very beginning what problem solvingis, particularly in computer science. Thesecond focus of this particular course, ismainly telling you why we are choosing Python,why Python is so important, particularly fordata 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 thatPython 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 startfrom the very beginning, very, very beginning,which means we will start from how to installPython for example, we will start from there,and then we will see what are variables, Imean, very, very beginning, and then progressivelywe will be moving on and on and on to datastructures to complex structures, but thattransition from 02 onwards, that transitionwill be very, very smooth. I mean, whateveryou know, so far, in the course, that willbe helping you to gain more complex structuresvery, very easily getting the understandingof a lot of structures very, very easily.So in this Python, we will include all conceptsof Python in general. And, and one more thing,after I mean learning, despite on the waywe the way we organize this course of learningthis Python, you will be having an understandingof other languages as well. I mean, the contentshere are explained in so general way all overthe Python syntax, but the general but butbut the concepts are expressed in so generalway, the problems that we picked to solvefor practice are so generic that you willafter this particular Python course, you willbe having understanding of programming languagesin general. So data science is one other focusof this course, actually, the whole courseis 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 toachieve the solution of different problems.And and using Python, of course, and thenwe will be introducing the data science packagesthat are available in Python, because theyare really, really fast, really fundamental,very easy to use, and very, very powerfulto 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'simportant. 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 exceptionhandling, we are not doing web development,or any general kind of tasks that are doablein Python, we are not focusing on those things.Everybody solves different problems everyday. Some problems are easy to solve, andsome are difficult. And yet some are impossibleto solve. They are called unsolvable problems.But think about different instances of thesame 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 haveto do it after every eight hours. If the numberof instances if that number is huge, the optimalchoice is to automate the solution if theautomation is possible, but how how to comeup with the automated solution to come upwith a general solution that works for everyinstance of some problem. That is one thing.But to get that solution running on a computeris yet another thingProblem Solving deals with formalizing a generalsolution for that works for every instance.And programming languages, like Python dealswith the running of that solution on a computer.Python, as, as we will see, makes the transitionfrom problem solving to the running solutionmuch easier and quicker. And that's one bigplus of Python. A lot of words, I know a lotof words. Let me take an example to clarifywhat I said, Hold on till the end of thisvideo. And I will make everything what I saidso far, crystal clear. So let's take an example.Let's dive into an example to see what I justsaid. Let's say your a, and your friend isB. And your friend B is always willing tohelp you. Let's say you found such a friend.And then a just said, I want off just forsome 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 justsaid, Hey, wait, what do I have to do? What'syour job? At the end of the day, I'm goingto 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, whereare the records? He said, Well, there aresales records. I mean, at the job place, thereare 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? Thenhe said, oh, there is an other record calledpriority records, just write that email aftereight hours, just write that email in purityrecords. And then be said, that's it. That'sall 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 reallyknow what to do. Can you tell me step by step?What to do? Focus on again, I'm reading thisparticular sentence again. Can you tell mestep by step what to do? I have sales recordswith me having all the records for the lasteight hours, what to do, I just messed everythingup. I don't know what to do. And then at thecall, he just described a procedure to befor 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 customername, the customer phone number, the customeremail, the customer products that he buysand 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 recordone by one, and find the record with a maximumsales. Obviously, once you have focused onthe sales column, you're just comparing salesof different records with each other and willeventually come up with a record that havemaximum sales. Number three.If there are more than one records with maximumsales, it is possible that the maximum salesvalue let's say is 100, whatever the unitsare, and there may be two or three or maybefive records with the maximum sales 100. Thenwhich one to pick, as described here in Stepthree, that if there are more than one recordswith 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, whichrecord appears first from top to down, justpick that one and ignore the rest. That mightbe a policy that might might be a tie breakingpolicy, but just do that. And then the fourthstep is focus on the email column of the recordyou found in step three. In Step three, youfound a column with maximum sales. Step five,see the email address and write that addressin the priority records. So that's for theeight hours, then repeat this process, seethe step six, then repeat this procedure,after every eight hours, I'm gonna repeatthis procedure, I mean, you'll see the thesolution a is communicating to be in in thisin 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 mayask how to find out a maximum, B might bethat person who don't know how to find outthe maximum. And third, for example, anotherquestion we might may ask is that when whenI'm going to write the email address in thepriority rock records, where should I writeat the very top or at the end or somewhereor, but at the end of the day, a solutiona step by step solution is required for communication,this kind of if you see the solution, althoughit has some it may be explained in there maybe more steps that should be added, but ifyou see the solution, the step by step solution,this is a general solution. This is a generalsolution, much more general solution for everyinstance, but every instance I mean, afterevery eight hours, you will be having somerecords, and you have to do this procedureon the records for that eight hours. And thenafter that, that after that eight hours, youwill 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 eighthours 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 stepby step solution, coming up with a step bystep solution is is one module of the onemodule of the problem solving. And there'sstep by step solution is called algorithm.algorithm. Obviously, the step by step solutionis not always required to be communicatedin plain English or in natural language, youmay come up with shorthands or shortcuts toexplain these step by step solution. So, thethe more shortcuts the more precise and uniquemeaning keywords you use in your step by stepsolution, the more better communication ofyour solution takes place. And going fromthis step by step solution, which is justin plain English, going from this to a moreconcise and unique kind of procedure, thatthat can that kind of work that one step thatwill take us from there to there, that wewill see in the next video will be calleda pseudocode. And from that pseudocode therewill be few steps that will take us to thesecond major problem that the problem problemlanguages will solve the get the solutionrunning on a computer. So I'm just just inthis video i i wanted to explain you thatsolving a problem may not be that hard, Imean, coming up with a coming with comingup with a solution of a problem may not bethat hard, but communicating that solutionor, or writing that solution in a form ofprocedure that can solve every instance ofthat problem that that requires a step bystep treatment of the procedure. And thosethose steps they should be linked in a sequenceand they should be unambiguous. And if a particularstep requires more elaboration, that stepmight be broken down to further steps. Butthat step by step solution at the end of theday is called algorithm. Now that algorithmmight be in English, but we will see in thelater video that there are better ways ofexpressing 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, everyinstance of that problem should be solvedby that step by step solution, which is calledalgorithm. And in the next video, we willsee how to actually how to actually eliminatethe need of having English with us and howto incorporate the uniqueness of understandingof 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 seethat the Python is very close to what humansgenerally think, I mean, it's very easy, thetransition will be very, very easy. So, hopeto see you in the next video and I'll be explainingalgorithms in in, in a in a more kind of keywordway. And, and in the same video we'll be focusingon pseudo codes which are basically pre stepoff of the actual core of any programminglanguage. So, hope to see you in the nextvideo. Okay, in in the last video, we weretalking about the algorithm what an algorithmis and how to express that any any algorithmand we saw that algorithm is just a step bystep procedure. But, but how to express analgorithm may vary, I mean, you need not alwaysto have plain English to or any natural languageto 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 ideato come up with a structured way to expressan algorithm such that each and every statementis completely unambiguous. And one such wayis is to express algorithms using flowchartsflowcharts are our graphical ways of expressingalgorithms. Here we are taking. The problemhere we are discussing is is computing PEof different employees of some company. Andthe procedure of I mean, if there are severalemployees, let's employ one employee to employthree and so on. Let's say there are severalemployees in a company and having each employeehas name, phone number, email and all thecredentials. And then let's say the pay iscomputed on hourly basis, and each employeehas worked certain hours for example, eighthours and each employee has an hourly ratemight be let's say 100 units, whatever theunits areemployed to might have worked for example,seven hours, but the hourly rate of this employeemight be 200 different employees, they mighthave worked for different number of hours,and each employee can have a different hourlyrate depending upon the capacity of the employeeor the or the job nature the employee is doingand so on. So, so, so, if we want to computepay of all employees, one by one, the procedureof computing pay is stays the same, the instancesthey differ for employee one, the value ofour is eight the value of Raiders 100 foremployee to the procedure will stay the samethe values of our end rate they will differso what should be the procedure, the proceduremight be that you take the take the inputof let's say employ one or whatever employeeyou are going to compute salary for take thehours hours value in a in a placeholder callthat place or call that placeholder as oursplaceholder or a variable y this is calleda 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 willtake value seven for employee two and so on.Similarly, once whatever employ whatever employfor which you are going to compute the pay,if you have taken the hours from some recordsfrom some working records, then take the ratefor the same employer as well. So input thisthat step one in Purdue that is step two,the steps the sequence of these two stepsmay change for example, you take the you takethe rate value first and ours value laterthan that, but either way, that's one wayof that's one way of expressing this thisprocedure. 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 symbolbecause 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 thisis 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 isa 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 inputshould stay everywhere wherever we want todo such kind of operation. If you if you'reusing for example, the value get rather thaninput then use get always but come up withsome set of keywords that are expressive,as well as concise and then take the sequenceof those statements, each and every statementshould be should have a unique meaning, itshould not be ambiguous, and the sequenceshould be in the sequence describe the flowof what is happening, what is going on. So,first we take hours, then we take rate thesetwo values for for for any kind of employee,and then we will just multiply them and aftermultiplication, 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 maywe may print that value on a print slip, wemay have emailed this value to some otherdepartment or whatever to see and we wantto make, but the procedure really is stillhere, then based on pay whatever action weare going to do that that may differ. Similarlyif we go this is this is I mean, some kindof structured example of, of the, of the expressivenessof an algorithm which is called pseudocode.And what kind of keywords you're going touse, there are no general keywords, I mean,some people may use get some people may usedifferent kinds of keywords for it, but itis good to come up with a set of keywordsto to describe the describe the solution ofthe solution of the problem in flowchart forexample, everything every every statementhere, that is here in in pseudocode everystatement 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 thestart symbol and end symbol the start andend of any procedure in flowcharts they aredescribed by the ovals For example, this ovalin that oval normally the flowchart sequencesfrom 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 thereare 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 coolway of writing. expressing an algorithm andpseudocode is also a way of expressing analgorithm. Well, converting flowchart to actualprogramming code is somewhat tedious, writinga pseudocode beforehand, which is readable,which is precise, concise, as well as unambiguousthen converting that pseudocode to code ofany programming language, that is not thathard, that is simple in writing flowchartsfor very complicated problems is somewhattedious, because then it It also requiresanother transition from flowchart to reactiveprogramming code. That's why writing pseudocodeis more feasible, if the goal eventually isto convert that pseudocode to some core ofprogramming language. So, you can go withflowcharts you can go with pseudocode eitherone is fine, but more feasible way of expressingalgorithms is a pseudocode. That was justa very simple example. I mean computing, computingsalary of an employee writing a procedurefor that. I mean, this is so simple, nobodymake your writing that kind of writing solution.have this kind of problem as a as an algorithmor as a pseudocode as a flowchart. But thebasic idea is, is is is the same, even ifyou 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 procedurehow to how to make tea for example, that mightthat may look look to you funny, I mean, dowe really want do we really want to know theprocedure to make tea? Well, the idea is notto learn how to make tea, the idea is to learnhow to express the solution of this problemmaking tea that's a problem, the solutionof this for how to how to express solutionof that problem as as a pseudocode. And wewill see one more example of flowchart aswell. So hope to see you in the next video.Okay. In the last video, we saw flowchartsand pseudocode, we just took an example ofwe took a very simple example computing salaryor 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 thecore of some programming language, which eventuallywe need, because eventually we need automationof of a solution of a problem. And for that,we need a code of the digit the code for thesolution, the general solution in some programminglanguage, so flowchart and pseudocode, andthen the core of some programming languagelike Python,it is somehow in sometimes handy to to breakthe problem or to devise a general solutionof any problem for in first step in a flowchartbecause that is more expressive, and moregeneric, more general, maybe in a graphicalway. And then once the proof of concept isclear, once it is clear that this is indeeda general solution, it has no bugs insideit has no errors, it will work always, thenwe can take another step to convert that flowchartto pseudocode. And then pseudocode can beconverted to the the code of any the codein some programming language. But writingpseudocode right away, I mean, from the verybeginning without flowcharts is also a commonpractice. Either way, whichever way suitsyou. In this particular video, I'm going totalk about problem the problem is making tea.You might be thinking, what are the differentinstances of this problem I'm in making teais making tea. What what kind of differentinstances are there? Well, one person maybe liking tea with, for example, 1.5 unitsof sugar, whatever the units are, and anotherperson may want a tea with, let's say, twounits of sugar, one person maybe, maybe needinga D with, for example, point five units ofmilk, and another one, maybe a different unitsof milk, and so on. So the procedure of makingtea should stay same. And the instances whichmeans the different people want tea in a differentkind of combination that may vary. So let'slet's like let's see a procedure first andflowchart. And then in pseudocode, for formaking a tea, for making tea. So let's startthat 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 algorithmfor this? So first we start and then the firststep we do is we put teabag in a cup, thatmight be a first step. You can argue shouldthis be a first step should that be the secondstep and so on the sequence of By the way,solving one problem, you can have multiplealgorithms for that. And do different algorithmsmay just vary because of the sequence of statementseven if you have the same statements. So I'mnot talking about that the algorithm or thegeneral 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 stepmight be the boil, boil the water and pourthe water and pour the water in the cup andthen put the tea back. Both are fine, I meanthis way or that way. So let's start withputting 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 teabagin a cup and then forget about that cup andboil the water somewhere there is a waterI mean take the water from somewhere and boilit and see if after let's say five or sixor seven time units whatever the time unitsare, see if the water is boiled or not assumethat there is a test that tells you that thewater is boiled or not. So, there is a testavailable to you. So, you apply that testand check that the water is boiled or notif it is not oil then keep on boiling. Soboil it again. And assume there is a procedureof boiling of water in in in normal case,boiling water is just happened by I mean keepingthe temperature high or putting that thingputting the pot of water on fire or somethinglike so, but that that itself is a procedure.So,while the water again and boil the water againcheck if the water is boiled if no then boilit again. If not boil again then check ifno then boil it again this is called a loopthis is called a loop or repetition you aredoing the same kind of stuff again and again.Until there is a particular condition thatis that is met. So in this case, the conditionis when while the water is not boil, keepon doing the same procedure again and again.This is called repetition or loop. So youboil the water again, check the conditionif the condition is true, for example, thewater 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 describethat is that the same cup or a different cup?Well, this see you pick up here is actingas as a placeholder where this tea bag andthe water is going in. So we have a cup, weput teabag in it, then we put the boil waterin it, but before pouring the boiled waterin it. We just boiled the water. Okay, andthen after we have water in a cup and a teabag in a cup, what should we do next? We actuallywe actually first test one sugar or need moresugar? 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 thewhile you want sugar. I mean you test thatthe sugar is okay or not. Here you test thatthe sugar is okay or not or whatever sugaryou need. If Is that okay or not? Until thatcondition is not met, you keep on adding thesugar, add a teaspoon again, then test outa teaspoon that is again a loop or repetition.Once the condition is met once you know thenexit this loop and ask what milk because somepeople just take tea without milk. Maybe somebodywants a milk maybe somebody don't. So wantmilk? Yes. So add milk. So that's that's amistake 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. Thisline again shouldn't be there. So that that'sanother loop. Once you exit this loop, thenthe T is ready, you serve that D finish you'redone with the procedure. Now let's see thesame procedure in pseudocode program is thekeyword and that's what program name is programmake 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. Whateverwritten in while and while is is the bodyof this repetition are called loop. So whilewater is not boil, boil water. Then againcheck water boiler not know what again. I'min keep on boiling. So this is repetition.Once the water is boiled, which means thiscondition 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 thisuntil you don't need sugar anymore. So, that'sagain a loop. So, so, you might be thinkingthat why we are writing this add sugar andthis boil water to writer to this this whywe are really indenting this that style ofpseudocode to just display that this is insidethis this is this particular statement orset of statements are called the body of theloop and this end Oil should be here in thisalignment here in this line and so, thereis a there is a bug in this slide this shouldbehere okay once this condition is false sugarneeded 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 becomesfalse milk needed no then you can exit thisloop, you can just go to here. While latesthere need to steer steer D need to steer yessturdy he was there yesterday, once this conditionis false get out and your tea is ready Dowhatever you want to do. This example wasso 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 procedurewhatever procedure you want to repeat againand again to until there is a particular conditionthat is met that is loop loop is there. So,the The purpose of this slide is was justto just to make you make you convinced andmake you comfortable with the pseudocode andflowchart we will not be talking about flowchartsany further from here on we will we will bejust talking about pseudocode in just oneor two more videos. And then we will be directlygoing towards from we will be we will be comfortableenough with pseudocode for solving certainkinds of problems that we will then eventuallybe moving from pseudocode to actual Pythoncode. And and I bet you I'm going to tellyou that the pseudocode in the next videoI'm going to explain that will be very, veryeasily will be converted to the actual exactPython code. So in the next video, we aregoing to actually solve a problem of findingout minimum value from a list of values, sometimescalled the searching problem, we're goingto solve it by first using pseudocode. Andthen in a later video, we will see how towrite 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'ssay, let's say l is some list. with numbers,let's say we define list by these, these squarebrackets, let's say the list contains 23.Let's say that's a value minus four, thatvalue is zero, that's a value 73. That's avalue, and maybe maybe minus 10. That's avalue, maybe 13. That's a value. So let'sjust take an example that we have 123456 valuesin a list. So and that list is basically wetook the list here as L and we just describethat let's say the list is declared by orexpressed by the square brackets, and theelements of the list, they are separated bycomma. That is just our convention for thiskind of problem for this problem just forthis code. And And I'm not talking about anyparticular programming language yet. Thisis just a list of numbers. And let's say wewant a procedure that finds out the minimumvalue of any list. Well, first of all, whythis problem has multiple instances. Well,we need to come up with a solution that worksfor any list for example, if the list is ifthe list has these six values, then the procedureshould find out the minimum In this list,the minimum value in this list out of allthe values is minus 10.Because minus 10 is smaller than every othervalue. 23 is bigger minus four is smallerthan 23. Zero is bigger than minus four, becausethe, the value with negative sign, it is smallerwith the value of a positive sign. But ifyou have two values with negative signs, thevalue with a bigger number, in terms of magnitudeis actually smaller in negative sense. Soif you compare minus four and minus 10 minus10 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 generalsolution for that, that's less just go andfind out the minimum that is minus 10. Gohome happy? Well, we need a solution thatworks for another list. Another list withdifferent numbers. And maybe different numberof numbers. Maybe in this list, we have sixnumbers, 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 thanonce 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 tofind out, we want to come up with a procedurethat finds out the minimum value, regardlessof the list, whatever the list is, this procedureshould actually return or end up finding outthe 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 seehow to code a procedure for that. So but butbefore starting this procedure, what kindof things we really need to to, to write apseudocode. For this kind of problem, we maystart by writing that program, like in theprevious video, program name as search. Andthen we take input or input list, then wetake input, the number of values in the listthe total number of values, and then we moveon as as we want to move on. But writing outa procedure in terms of pseudocode, it isalways good to to avoid these input statementsinside 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 particularinstance from inside the code, it is alwaysa good practice to, to, to supply the instancefrom 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, inthis 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 programand then this, just write the name of theproblem you're going to solve in this particularcase the name is search minimum from list.And then this particular we are talking aboutthis list l with total number of elementsas n whatever the values inside the L is wedo not know and and this n may take differentvalues, l can be different, this n can bedifferent for different instances. But itis not a good practice to take input frominside here. Then, one more convention isthat, let's say list of two represents thesecond element in the list. In this particularcase, L of two is basically L of two is basicallythe second element in the list, which is minusfour, L of let's say three is the third elementin this list, which is a zero, and so on.So let's let's take a convention, that wheneverwe want to access the elements of the lists,whatever whenever you want to read the elementsfrom the list, we will read the element numberby giving the element number here let's saywhatever the if we write L of AI, that meansit means the ayat element of the list.So, first we take a variable, we are assuminghere that the list is supplied to us the totalnumber of elements in the list is suppliedto us. So we first take the minimum value,we, which we really want to compute the minimumvalue we want to compute, but any list canbe supplied in this procedure. So what's theprocedure, the minimum value that we wantto compute, we just consider the very firstvalue of the list in this case, the very firstvalue is 23, we consider that is the minimumvalue. Obviously, that is wrong, this is notminimum value, minimum value may be somewhereelse, or maybe this one may be somewhere else,but we are not sure that the first value inthe list is the minimum value. But let, let'sjust hold on for a moment and move on. Let'ssay the minimum value is this here, this iscalled the assignment assignment. This minvalue 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. Inthis particular case, okay, so min value isthis, which is 23. Now, let's declare, let'sdeclare another variable, which is calledcounter, we may need this counter. And let'sdeclare 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 value23. 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 ofn for this particular example is six, andcounter here is two. So because counter hasvalue two, while two is less than or equalto six, first check whether this conditionis true or false, because if this conditionis true, then you will go to the body of theloop, then this whole box will execute. Ifthis condition becomes false, then you willexit 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 equalto six, that is true. So we will go insideto the box and see what happens. Then whatwe will do, we will pick and pick a valuefrom at the index counter. Right now the counterhas value to L off counter means pick thevalue, because the counter has value to pickthe 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 variablewe maybe needed somewhere okay. Previouslythe min value which is a variable, it wascontaining the very first value which is 23.Now we have picked the second value the countervalue 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 minimumvalue. 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, otherwisewe will go into this block. So right now thecondition is true. So we will go in this blockand minimum value will just be replaced bythe new value. And the new value right nowis 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 whateverthe value is in V and right for this example,the value in V is minus four. Okay? So ifif if you go into the if condition, then you'renot going into the else part, either you'regoing to F part or in the else part one ofthem. Okay, so then we move back Oh, there'sa bug here we need to add the counter. Weneed to increment the counter here after afterthis. Before this. There is another statementincrement the counter. increment counter.That's another statement increment counter.So Now increment the counter after this ifpart increment the counter, and the counterwill become three. Now, we will repeat theprocedure and check three is smaller thansix, yes, we will go inside, and we will picknow the counter value is three, we will goand pick the third entry. And now the thirdentry will be in V, the V will now containzero. Previously it contained minus four nowit will contain zero min value is containingminus four now, so zero is smaller than minusfour, no, if zero is smaller than minus four,then do this. But zero is not smaller thanminus 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 incrementthe counter again. Now, you increment thecounter the counter value will become fourand the value add for is 73. First of allcheck for is smaller equal to six Yes, wewill contain the value at index four whichis 7373 is smaller than minus four no do nothingand given the counter check the if conditioncheck the while condition now counter willbe five five is smaller or equal to six Yes,pick the fifth entry because country's fifththe 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 becauseif has executed else will not execute, youexit the if condition and then you incrementthe counter the counter will become six. Nowsix is smaller equal to six Yes, because sixis equal to six hence the condition is true.Now, you go and pick the sixth entry whichis 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, incrementthe counter, now the counter will become sevenand you go back and check the condition sevenis 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 seethe min value here is containing the actualmin value which is minus 10. So that's howwe search the minimum, this return is alsoa keyword. So which means if we if we justif we just if we just use that function, ifwe if we just use that pseudocode with ifwe just use that pseudocode for this differentkind of lists with with its sizes, whateverthe list, this is this was just one exampleif we chain the list, the procedure will workone one bug in in the code was the incrementcounter statement was not there, it shouldbe there after the end F and before this endwhile here. So this that was the pseudocodeof searching a minimum. In the next videowe are going to use this pseudocode and wewill we will see how to rearrange the valuesof a list or sorting the values of lists suchthat all the values that are smaller theybecome earlier than the bigger values. Andthe problem is called sorting. So in the inthe next video we are going to talk aboutone 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 fairlygood idea how to solve a problem how to writea pseudocode for a problem. And the way weare writing the pseudocode is very close tothe actual Python code which will become soclear to you. So hope to see you in the nextvideo. Okay, in the last video we talked aboutwe talked about this how to find out minimumvalue from a list of values. And we came upwith an algorithm with name search men fromlist. Here we have just made a little modificationthat rather than just returning the minimumvalue, we are also returning the positionof the minimum value in the list. So for example,if the list is 17024, let's say in nine letterthat's our list. There are seven numbers inthe list, the minimum value is zero. so thevalue the minimum value itself is zero, butthat appears in position three. So when whenthis procedure will end, the min value willcontain zero and the ID x which is the positionat which the value the minimum value was achievedthat will contain three So, not only we arenot only we are finding out the minimum value,but also we are finding out the position ofthe minimum value.This procedure, our pseudocode actually describesa very simple, very simple concept, you considerthe very first value as a minimum value andthe very first position as a position of theminimum value, and then traverse the listelement by element and, and see if you findany value that is smaller than the minimumvalue so far, if that is found, then replaceyour minimum value with the new minimum valueand 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 minimumfrom the list. And to traverse the list weuse this loop while loop. So next we solvea problem called sorting problem very, veryfamous problem in computer science. So theproblem really is let's say we have a list,let's say 14035. And seven, let's say andthe sorted order the ascending sorted orderis the order in which the list is presentedso 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 thisproblem, we named this algorithm as sortedlist and sorted list contains this L. In thisparticular case, the L is simply this. Andthis n is the size of the list. In this particularcase, the size of the list is six, so six,and right now l two is empty. So althoughwe have to populate l two, but right now itis empty. And counter again, we initializethe counter with one. And as as long as theConqueror is smaller than six, we keep onwe keep on moving inside this, this block,that's the that's the body of the loop. Sowhat we do is we pass the list and the sizeof the list. And we use the previous algorithmto find out the minimum from the list. Sothe minimum from the list will be found aszero and its position will be found as three.So min value will contain zero, and Id x willcontain three, then what we do, we pick thisminimum value and insert in L two l two wasinitially empty. So we insert in L two, weinsert the minimum value, which is zero sofar. 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 whatwe really do is we delete this value, we deletethis particular value. And the list now becomeswith size 1234 and five, so what we do iswe decrement the size with with one and thenwe move on now the country is one again, theN value rather than six. Now the N value isfive, so one is smaller than five, but thelist has no zero now in it because it wasdeleted, we searched the minimum again, andwe insert the minimum in the list. Now theminimum will be one in the new list. And wedelete that value from the list. And we decrementthe size we keep on moving, eventually thelist l two will be populated like so. Andonce. And once this value of n becomes negative,which is minus one with we will exit the loopand we will return the sorted list. But seehow this sorting procedure actually uses thealgorithm that we that we defined in in RPBprevious video.I'm not talking about that this kind of sortingalgorithm is the most famous sorting algorithm.There are efficient algorithms very greatkind of algorithms for sorting. But the ideahere is not to actually teach sorting theidea here to actually come up with the pseudocodefor this sorting problem. And also to showyou how you can use the pseudocode how youcan use existing pseudo cores as as instructionsin in other pseudo codes. So that's all aboutproblem solving. If you really understandthe selection sort and all that procedurereally well, you're actually very good inproblem solving, at least the problem solvingis that we encounter in the logic that weneed to solve different kinds of problemsin computer science. In the next video, I'mgoing to actually convert these pseudo codesto Python codes. What do you need? Doo doodoo, right this sortlist procedure in actualpython programming language, and how willyou change the search minimum from list inactual python programming language, we willsee the Python details bit by bit in detail,starting from right zero and ending at thevery high details of Python. So, in the nextvideo, I will just be showing you how to convertthis code. But when we will start learningPython, we will start from zero and we willsee 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 becausewe have arrived at a pseudo code. It is very,I'm just want to show you how the pseudo codeswhich 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 thenext 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 aflavor of problem solving by using this selectionsort called the sorting procedure. The ideawas just to use this procedure to solve thiskind of problem. And we saw in detail, notin that detail, we just just brushed up butwe saw how to write a pseudocode for solvinga problem of sorting, which requires actuallya list to be sorting in ascending order. Forexample, 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 inPython 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 defineprocedures, different kinds of procedures,they are called functions in Python. And ratherthan writing this, we have to write a defstatement before it and then whatever namewe want to write out, the rest of the thingstays the same, except at the very end, wehave to write a colon. That's the syntax ofPython. So the changes from here to here isa def statement, which defines that is usedfor defining def for define. And then at theend, 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 messingup 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 Pythonprogramming language, the first index of thelist usually starts from zero. So they arethe minimum value was the first value of thelist here, the first value is actually theindex 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 counterwas one more than whatever the index was.Here, the counter is simply one, we need toright 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 lessor equal to n. Same thing while counter isless or equal to n here. So here we just writethe, the colon at the end, we might have writtenthis equal sign here, this equal sign, wejust missed the equal sign the equal signis there. So now, but see that see the differencehere, the violet goes that way, here we havea colon at the end, rest of the things areexactly the same. Now, v is equal to L counterv is equal to L counter the same thing ifv is less than the minimum value, same thingif v is less than the minimum value in thepseudocode. Python is exactly the same. Justsee the colon at the end, we have colon atthe end of the while statement, we have colonat the end of the definition, we have colonat the end of the if statement. The otherstatement in pseudocode. In Python exactlythe same. Now, in pseudocode, we have l statement.In Python, we have l statement. If we wantto write an else statement, we have writea colon at the end of that. Then in Pythonin 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 describedby the indentation style. So if this indentationgoes on, if we have If you're here, then thisis goes if this if goes out, so we need notwrite ends every day. Similarly, the vilebody has this indentation style, this is allthe while body, whatever that is, that isearlier than this is not in the wild body.So, rather than writing the tokens and whileand if the Python handles everything usingindentation, so no need of end if no needof end while Oh, we haven't, right, we haven'twritten a counter here. So we have to writea counter plus plus here, so counter. So thesame statement, we missed this statement inthe Python code. So the same statement, exactlythe same statement goes here. That's it. Therest of the story is same, we do not needan end search here. The goal here is to showthat the pseudocode is, I mean, the way youwrite the pseudo codes, they are they're highly,they highly resemble with the actual codein 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 codeis much similar to it. So learning the Pythonis very, very simple. The simplicity of Pythonis really a great property of Python. Andthat's one big reason of popularity of, ofPython. Now the return statement is same andeverything is same, then we move toward thesorting. Again, we have sortlist, we haveto write the Define def define, and then wehave this colon out there, we have to writethe colon there, then let's do is definedlike empty, it's empty in Python as well.Counter starts from zero, because they arethe 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 anequal 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, herewith 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 thisis not a this is not a formal introductionto Python. I mean, the the goal here in thisvideo in these kind of session videos is justto introduce you with problem solving. ButI I found this, I mean, I found this beneficialto show you that the pseudocode actually resemblesto the actual Python code a lot, althoughwe will be dealing with variables lists, whileloops, if conditions, all these kind of stuffin them in a in a big and huge detail. Whenwe in the upcoming videos, when we will introducethe Python syntax and variables and all thatkind 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 dadthing is just you write l dot sort and you'redone. I mean, you need not write a lot oflines 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 howit is closer to what you think. But the actualproblem solvingin Python does not require so many lines ofcodes, I mean, there are so many functions,so many powerful procedures. For those youjust write one line and a huge amount of workis done for you. And there are very good oneliners for Python I mean in for for for forprogramming in Python, you did not write alot of lines of code to do some stuff. I meana few lines of code even a single line ofcode does a lot for you. And for that youneed to know the features of Python the featureof the features and the different kinds ofsyntax and features and libraries and thepackages and what what is available with Python.I tell you almost each and everything is availablejust you need to know what is available. Onceyou know the what what what what are the thingsthat are available. You need not to writelengthy codes you need now to build a lotof logic on yourself. Things are prepared,they're waiting for you, you just have tofigure 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 andlengthy 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 lotof 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 lotof features a lot of functionality, a lotof built in stuff ready for you, you wantto do something, it will be probably therein Python, you need to know where it is. Andfor 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 knowinghow to code in Python will save a lot of timefor you. So spending some time on learningPython will be saving a lot of your time.To solve the actual pure problem. Whateverproblems you're doing, you're going to solve.And Python is a real programming languagegranting programming language, knowing thislanguage is almost enough. So hope to seeyou in in the next videos where we will startPython from exactly zero. And we will seeeach and everything of Python in detail. Hopeto see you in the next video. If you're newto data science, you may stuck in choosingthe best language for data science. And inthis video, I'm going to I'm going to talkabout Python, which is the greatest languageso far for data science. To explain the featuresof Python, let me first go back to a littlebit history of Python from where it started.It basically starts in 1980s. It was introducedfirst in 1980s. But with constant improvementsand a lot of bug fixes. It was officiallylaunched in 1989. Nine years later. It wascreated by Guido van Rossum and it is opensource which means it is accessible to everyone.Even though it's open source. It can be usedfor 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 itis dynamically typed. So the variables thatyou are defined that you are defining thatthey are defined automatically, you need notto set the type whatever the contents in bringin, the type will be defined automatically.It is more readable and uses lesser code toperform 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 otherthird party software easy. Python programmingis easy to use, and has a simple and fastlearning curve. new data scientist can easilyunderstand Python, but it's easy to use syntaxand better readability. So so that's whatthis point is basically it's it's really abeginner friendly if you if you're new toprogramming. Well, Python offers you a veryeasy environment to go on. It also providesplenty of data processing tools that helpin better handling the data. Python is importantfor data scientists, because it provides avast variety of applications used in datascience, it also provides more flexibilityin 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 deeplearning algorithms very, very quickly. Sobasically, the sport, the sport of machinelearning and deep learning is huge in Python.That's huge. As, as is the case with manyother programming languages? It's availablelibraries that lead to Python success aroundaround 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 andconsequently, any Can anyone can write a librarypackage to extend its functionality. DataScience has become an early beneficiary ofthese particularly ponders The Big Daddy ofall of them. The other great thing about Pythonis there are millions of users who are happyto offer advice or suggestions. When you getstuck in something, chances are someone elsehas been stuck there first. So a lot of communityis there, a lot of packages are there, it'sopen source it it's easy to use, it's easyto learn. It's simple, it's readable, moreclose to human language, it's high level language,you code less you do more, I mean, you writea very few lines of codes, and you achievea lot of work. So, I mean, I've spoken a lotof verbs here, too, too. I mean, explain thatPython really is best suited language fordata science. But let me let me introduceyou some statistics about Python, the popularityof Python with respect to big with respectto its use, and with respect to the job opportunitiesthat are there in Python. So for example,if you see this chart, in the ranking of top10, languages, Python stays at the top. Sothat's the latest statistic, collected in2019, 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 peopleare more interested in Python, I mean, thetrend of using Python is getting larger andlarger, as compared to several other languageslike Java, JavaScript, C, sharp, bhB, C, ourobjective c, swift and MATLAB. I mean, manyof them are used for data science, but Pythonstays 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 from2014 onwards, that the job opportunities andjob postings are in different languages areat what amount, and you can see the graphof Python, although starting a bit low, butthen stays up and stays up, which means the80 if you see the numbers 85% of the totaljobs, 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 usedto perform any kind of task for embedded programmingfor, uh, for for posting, I mean, codes orembedding code on Raspberry Pi for web developmentand whatnot. You can you can, you can do thedesktop development on it, you can use theweb developer knowledge you can use the datascience, I mean, I mean, this is general purposeprogramming language. In other disciplinesdo it is performing very well. But data sciencefor data science, it is almost the defaultlanguage today.So, I mean, if you're going to learn datascience, 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 introducePython 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, includingthe 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, weare really going to teach you Python, andwe are not assuming you have any programmingexperience 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'renot assuming that you have any programmingbackground, you have any data science backgroundnothing. So we will start from the zero andAnd we will gradually move to 200. So, andincluding 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'regoing to introduce you Python from the verybeginning to the very professional. So hopeto see you in this course. Okay, before actuallydiscussing the best ID for Python, and particularlyfor 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 writethe code and then open a terminal window toexecute your code. When there is an errordetected in your code, you switch back tothe text editor, correct your errors, typosand 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 inall scenarios, which means you also need atesting module. Many times you have multiplecoding and testing files, and switching betweeneditor and terminal often becomes both confusingand efficient. So, an environment is needed,where you can write you can run and play withyour code all at one place. So the one thatprovides you with the capability of not justcoding, not just writing the code, but butalso testing your code, running your codehighlighting your syntax, bracket matching,auto completion, debugging your code, codesuggestions, and and many more features. Thatis called an ID II or integrated developmentenvironment. Now, there are several ID isfor different languages for for Python, thereare several ideas for example, Jupyter Notebookis an ID IE by charm is an ID IE spider isan IP ID and thought cannot be whim atom andthere are a lot more there are several ofthem. Now the question is for data science,in particular, what Id E is is the best orare what people suggest to be the best. Sobefore actually showing you the statisticsthat which one is the best before actuallyshowing you the actual numbers, the statisticalnumbers that shows which one is better, whatare the other let me just go through a fewof them few of it ease and their featuresand stuff. And then we will move to move tostatistics and some numbers that will showthat which one is better over the other. Solet me start with with this Jupyter Notebook.For the past couple of years Jupyter Notebookhas been gaining a lot of popularity in termsof coding and debugging. notebooks have beenredefining the concepts of an ID E and areadding more and more features on to it. Jupiterwas introduced in 2014 after its predecessoripython and from that date, it is really consideredto be a bless in the coding community.Jupiter stands for I'm in some people sayJupiter stand for Giulia Python r but thatI come in that acronym does not mean justthis. I mean Jupyter Notebook today is supportingmore than Giulia, Python and R and by theway, this Giulia Python, R and R all theseare open source languages for and they arebest suited for data science. This JupyterNotebook, it has markdown editor. It allowsyou to write HTML code, it allows you to writelatex in it. I'm in a lot more. Further thisJupyter Notebook. It's a web application basedserver client structure, which is easy touse and allows you to create, analyze, andmanipulate documents. And all these documentsare in the form of notebooks. Since it's aweb web interface, it can integrate with manyof the existing web libraries. For example,for data visualization. Jupiter has so manyfunctionalities 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 forpresentation and even for writing blogs. Youcan export your notebook from iPython Notebookformats to PDF or to HTML or even to.py, whichis the Python file. The user interface ofJupiter makes it a favorite tool, especiallyamongst the data science community. And oneplus of this Jupiter is, it's it's very quickto start, I mean, very easy and very quickto start, I mean, not much rocket scienceto write your first goal, you want to writeyour 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 usedjapin JetBrains other IDs like Java ID, thenrunning your first code successfully can eatup a little bit of your time, actually, alarge amount of your time maybe such as Imean, setting an interpreter by charm. Bycharm, however, is, is much better for, forworking with multiple scripts, handling multiplefiles and linking them together and huge largescale 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. Andthose packages in including NumPy, Sai, pimatplotlib, and so on. Just like other IDEease 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 andwhatnot. Additionally, Python lets you addplugins for non pythonic files. And theseplugins take care of indentation highlightingthe errors and keywords just on the fly. SoPython is also providing I mean, a huge supportfor coding Python. But, I mean, the one badthing 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 gettingstarted with PI charm is not that quick. Imean, it takes a lot of time to just go withthat. Spider however, is a lightweight, opensource ID Oh by the way, this by but thisby charm is is is not I mean it has ProfessionalEdition and and Community Edition and it doesnot open source completely. Spider however,is a lightweight open source, ie that comespre installed with Anaconda. And it was builtmainly for data science practitioners andengineers. 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 feelthe same cannot be by the way the unthoughtcannot be also has roughly the same look andfeel as MATLABSo, but spider was built for data sciencecommunity, it is integrated with essentialdata centric libraries like NumPy, Sai, pi,matplotlib, pandas, ipython, and whatnot.The built in capabilities can be extendedfurther by plugins and API's Spyder containsfeatures like text editor with syntax highlightingcode completion, static code analysis, debuggingvariable exploring, it also has profiler thatrecursively determines the runtime and numberof calls for every function and methods callin a file. And I mean, there's no thoughtcannot be there is a vendor's atom there area whole lot of it is just for Python language.But But the question really is being a datascientist, which one is which one should youchoose being a beginner? which one shouldyou choose? Even even for professionals, ifyou want to stay in data science, which IDhe will you prefer over the other? I mean,there are so many of them. I have just describedthree or four of them. So let's see some statsbased on popularity of different IDs for datascience, and then decide which one is betterover the other. So for example, this datathis this analysis, that the chart I'm showinghere, this analysis by was was done by Katienuggets and The link for that and it showsthat the most popular Python editors tillDecember 2018 and you can see that the Jupiteris at the top, the second is pi charm, thenspider then Visual Studio code and sublimetags, then add on atom women there are somany others, but Jupiter is at the top andthis is for I mean, these all are listed withrespect to the data science community. Soin the data science community which PythonID he is best over the other and, and JupiterJupiter is at the top I mean it is it is wayout. And one reason to this is its simplicity.It's it's supporting to so many differentformats. 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 canrun it on a local system you can run it anonline survey system and whatnot I mean ithas so much flexibility and very quick startand easy to use. If you for example see thepopularity of Python IDs with respect to theemployment then then you can see overall thethe Jupiter has been a winner as comparedto pi charm spider also your code and sublimeif you see company or self employed stillthe Jupiter is V out it has been if you seefor 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 choiceI'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 forexample, again, overall, Jupiter is a winner.If you see US or Canada Jupiter's most popularmostly used Europe, Jupiter is the winnerAsia, Jupiter is the winner, America use Jupitersevinor effect Africa and Middle East Jupiter,Australia, New Zealand Jupiter. I mean, thesenumbers 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. Sothese 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 Jupiterfor all kinds of coding. And in the in thenext video, I will be just showing you howto installJupiter environment how to install basicallyPython and how to run Jupiter for the firsttime from it. So I hope to see you in thenext video. Okay, in this video, I will showyou how to install Python. There are multipleways of installing Python you can go to python.organd install Python from there I would recommendto use Anaconda distribution it has Pythonit has a lot of packages pre installed ithas Jupyter Notebook as well. So installingthrough Anaconda is easier as well. So iffor example if you are working on a Windowssystem you should download the executablefor Windows we will be working with Pythonthree rather than Python two. So you shouldbe 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 youwill be installing 32 bit version. So let'ssay you have downloaded the executable filefor Windows then after the download you justfrom that xe file and follow the steps andyou'll be able to install Anaconda once theAnaconda is installed then in the search baryou just type Anaconda prompt and the Anacondaprompt kind of symbol that my mouse is pointingat this will appear in front of you, you justrun it you will see a command prompt likeso. Then in that just type Jupyter Notebookand press enter and you will be having Jupiterrunning 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 thisis the Anaconda prompt. So if I click it,it runs then I just typed for example, Jupiternote 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 frontof you. And that's what the Jupiter into interfaceis. We will see then how from this Jupiterhow to write the code how to make the codefiles and stuff but that's how from Anacondainstalling after installing Anaconda that'show you will launch the Jupiter. So this isthat easy, no problem. Then, for example,you can install you can install Python ifyou're working on Linux and just downloadthe version for Linux. And then rather thanFor example, let's say your your your fileis downloaded in the Downloads folder thenrun this command bash and this.sh that's thefile name. The installer prompts in orderto continue installation process this I'min these kinds of commands will will appearPress Enter to Continue then press Yes, andthe installer will finish with the thanksmessage. After that, you just go to downloadsfolder and type Jupyter Notebook and the JupyterNotebook. interface the browser based interfacewill appear in front of you. You can haveif you're if you're working on Mac, you canyou can in you can download the Anaconda distributionfor Mac, then you'll find an anaconda Anacondanavigator, the launchpad you can launch thatand then just click there's a Jupiter iconin front of you just press the Launch buttonand you'll be having your Jupiter runningin front of you. So in this video, we justtalked about how to install Python. If youinstall Python using Anaconda you will behaving Jupyter Notebook as well. In the nextvideo, we will see how to actually use thatJupyter Notebook interface for example, Iwork on Windows, so I'll be having this kindof interface although the interface lookslike same because it's a browser based webbased interface. In the next video, I willshow you how to get comfortable with Jupiterand we will be also writing our first HelloWorldprogram in Python. So hope to see you in thenext video. Okay, so in this video, I willshow youhow to write the first program in Python basicallythe HelloWorld program. Before that, in theprevious video, I show you I showed you howto launch Jupyter Notebook. So once you launchJupyter Notebook, whether you are workingon Windows, whether you're working on Linuxor Mac, whatever, when you will launch theJupyter Notebook, you will see this web basedinterface. And here you are in the right corneryou can see the button new, you just clickit, you will select Python three, and youwill see a beautiful interface in front ofyou that will allow you to go here, thereare a lot of file edit view there are a lotof parents kernel and a lot of controls herewe will see them as we move on. But this ishow you this is this is what the coding environmentis this is kind of editor as well as I meanthis is complete, ie interface in front ofyou. So let's see this interface a littlebit. Step by step at least the controls thatthat we need. First of all, you are seeingwhere my cursor is moving. That's the filename or the notebook name. You can changethe notebook name or you can just write forexample. Whatever the name of the notebookyou want, for example, mastering by Thorneforbeginners. Okay, so let's say that you'remastering Python, let's say let's say zeroto hero, maybe. So let's say this is yourfiling, you just create that file and you'llsee this mastering Python zero to hero thatfile is created with this file is renamed.Second. This is a cell in which you are goingto type your code. The code, I mean, the twomodes of writing is one is you can write thePython code. Another way is you can writethe markdown. The markdown is important inin a way that if you want to describe yourcode, if you want to write other stuff otherthan Python code, you can use these markdowncells and they We will be helping you. Forexample, if I select this markdown, and Ijust select this markdown, and I type here,for example,this is by THON directorial. And then I pressShift Enter, it will appear as a heading.And a new cell will be graded down. This isalso a cell. But this is a markdown cell.As you can see, now in this cell, that's acode 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 pressEscape key, then if you press M, it will changeto markdown. And if you press Y, it will changeto a code cell. There are several I mean shortcutsthat are available keyboard shortcuts, ifyou if you just see, if you go to help andsee this keyboard shortcuts, there are severalshortcuts that will be available in frontof us. For example, if you press escape, andthen press F, you can do the Find and Replaceoperation. And if you press enter, then thatwill go into Edit Edit Mode, if that's important,if you press Shift, enter, the cell will runand the new the cursor will go into the newcell. And there are a lot of controls youshould be seeing most of them, I mean, gettinga good grip on these controls will help youmoving in this Jupyter Notebook very quickly.So for example, this is a Python tutorialthat's a markdown cell, you can also createthis, this cell also as a markdown cell. Andthen you can type here for example. This isour first program in Python. It there it isjust 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 firstPython code HelloWorld. So first of all, youwill write Brent Brent command will allowyou to print anything on the screen. brantassays double codes, starts ends. And in thedouble code, you write whatever you want tobe printed on the screen, for example. Hello,world.And once you have written that code, justpress Shift and enter, and this code willexecute in front of you. So that's HelloWorldprinted in front of you. And that's our firstprogram, I mean, writing the very first programin 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 writeHTML 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 somemathematics in it. And it allows you to writemathematics as well. For example, A equalsB plus C, Shift Enter, and that appears likea mathematical equation, not just this, youcan write very complicated equations. I mean,and and, and this whole notebook will containyour descriptions in terms of HTML or latech,or descriptions, and code and all that mixedup, whatever. And at the end, you will, youcan, you can just download this. You can justdownload this, this notebook, as if you wanta PDF file PDF file. If you want a notebookfile, it's an output file if you want to latechif you want just a Python file if you wantslides, for example. I mean, you can downloadthe same thing as slides. It will make slidesfor 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, reallypowerful Jupyter Notebook and coding in itis not just the coding. I mean, it is Preparinga document. If you want to prepare a document,you want to describe anything you want toadd images, and at the end of the day, itwill be an HTML document for you. It can beshared on web. I mean, it's ready. Nothingwe we want to further finish it. So that wasour HelloWorld program in Python. We willcontinue to build this byte mastering Pythonzero to hero notebook, we will continue codingin that we will describe the headings we willwrite the markdown cells and all that stuff.And we will at the end of this course, youwill be having one notebook with all kindsof descriptions and code in it. You can usethat notebook afterwards, we will be buildingwell one notebook, one complete notebook forPython. So that's about it. That's the helloworld. In the next video, we will see howto 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 theupgraded version of ipython shell. And I alsowant to show you ipython shell as well. Soin the next video, we will just see the ipythonshell and we will see how can we how can weview Python as just as a calculator by usingipython shell. So hope to see you in the nextvideo. Okay, so in this particular video,I'm going to show you the ipython shell justopen 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 thenotebook 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 anykind of Python code in here. Actually, theJupyter Notebook is more enhanced and morefeatured the use of ipython. Basically everythingthat I bought, that is there in ipython isthere 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 ipythonshell as well. But remember, previously inin Jupyter Notebook, we type Shift Enter torun a particular command here, we just pressenter and everything will work. If you wantto 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 justlike, 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 eightis static, or multiplication, static is achievedby multiplication is achieved by a staticsymbol 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 arrowkey and last command just appears. I havepressed up arrow key again. And the secondlast command appears. I press the up arrowkey again and the third last command appearsand now I'm pressing the down arrow keys.So for example this and you may have whateverthe 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 verycomplicated 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 computethis result, let's say 45 minus 45 minus nineand let's say you compute this result, whateverthe 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 resultis in a, and then you have this particularresult that is in B. And now, you just wantto add the two results together, and you wantto print thewhat what normal calculators does not havethe support of saving the results and reusingthem. But here in Python, even if you justwant to use the Python, just as a calculator,you can declare as many variables as you canand you can save the previous results, youcan retrieve the previous results. And youcan use the previous results, save new resultsand so on. These kind of symbols that areused to save the results, and then they canbe just used afterwards, these are calledvariables. 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 beyondcalculators, you need certain results to besaved and retrieved retrieved afterwards.And the variables are are the constructs thevariables are the features that actually dothat. So the calculator is fine, you can usethis ipython shell just as a calculator. Butif you want to do interesting programming,complicated programs, I mean, you want toachieve a task that involves much more calculationsone way or the other, you have to save certainresults in somewhere. And then you have tocombine the results together because the longerproblems in normally are broken up into smallerpiece of problems. And each smaller problemhas a result that should be saved somewhereand afterwards the several results they shouldbe combined to achieve the result that weare after. So these variables are requiredif 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 enhancedversion of this ipython shell, the iPod ipythonshell just people used to write a lot of Pythonprogramming just in ipython shell. And eveneven today is several people are writing theircode complete code in ipython shell. But thethe Jupyter Notebook is more enhanced forthe enmore documented more, I mean, it hasbetter interfaces and several features thatare better than just using ipython shell.So you have seen this ipython shell, it'svery 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 purposeof this video was just to was just to introduceyou with ipython shell and just to tell youthat 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 Pythonis really really much more powerful than justa calculator. So hope to see you in the nextvideo. Okay, in this video, we will talk aboutvariables and operators the operations thatyou can perform on on variables. A variablein a very layman term is basically a symbolthat stores some data that can be used lateron. So for example, this x is a symbol correctoror a symbol y is a symbol x y is a symbolnormally, and these are called names of thevariables. For example, this is a variablename x, y is a variable name y, x y is a variablename itself. Now, these variables, they canstore different kinds of data, I mean, wheneveryou want a particular data to be used againand again, it is better to save that dataor label that data by a symbol by a descriptivename so that you can retrieve that team retrievethat data by using that label or symbol. Soone way or the other. This this variable actuallyis a description of the data that you wantto use our store and you want to use lateron in your program. Different types of dataare there, for example, the integer type data.For example, if the data you want to storeis integer type, it's a number And the numberis just the integer number it does not havea decimal point expansion that is a type ofdata and that can be stored in a variablein that in that case, the variable type itselfwill be integer, you need not to specify thetype of variable when you are storing thedata to it the storing data to a variableis sometimes called assigning data to a variableor assignment. For example, if your variableis x, and you are assigning a value let'ssay two, then two is integer value its integerit does not have a decimal expansion and whento is assigned to x, based on the contentto that to basically is an integer type value,automatically this the type of x is set tobe integer. And that is sometimes called thedynamically typed Python is dynamically typedlanguage or dynamic typing, you need not tospecify the type of the variable the contentsthat you are assigning to a variable, theywill define the type of the variable on thefly. And the assignment for example, in hereI'm storing two insight x and next time ifI 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, sorather than writing this symbol for assignment,normally an equal sign symbol is used forassignment for example, x is equal to twothat means two is assigned in x five is equalfive is equal to five means five is assignedin y 7.2 equal x y equals 7.2x y is completelya new variable, it has nothing to do withx or y. And it is handy sometimes to to tosuggest the name of the variables that aretoo descriptive that are very, very descriptiveto increase the readability and managementof the code, because later on you will youwill be seeing when you will be working indata science and other stuff. The programsthat 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 youif you do not assign the names of the variablescarefully. However, if you write the namesvery in a very descriptive way, by just writingthe name of the variable by just creatingthe variable symbol or or or the name, ittells a better look and feel of what kindof data inside and what should I do with that.So, I was talking about this equal sign thisequal sign is used for assignment. Here forexamples when 7.2 is assigned to a variablex y, automatically the type of x y variableis set to be a floating point integer floatingpoint number a float is a data type in inPython that describes that the particulardata is a real valued it may have a decimalexpansion as well not just integer and floatsare the only data types in Python, there areseveral others for example, you can definecomplex numbers if you if you want to youcan for example, defining a complex numbermight be for example, you write the name ofC and you write two plus four j if you writethe symbol j here, it automatically becomescomplex. And now you can you can use thissee the way the complex numbers should becreated. Similarly, there are other data typeslike 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 typeof this variable a string string is just asequence of a lot of collectors, where heis a collector is a collector L is a collectorL is a collector always a collector W is avector. And when we will define anything,any sequence of characters inside the doublequotes and then ended the double quotes here,or the single quotes, single quotes and doublecourse either way, then the type of this isbecome strings. And these characters shouldbe created as it is. Like for example, ifwe have another variable s two and we justsay one, two, in double quotes. Now this stwo is no longer 12 as an integer. It is asequence of characters where first characteris one and other graduates two, we will talkabout strings in detail in the upcoming videosbut just to give you a look and feel thatPython actually supports a lot of data types,a lot of interesting data types includingthe 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 variablesin in a single line there is sometimes calledmultiple assignment. For example, if you writea comma b equals four comma 5.00, then fourwill be assigned to a and 5.0 will be assignedto B. notice one thing although 5.0 lookslike an integer, but when you when you writea decimal expansion, it automatically becomesfloat. So, if you Now type the type, if younow check the type of a it will be integerand if you check the type of B it will befloat. Once you have declared a lot of variables,they stay in the memory they occupy a particularspace inside the memory. For example, x isjust a label to a memory inside the memorythat is to located somewhere. Similarly, yis also located somewhere in memory. And similarlyx y is also located somewhere in memory. Andthis is the data inside that memory. Thesewill stay in the memory and the occupy thememory. If you if you decide to no longeruse a particular variable and future in thein the program, then you can call this functiond l space, whatever the variable name, andit will delete the it will delete the variablefrom 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 Notebookand let's let's actually, let's let's actuallydefine certain variables, use them, printthem, do some multiple assignment and seea lot of stuff in in Jupyter Notebook. Solet's go to Jupyter Notebook. So that wasour notebook that we were doing, that we wereactually working on the last time. So let'ssay I define a variable X, let's say x istwo. 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 nowI'm in a code cell. Previously I was in amarkdown cell, notice this change in thisparticular cell, this is markdown in thisparticular cell, this is code cell, C thatgoes, Okay, x is equal to let's say, three,let's into this. Now x is assigned a valuethree. If you want to know how many variablesright now are there in the memory, we canwrite this command whose This is a percentagesymbol, if you write percent a symbol andthen just type a command, w h o s, it willtell you all the variables that are on rightnow 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 viewthat you're now seeing. Okay, if you wantto explicitly check the type of x, you canprint type x. So for example, this functiontype will will actually find out the typeof whatever variable you give inside and thenthis print function will help you printingthat on on the notebook. So if you see thetype of x, the type is basically its integertype. Now,if you for example, change the value of xas three to let's say, 5.7. So you have samevariable, but you just change the value fromthree to 5.7. So let's see what happens now.So if we call us again, we have now the variablename is still x, but its type automaticallyit's type automatically change to floatingpoint number, because of because we assigna floating point number to it. And this isthe data if we want to explicitly check thetype of this x, that would be class floatnow, further. Let's say we have another variableABCD. That's a variable name, let's say andwe assign a value 55 six Point, three, two,that's that's the value. If we now calledwhose 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, firstvariable 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, point07, point two, and let's say minus three.So if you enter that, and you now check thestatus 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 hasvalue five sees float, sees float all those6.0 looks looks much like integer. But whenyou 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 variablethat 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 wantto use in future. And now if we see again,the view of the memory, we don't have thisand if we now want to access this, for example,if we want to print this ABCD, we will getan error, we will get an error and we shouldwe should get an error because this particularvariable does not exist in the memory, itpoints to no data, it has gone, it has gonelike it was never, it was never there. Sothat's about the variables. We just talkedabout 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 interestedin 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 videosjust on string data type, because this isvery important data type we will we will seethat in detail. But the purpose here is justto tell you that there are a lot of data typesthat Python supports and Python is dynamicallytyped whatever content you are assigning toa 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 oncewe 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 canwe multiply two variables together, can wehave an operation like addition or mixed typesfor example, one variable is a floating bynumber and other variable is integer numberinteger type, can we mix up those can we addtwo different types of variables togetherand get a result then what will be the typeof the result and so on. So a lot of thesediscussions on operators the very basic arithmeticoperators on these variables, particularlythe integer and float variables, we will seethat in the next video, so hope to see youin the next video. So in the last video, wesaw variables and we particularly saw integertype variable and floating point, variabletype. We also saw very briefly on Jupyternotebooks are complex, and string as well.So in this video, we are going to talk aboutoperators, 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 probablyyou will be storing data to the variablesand then you are you're applying some computationon 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 arithmeticoperators, let me let me just this this plussymbol is used to add to variables. This minussymbol 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 thename suggests, it's if you want to dividethis this person to a symbol when it is appliedto two different variables, if x is on leftand y is on right, what it does it, it actuallydivides 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 remainderthe 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, wenormally 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, butit 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 pointnumber, 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 writethe double slash three, and it will returnjust the value that is that is there beforethe decimal expansion. So this value willbe returned. So this is kind of the integerdivision 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 fourin mathematics, we write this as following.And the result will be 16, you can save thatresult in another variable, or you can justprint it or you can write that in a file ofwhatever. So these are most important. operators.One thing that I want to tell you that theseoperator are not just for integers and floatingpoint numbers, the applications of these operatorsis much broader than these later, we willsee the objects or the data types that arecollections. 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, theyhave their meanings there. Even even eventhis plus is used for strengths. Now thinkfor 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 iswhy then Python allows you even to add thesekind of data types, although some doesn'tmake any sense with these kinds of stringvariables, but we will see four differentkinds of data types. The the definition ofthese operators, they actually changed oradapted accordingly. For example, in mathematics,we are much more fluent a four with plus withDebian with subtraction, and it makes senseto add two integers to subtract a floatingpoint number from another floating point numberand stuff, but with data type that is unfamiliarto you right now, these operators may notmake that sense to you. But there are definitionsthere, there are ways to use these variables.For the data types that are even there oreven beyond an integer and floating pointnumbers, we will see all these details aswe 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 arenot just limited to integers and floatingpoint numbers or complex numbers, they canbe 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 dealingwith. So yeah, here. So let's first pressescape, then m just to change it to markdownand then good scape one for heading begetting.And here I write, let's say operators, andshift 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 newvariable, let's say sum of sum of A, B, that'sa new variable sum underscore AB, that's avariable name, you can have a better way youwill name maybe some of A and B, that mightbe a variable name. It is good to have thevariable names that are descriptive that describewhat 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 sothat 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 neednot write everything, just press tab, andit will automatically complete the remainingpart of the variable and press Shift Enterand you have eight. If you check the typeof this variable, some of tab automaticallycompletes tab complete that is called tabcompletion, while it's integer, the type ofthis particular variable is integer, that'sa new variable and why and the type is integerbecause a was integer, B was integer. Andinteger plus an integer is an integer. Whatif we add an integer with a floating pointnumber? What do you think? What should bethe result? If I just type type? A, that'san 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? Letme 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 thetype of an integer and a float combined?Well, the types are up costed, which meansthe floating point number, the result willbe a floating point number. And the reasonis, every integer by default is a floatingpoint number, a floating point number is ais an upper class, or you can say a superset.So in Python, in Python, by default, the typesare up costed to super super sets. So hereinteger plus a float, the result will be afloating point number. And that's a result,you might be thinking why we have why we haven'tstored the result in another variable. Well,if we want to store the result in anothervariable, we can, or if we just compute theresult and apply some operation on that, wecan do that. For example. We could do thefollowing, for example, a plus d. That's whateverthe result is raised to the power three, whateverthe result is, whatever the result is, dividedby maybe four. And we just save that in anew variable. Let's say. Let's say the newvariable is V. Let's say we save that value,and V. And now we print we, and we have theresult for me. Wow. So we can do a lot ofstuff with these kinds of variables. Let meshow you a fancy stuff that we will see lateron. Don't worry if you don't get it just asone, for example, as one is Hello. Hello,and let's say s two is world. And we haveanother variable, let's say s, which is sone plus s two. What it will do is it willjust concatenate them together. We will seestrings a lot later on. But just to tell youthis plus is not just for not just for numbers,it is for other data types, very fancy datatypes 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, ShiftEnter, the result actually is 3.33, and soon, you might be wondering we have not savedthat 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 notstore the result in a particular variableexplicitly, by default, there is a variablein Python, which is underscore underscorecontains the last result that you did notstore in a particular variable explicitly.So, that underscore is basically one defaultvariable for for the result, if you want,don't try to update this underscore, justjust read it Do not assign anything to underscore.For example, if you assign something to underscoreassignment will be done, but then the propertiesof underscore will no longer be there as theyare in in Python built in properties. Okay,so, that's about it, I guess. So that wasthe operators, we will see the operators moreand more later on. But before ending thisvideo, 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 shortanyways. 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 startsfrom for example, a digit? is a 3x? validvariable name? Or, for example, at the rateof at the rate of Why is that a variable name?Or, for example, this symbol times two timesx, is that a variable name? What are the conventionsto for variable names? can we can we writeanything? In the left hand side? The rightlet's say 3x? Is equal to four? That means3x is now a variable name. Is that true inPython? Or are there conventions to definethe variable names? So?Yeah, think about it. See you in the nextvideo 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 questionabout the naming convention of the odd variablenames. In particular, I asked you whether3x 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, youmight have tried that, declaring that variablename and Jupyter Notebook, and then you mighthave got this answer one of these? Well,let me tell you, the answer is no. A variablecannot start with a digit. Not with, not with,at the rate of not with hash symbol, not withI mean, there are severalother special characters are not there excepta few factors. One of those is underscore.Let's go to let's go to Jupyter Notebook andand check this. So, for example, 3x equalsfive error, invalid syntax, let's say activateof y equals four. Invalid star d equals fourerror. Well, an exception is underscore underscoreE equals six, that's allowed. Starting a variablename with underscore is allowed, it is differentthan the underscore that is built in underscorethis underscore E is different than simplyunderscore. So it is good to not declare thevariable names that start from these becauseyou will be getting errors further. variablenames should be descriptive. They should giveyou a look and feel of the data what theyare containing and you're free to define variablenames, as as descriptive as you want. So itis a good practice to, to start writing thevariable names in a better way. One, one betternotation, one better notation of definingthese variable names, even the function names,we will see the functions later on. One wayto defining those is to use camel notation.camel notation camel notation is you startwith the variable name with for example, lowercaseletters, let's say your variable is startingtime of the course. Let's say that's yourvariable name. So you write starting, that'sone word finishes, then the next word shouldstart from capital T, starting time of thecourse, 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 keepingconsistently keeping the consistent strategyof defining variables. There are several otherways this is one way. So starting time ofthe course is let's say 2.0. That's it. Sothat's a variable name, if you if you nowcheck, that's a variable name. But now, ifyou see this variable, just just the namesuggests the data inside is doing what? Sothe names should be descriptive, I mean, andmake that as a habit. So, yeah, I guess wehave now answered our question very concretely,that variable name cannot start with a digitnot with any special character other thanunderscore, okay. In the next video, I willbe introducing comparisons with with variables.For example, what if you want to compare whetherone variable is smaller than the other ornot? What if you want to compare whether thetwo variables they are containing values theyare same or not? What if you want to do comparisonsof the of the data that is stored inside thevariables, and based on the result of thecomparison, you want to do something else.So in the next video, we will see a bool datatype that is very, very famous, and it isused in a lot in decision making. And we willsee 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 abouta data type which is called bool. That's very,very famous data type. Actually, it's themost famous data type because it is used indecision making all the control flow mostof the controls, so depends on this data type.Although it is very, very famous, very muchapplicable data type, it is very simple. Itis a data type with just two states with justtwo values. By the way, there are capacitiesof different data types. For example, in Tinteger, thedifferent kinds of values that you can storeare huge, you can store any negative numberin it, you can store zero, you can store anypositive number, the capacity of floatingpoint number or the number of values thatit can save is is even higher than even higherthan integer and the complex number is evenhigher than that and so on. But the bool datatype, it has just two states one state istrue. It has just two values. True is a value.And false is a value just these two straightstrue or false. In some programming languages,the true is denoted by one, and the falseis denoted by zero. But in Python, the trueis just t ru e true that thing and false isfalse. That's it. If you For example, definea variable let's say any variable name, whateverthe name is, let's say B and you assign truethen it's its default data type will becomebool. And if you have another variable, let'ssee which is false. Then C is also bool. Onething 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 booldatatype. For example, a true and and is akeyword combining true and true. If if thereis a variable, let's say a with a There isa boolean variable a with data true. If thereis a boolean variable b with data true, thena and b is also true. So let's say I've usedthis variable D, in storing this A and B,the D will also be true. So true and trueis always true. Further true and false, thisis always false. And this is committed iffor example, true and true is true, true andfalse is false, false and true is false, falseand false is false. So, if you apply an operatorand keyword to combine the two Boolean variablestogether, if both are true, then and willresult a true otherwise and will result offalse 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 isfalse. If any one of these is true, then theresult is true. Remember the difference betweenn and R and will result false if any one ofthe two operands at least one of the two operandsis false,then the result is false. If both are or areanvisa true, if both of the operands are true,otherwise it is falseor will result false if both of the optionsis false or false. Otherwise it is true. So,you now know and you now know are there isanother operator called not. This is not sonot for example, returns not true. Resultsfalse and not false. returns true. Great.So knot is a unary operator. unary means itjust takes it just takes one variable andoperate on that, and is a binary operatorlike plus is a binary operator. It takes twovariables to operate on, or is a binary operatorit operate, it takes two operators, it takestwo variables to operate on and so on. Soremember, remember these things, one, andwe'll return true if both of the variablesare 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, notfalse means true. So these are basic, that'show you can combine the Boolean variablestogether. In the next video, we will be seeinghow to apply these comparison operators andthe result will be Boolean types. And howcan we combine the Boolean types togetherto to build a better decision making. So inthis particular video, I just, I just introducedthe boolean data type for you with you. Inthe next video, we will see where the booleandata type actually appears, and how it impactsour, our our programming style or thinkingstyle or coding style. So hope to see youin the next video with comparison operatorsthat actually produces the Boolean variables.Hope to see you in the next video. Okay, inthe last video, I discussed boolean data typeand I discussed that a boolean variable takeseither a true or a false and we can combinethese Boolean variables together with andour operators. And then we can apply a knotoperator on a particular variable. And wewe saw that a true and true returns true andand otherwise it also returns false. Similarlyfalse or false is false. Otherwise, or alwaysreturns of a true before before actually discussingthese comparison operators. Let's do let'sjust go to Jupiter and just just play witha boolean data type. Just Just for just fora moment. Let us just convert this to markdowncell and just cried. Both that's a word Booleanvariable. So let's say A is true and B istrue and C is false. False. And okay, so theseare variables. Let's press those to see whatare the states of. So, a is a boolean variablewith value true B is a boolean variable withvalue true C is a boolean variable with valuefalse. So, now it is true B is true, C isfalse. So that means, let me print print aand b, what do you think? What is what willbe the result? Let me print a and see whatwill be the result. And let me Brent? C andA. 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 willbe true, then false false. So yes, true, falsefalse. Let's, let's check the or print. Andby 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 arefalse, here is true. So the value of d willbe truefor the not a, because A is true, not a willbe false. Similarly, not B, B is true. Sonot B will be false. Not C, C is true, C isfalse, 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 canalso check the value inside D and that isfalse. So, yes, not only that, I mean, wecan we can we can we can combine at a higherlevel for example, A and A and B, whateverthe 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 resultwill be some Boolean, that Boolean and thatBoolean thereare theresult eventually will be a Boolean, and thennot have that. So let's check what if thatis the result is false, well, why the resultis false. figured out why the result is false,let me go to comparison operators. So, thecomparison operators, let me just go throughcomparison operators. This equal equal toit compares whether two variables whetherwhatever the variables are whether they areinteger floating point, whatever, whethertwo variables are are, they have same dataor not, for example, x equals equals two y.That will be true if x and y, they both havesame data. So for example, if X has valuefour, and y has value four, then we are justchecking x equals equal to buy or not, theresult will be Boolean. Because an X may notbe a boolean variable y may not be a booleanvariable. If we want to compare the valuesof x and y, then we write w equal withouta space inside. Remember, if we write singleequal that will be an assignment operator.If we write w equal that means we are checkingwhether the two values are same or not. Similarly,if we write this particular symbol that checkswhether two values are not equal or not, forexample, x is not equal to y, the result willbe 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 thatcase, the result will be a true otherwisethe result will be false. Similarly, we cancompare the two variables using greater thanwe can compare the two variables by less orwhether whether the whether one variable lessor equal to the other. For example, if X isless or equal to y, the result will be trueof this comparison the result will be trueif X has a value that is not larger than whyas long as x and y are equal or x is smallerthan y In any case, the result will be trueotherwise false. Similarly, greater than orequal to. Okay, so I end this video here inthe next video, we will be, we will be movingto Jupiter and playing with these operators,and seeing the return types of Booleans. Andthen combining them together with ands andORS and doing doing interesting stuff withthat. In this particular video, I just talkabout the comparison operators, the booleandata type and combining them by and or not.In the next video, we'll be first moving toJupiter, we will see the comparison operators,we will write all these statements in Jupiterand just get a good hands on grip on that.And then we'll be moving on verse. So hopeto see you in the next video. So in the lastvideo, I talked about comparisons, w equalto 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 entera markdown cell and type comparisons. ShiftEnter comparisons. So we can we can comparedifferent values by first assigning them tovariables. And then comparing those variablesor 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 ofa comparison operator is always Boolean, itis either true or false. So in this case twois smaller than three. So the result willbecause this statement is true. So the resultwill be true and true will be counted. Further,we can store that result in in another variablefor example to is smaller than three, whateverthe result is, the result will be true, theresult will be saved in a variable, see, ifwe check the type of seereject the type of seeing as long as let'sprint the value of C. So you can see the typeof C is Boolean, and C in this particularcase is true. Moreover, for example, let'shave three equals to four. Is that true orfalse? What do you think three equals to four,three, w equals to four, that is false, threeis not equal to four. And let's save thisresult in D, remember three double equalsto four, that's an operation the result isfalse. This equal is an assignment operatorthat the false value will be assigned to thevariable D. and here we can see Brent D. Burnit is false. Similarly, what do you think?Three double equal to 3.0? What will be theresult? Remember, three is integer. 3.0 isa floating point number. And I'm comparingthree double equals to 3.01 is integer, andother is a floating point number. So whatwill be the result? Let's say the result istrue, because they are comparing the valuesby discarding the decimal position. Further,let's see. Three is smaller or equal to solet's say x is equal to four, y is equal tonine. And z is equal to let's say 8.3. Andr is equal to minus three, let's say and theseare our variables. Let's see. So what do youthink what will be the result here x is smallerthan y. What will be the result of that xis 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 firstfirst this will be true, this will be againtrue, and that is false. Okay. So, this trueand true will return true and true or anything,the result final result is true. So, thiswill return or it's returning true. But, ifI just do if I just switch the order, forexample, if I just write this statement, whichis false, this particular statement here andthen I do this, what will be the result now,Now see, x is smaller than y it is true, ris equal to x that is false. So, this resultwill be false eventually, and z is smallerthan y, that result is z is smaller than y,let me just say z is larger than one, letme 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 switchthe listing r equals to x, I just want toshow you the precedents of r and x is smallerthan y. So now, if you see this is false,this is true, false and true is true, trueor false and true is false, this is also false.And the result overall is false. It shouldhappen, but what if, what if this goes first,if this goes first, I mean, I want to showyou 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, orfalse and true or false. Andtrue,what do you think what will be the resulthere, true or false and true, if true or falseoperate operate First, if true or false operateFirst, the result will be true, true and true,the result is true. If however, let me letme just write a false here. If all operatesFirst, if all operates first, then false orfalse 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 falsehere 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 willbe 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 overallresult 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 firstin this particular case and will be appliedfirst even if you even if you change thiseven if you change this order for example,if you even if you pick this thing and applyhere still the result is and will be appliedfirst and or will be applied after, it isalways good rather than to one way is to rememberthe precedents and will be applied first thenor, I mean it is good to think about the precedents.Another good thing is to specify the orderusing parentheses. For example, now, we specifythis first our will be applied and then fourand will be applied. So, it is good for readabilityto always apply these parentheses and andcheck the order in which ands and ORS andthe combination will be applied. So, the inany way the result of these comparisons willbe bullions. Question, what will be the resulthere? 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 willreturn 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 ortrue or false. We combine the different toolsand different Boolean values using ands andORS. And here is a question for you. Okay,I will see you in the next video with answerof this question. So I left you with a questionin the last video. So that was the questionif you remember. So the question really was,what's the what's the result here? So what'syour answer? True or false? The result, eitherwill be true or false, because these are allcomparisons and combination of Boolean values.So let's see step by step. First of all, let'ssee 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, thiswhole thing here till here is false. Now wehave or or and then we have false and truefalse and true is false. So, this whole thingis false this whole thing is false and orbetween false or false it is false. So theresult of this. So the So the answer to thisquestion is is false. Let me let me just convinceyou by typing the statement in in JupyterNotebook. So, if you remember we have Brent.Brent, not two is not equal to three and thenwe 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 goesto there and I guess Yes. So the result isfalse. The result is false. The purpose ofthis question was not just to the purposeof this question is to appreciate actuallythe fact how we can combine different Booleanvalues to to to achieve the final booleanvalue and these kind of combinations willbecome very, very helpful further in in controlflow and we will see the if conditions anddecision making and stuff so The answer tothis question is false. Yeah, and I end thisvideo here. In the next video, we are goingto 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. Andafter seeing those functions, then we willdirectly jump to control flow basically theif conditions and stuff where you will seethese comparisons, these Boolean values ina 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. ThatI think with the passage of time, we willbe covering more and more but let's starta function are sometimes, particularly a builtin function is is basically a feature fromthe language that is supplied for the usersto achieve particular task. For example, aroundfunction. If you give round for example, around,let's say 4.6. This 4.6 is a floating pointnumber, and rounding means make it as integer.And what round does is it finds the nearestinteger to 4.6. And the nearest integer inthis case is five, because five is more closerto 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'sone 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 tothe function. For example, when you writeBrent. Brent, let's say a, this a is calledargument to a function Brent. Similarly, roundis a function 4.6 is an argument round isfunction 4.3 is an argument, we will see functionsin details, and we will be writing our ownfunctions as well. But for now, just justbear that just bear with me that functionsare these kinds of features that are available.However, we we will be writing our own functionslater on. So this particular function acceptstwo arguments surround has two different kindof implementation. One is when it acceptsonly one input argument, it returns the nearestinteger to that, if it accepts a floatingpoint number as well as another argument likehere 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 basedon its next value. If the next value is largerthan five, then eight will go to nine andstop. If the next value is smaller than five,then it will stay as eight and the resultwill be three decimal places after this. Solet's practice this round function just ona 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'srounded 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 printround, four point, let's say 345. Let's see,and the result will be for the reason is 4.345is 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 onlytwo 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 largerthan five. Hence it is rounded up. So 4.56If however, I call this function for threeThen what do you think what will be the resultit will be 4.55. And the six will be roundedup based on the seven, and it will become4.557. Yes. However, if, for example, therewill be a value at at the place of seven,if there is a value, let's say three, thenyou call this function, then 4.556. And thenbased on the next value three, the six willstay 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 functionbasically divides and returns quotient, and,and remainder. So in the next video, we willbe 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 diffmode, and there are a couple of more functionsthat we will see in the upcoming videos. Sohope to see you in the next video. So in thelast video, we saw round function that sometimesaccepts one argument and sometimes accepttwo arguments and behave accordingly. In thisparticular 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 twooutputs, two numbers, two terms basicallyquotient and remainder. For example, in thisparticular case, the quotient is five, andthe remainder is two, because if five is dividedby if 27 is divided by five, the result isfive, but then the remainder is two. And theresult is returned in a kind of an orderedpair. And these kind of collection in whichwe have two or more elements, we call thesecollection as tupple that we will see in detailwhen we will see the data structures moduleof this course. But right now just bear withme that it returns two numbers, two elements,and the two elements are ordered in an orderedpair, which is called a tupple. A tupple isnot just an ordered pair, it can have threemore three, four, or five or seven, or maybeseveral elements. But right now we will atupple is just an ordered list, which we willsee in detail. So let's see the working ofthe 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 27So three, three is the quotient. And the remainderis remainder is seven. So three is quotientand salmon is the remainder. So and if yousave the result, for example, if you savethe result in a variable, let's say G. Soif you see the G the type of G if you if youjust type the type of if you just find thetype of ci it's a tupple, which we'll seein details, and if you see the contents ofG if you see the contents of G the contentsof gr three and salmon, and if you want toaccess each element independently, then youcan access the element first element, becausethe if there are multiple elements in in avariable normally that that kind of variablesare called collections that we will see indetail later on. And these are the indexingthe positioning is start by zero rather thanone. So g zero means the first element ofG which is three in this case, and the secondelement of G is oneat one, which is seven. So, this is basicallythis 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 thedata 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 canachieve dev mode by by another by anotherthing. For example, if you want to achievea more 34 nine, you can do the same thingby let's say 34 divided by double dividedby nine that will give you a quotient. Andthe question is three and further if you write34, remainder nine and that will give youthe remainder that you need. So you can callthat function Dave mode. Or you can use thesetwo there are multiple ways of doing the samestuff. Okay? So, yes, so, I mean, sometimesit's useful when you're going and knowingthis kind of function that returns quotientand remainder. Okay, next function that ismore useful is is in stance, and we will seethis function in the in the next video. Sohope to see you in the next video okay, thisfunction is in stance, it actually returnseither true or false. And it just checks thatparticular given data value belongs to thistype or not. For example, if you want to checkwhether one has type integer, so, you cancheck that using this function by the way,you know that one is of type integer thenyou may think that why on earth one shouldbe interested in checking the type of oneif somebody no it is in teacher, sometimes,we have certain variables and certain datais stored in it, and we want to check thedata inside it belongs to which kind of typeand in several cases the value to this variableis not assigned by us It may be read fromsome file or maybe through input a user givesome number or something like so. So, sometimesit becomes important to check the type ofa particular way if we are if we are expectinga 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 whetherthe given value has a particular type of not.So is instance one int returns true is instance1.0 integer that returns false maybe, becausethis is a floating point number, and you cancheck a particular value belongs to one ofthe several types or not, you can give severaltypes 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 thesame 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 threeis 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 noit does not end in Deezer. If for example,we check if this is not in nature, then maybeit is a float? The answer is yes. Or maybewe check that. For example, if that valueis either float or integer, if it is one ofthese, then I mean check that particular valuein this particular case 3.4 whether it belongsto one of these types, we can increase thesetypes, for example. So, let's say we we gavea complex number here and check is in stancelet's say two plus three j that's a complexnumber. And let's say we asked whether itis an integer or float or not, the resultis obviously false. And the reason is, itis neither integer nor float or even if wegive string there str, so, it will still sayno it is notnot any of these, but maybe there is a complexdata type if you see that, that says yes,because it is complex. So sometimes this isinstance becomes really useful. Next functionis power. So power you can you can computepower by the way using using for example,if you want to compute x raise to the powery, you can use double star and that computesexactly x raised to the power y or equivalentlyyou can call the function POW x comma y andthat will give you the same result as thisone. But power sometimes take three argumentsas well. And in that case, it it a it performsthe power function in a different behavior.So for example, if you supply three argumentswhat it does it it raise y to equate x raiseto the power BI whatever the result is, thenit takes the remainder by z and gives theresult. So let's see the functioning of thispower function in Jupyter Notebook. So let'ssay Baba, I want to compute to raise to thepower for the result is 16. No problem. Toraise to the power four, I can compute theresult 16 this way as well. But here is anotherway, how can we use this to raise to the powerfor whatever the result is, then I want totake the remainder, by let's say, I want totake the remainder by seven, or two, so we'vegot four is 16, then if we take the remainderby seven, the result will be two. And that'sthe result two. So that's how you can usethis 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 thesekinds of functions so that in future if yousee another function that he had not seenhere, you'll be able to use it and apply it.So in this particular video, we saw this isin stance function and this power function.In the next video, we will see one more functionthat will allow you to take input from theuser. So far, we are supplying values or assigningvalues to variables directly, what if on thefly, we want to give the values and thosevalues 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 seeyou in the next video. So in this video, weare going to see a very important functioncalled input. This function is I mean, thisis beneficial for taking input from the keyboardfrom the user. And the way to call this functionis you type input. And then you type a messagethat actually describes the expected entrythat for example, into something if you wantsomebody to or tell somebody to just incurlet's say, a number, you can write into anumber, or any specification to help the userto enter whatever input the user want to interestproperly. One thing is that no matter whatthe user will enter, the variable a will behaving 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 numberif 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 convertthat string to a number, and, and so on. Sofor example, let's see, let's see on the JupyterNotebook, 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 thenI press enter, not Shift Enter, Enter, thenx will receive 56. Now, you might be thinkingthis 56 is an integer, so the type of x shouldbe an integer. But this is not the case thetype of x will be a string. And the reasonis, whatever you enter is received as charactersfive and six, even if you have entered somethingelse that would have been received as a sequenceof characters. So this is no longer a fiveas a digit five, six as a digit six. Theseare 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 nowconverted this string to integer and thenwhatever the result is, you have stored thatresult in x again, if you now see the typeof x type of x, the result is integer. Andyou 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 expectingan 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 toconvert 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 areproblems for example, if you are if you areexpecting float and somebody enters into somethingthat 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 willcatch an error there are ways to avoid thesekinds of errors and programming program breaksusing exception handling and there are otherways, but be careful I mean the user is notI mean the one who is going to enter the theenter the input if that that user is not restrictedenough, then you can get errors. So, I mean,this is not the case that whatever you willenter it will be converted to a float if itreally, if whatever you have entered is reallyto convert it is really convertible to a floatthen it can be convertible to a float, nototherwise. And at the input time, there isno restriction you cannot restrict the keyboardto 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 justlet me just go through quickly we have seeninput we have seen is in stands, we have seendiff mode, we haven't we have seen power function,we have seen the round function and thereare several others. Yes, so from now on, wewill be actually moving towards basicallydecision making based sometimes we will usethese kind of functions, mostly you will beusing input function, but sometimes we'llbe using maybe other functions like thesefunctions. And sometimes we will be doingdecision making based on the ease and andstuff like so, one thing that I want to tellyou is if for example, you know the functionname, some function, let's say like power,you know, that POW power is a function, butyou do not know how to use that function.One way is to just type question mark in frontof it, and then just press Shift Enter,and in front of you, the documentation ofthe power will open up so it will tell thatthis is power, that's how it should be calledand then some description will be in frontof you that equivalent to x raised to thepower y with no arguments, the two argumentsare equivalent to x raised to the power yremainder with z with three arguments andso on, if you want to see implementation ofthis function as well. We will see the functionslater on but if you want to see more aboutthe help, you can type the double Sam equala double question mark and more things shouldbe open up in front of you. So, in this particularcase, the small function does not have animplementation in Python. So, the single questionmark and double question mark are the sameat one more way is to use the help functionhelp out and you will get a lot of informationabout the power how for example, help on builtand function power in module built in. Sothis 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 inputand this is how this can be used. So sometimesit is okay if you know the if you know thename of some function, and you know how touse it, you can just open up the documentationright here in Jupyter Notebook by either usinga help function or you can use just a questionmark in front of the name and so on. So, that'sabout the functions. In the next video, wewill be seeing the power of comparisons andthe decision making or sometimes called thecontrol flow. So the real fun will begin fromthe next video because we will be actuallydeciding which part of the code should runand which part should Not run based on basedon certain conditions. So hope to see youin the next video. Okay, we are in controlflow, 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 usinginput, I have not supplied the input messagehere, the message is optional. It's a descriptionif you supply that that's okay, if you don'tsupply even that, that's okay. So A is somenumber the user will supply when the codewill run B is some number the user will supplywhen the code will run. Now, once you havea and b in front of you, obviously the userwill supply that on the fly, you don't knowwhat the value of a and b are. Because whenthe 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 valueof b is that you don't know, the user willsupply that value those values, your taskis to print the value that is bigger thanboth. So for example, if a is bigger thanB, 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 howdoes Python allows us does Python allow usto do that, for example, if a is bigger thanwe should print a, if b is bigger than weshould print B, remember again, and againwe are we are talking in terms of if A isbigger, if so this is this is this is whatif 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 towhat, so if a is bigger than B, then do certainthings. Otherwise, don't do that. Those kindsof things. So this if condition is really,really powerful, and is available in all programminglanguages. In here, for example, let's seeif a is an input B is an input, writing anif condition, that's if is a keyword. That'sa comparison that we have done earlier aswell. And then the syntax required a colonin front of that. So if this condition istrue, if this result, if this comparison resultsto remember the comparisons, they return Booleanvalues, if this comparison, if this, whateverthe result of this operation is if that istrue, 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 thana, then B will be printed then or they mighthave printed, for example, we might have printedrather than writing this we might have mighthave printed, let's say just print B becauseb is bigger. If b is not bigger than a, whatwill? What we will do them. So yeah. If bis bigger than a then B will be printed? Yes.Because then you will be inside here. If bis 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 wedeal with that if b is not bigger than a kindof condition? So let's first see the blessingsof if condition and Jupyter Notebook. Yeah,so let's say a is an integer. Let's say you'reexpecting 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 isthe indentation that defines the block ofa let's say if I want to print a, then I wantto print, let's say, I am still inside. Ifcondition, condition, and so whatever thatstarts 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 blockis 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 likethis, this is no longer inside the if condition.So, for example, here I type I am outsidethe if condition. So, the purpose of writingthese multiple lines is just the if conditiondoes not require to contain only one lineof code, it can contain a whole block of codemultiple lines of codes. So, this is no longerinside the if condition. So, now we will takeinput a input B, whatever the numbers willbe, if the value in a will be larger thanB, then this will be printed and this willbe printed. Once these two are printed, thenthis has to be printed regardless of the valuesof a and b, because this does not this lastsprint statement, it does not depend upon.This does not depend upon the values of aand 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 isnot bigger than B, then neither this willexecute, nor this will execute. But this willstill execute because this is this has nothingto do with the condition. So let's run thiscode 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 haveappeared 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 1212is bigger than B if this condition is true,this statement becomes true. Whenever thiscondition becomes true, you're inside theprints you are inside the if condition. Nowthis print executes and you're you get wellthis print executes and you get I am stillinside the if condition, and this has to executeno matter what the values of NBR so now letme read on this and give other values of aand b let's say the value of a is 10. Andthe value of b is let's say 45. Now, thiscan this condition becomes false because 10is 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 theseare the statements that are inside the ifconditionthey cannot execute because because you nevervisit them, they can only be executed if conditionbecomes true. So then once you're out theif condition that's the statement there isgoing to be executed anyways. So yeah, sothat's the flavor of if condition on the seeand making and this is the comparison operatorthat returns a Boolean value. You may havedifferent kinds of comparisons here or combinationof comparisons here No, no problem dependingupon your logic. But the question is, arewe done we are going to print only the biggernumber we have, we have printed the one thatis if a is bigger, we have printed that whatif if b is bigger, we have not solved thetask 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 biggerthan a, then we will print B. Maybe Maybewe should make maybe we should apply anotherif 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 Notebookand, and write the following. Let me let mewrite a whole new program here. A equals andimport. 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 becomestrue, then this condition cannot become true,because it cannot happen there is becausethen B as well as B is bigger than a Thiscannot happen. So, whatever the bigger numberwill be that will be executed further youcan see I have this if condition and thisif condition they are aligned in a way thatthis if condition is not this the second ifcondition is not inside the body of the firstif condition, we will see such cases suchcases 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 willbecome true, because A is bigger than B Bis bigger than a, these two statements cannotbe 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 fourand the result is 22. Because 32 is bigger,I guess we are done with the task, we haveused this if condition twice to achieve thetask to print the number that is bigger andboth 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 particularlythe L statement, whatever what we have donerecently with another if could could be achievedthrough an L statement that is more powerfuland more readable. So in the next video, Iwill 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 wewanted to know we wanted to just print thegreater number. So we input a number a weinput a number B and if b is greater thana we printed the is greater than eight, thenwe applied another if condition to check ifa is greater than b, then paint a the elseclause 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 thisis not true, which means else if this is true,then go there, else go there. So if this istrue, then you learned here, if this is false,then you learn else part for sure. And thiselse is I mean, if b is greater than a ifthis condition is true, then you print thisthing. Otherwise, a might be greater thanB or A might be equal to b either way youlearn in else part. So this if and else theyboth have this alignment, but then the blockof ELLs started from this particular alignment,maybe you have more statements here, the alignmentof this if block structure from here, andyou may have more statements here. So let'sgo to the Jupyter Notebook and see the elserunning. So let's say a equals and input andB isB is int input and we say okay, if a is greaterthan b, then brand aelse else rent else brand be elsewhere outspentB. 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 ShiftEnter. So input a number. So A is let's say10, and B is let's say, 12. So what do youthink when I will press enter what will beprinted, B or A, B, B is printed, that's whatB is printed. Now, if I run this again, anda is done, and B is done, still the 10 willbe printed. So let's modify it, let's, let'sjust say, print. If part. So that means welanded in if part. Otherwise, we landed inEllsberg. So just to be more elaborated, let'ssay 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 LSblock, the whole block just executed. So that'swhat else is, it's really very nice to havean L state or whatever this whenever the,if this is false, whatever that conditionis, 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 wewant, if a if b is greater than a, then youprint B. Else, if A is equal to b, then youprint they're equal. And if this is false,and this condition is false, if both theseconditions 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, ifb is larger than a, then you land in thispart else, if this L is just short form ofelse, else means B is not greater than a else,you can have another check elsif A is equalto b, then do what?ll, if we can have one more check, we can haveone more check, we can have several checks,and then else else will only execute if allif conditions or elsif parts on top. Theirconditions, they are false, and only thenelse will be execute. So let's see these ldiff running on Jupyter. notebook. Okay, solet's say a is and so rather than taking inputs,let's say is one, B is let's say five. Let'ssay we have taken these inputs is one B isfive, if A is if a is equal to b, then theword rent equal l l F, which means else ifnow, because this is if you should you haveto write a condition here, which will be eithertrue or false. If A is larger than B, thendo 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, thisis 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'sfalse is larger than B that is also false.So you will learn in export and B will beprinted and then a statement will be printedwhich is not an F. So yeah, so B is printedand not an F. If b is 10, then what will happen?A equals to B that is false, so you will notland here. Else if A is larger than B true.You will land here because you land here elsewill not execute. So He will be printed andthen not enough. If A is 10 and b is alsobanned, let's say, then you have equal. Yeah,so that's elsif. Okay, so that's about ifelse if else if or short form is lf l structure.In the next video, we will be talking moreabout this if else if else structure in abit more detail. And we will also be givingyou a short form of this this guide of ELLsif elsif elberfeld of structure. So hope tosee you in the next video. Okay, one way ofwriting this, if elsif else kind of structurethere 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 printthis particular thing, if A is equal to b,l sprint that this is exactly the same kindof structure, for example, print a, if A islarger than B, so you just read that if ais 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 Iwill, I will recommend to to to use, I'm inthe structure in this particular horizontalform. Rather than writing that in this particularway. Because this kind of structure, thathorizontal kind of structure is much morereadable, much more manageable. And this mightbe this structure might be confusing sometime for for some kind of readers or, andalso 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 ofstructure in this way, this is available inPython. Okay, let's let's get a good gripon this f LS f l structure on Jupyter. notebook.Let's move on to Jupyter Notebook. To seean example, just an example. So let's saythe example is user will input a number, let'ssay 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 than85, then we will print a grade. If the marksare larger than larger than 80, but smallerthan smaller, so if the marks are larger equalto 85, then we will print a grade. Else ifmarks 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 willpaint we will print for example, b grade forexample, b grade, and so on, let's print thiswhole nested structure that let's let's makethis else. if else if elsif kind of structurea little empty, let's let's get comfortablewith it. So if a is larger than or equal to85 to enhance readability, it is good to includea space is a space after the variable andspace but don't actually write the space insidethere because larger and equal to the combinedwithout space is an operator. So if a is largerthan 85, then print let's say a grade ratel if A is a is larger or equal to a D andE is smaller than 85. So let me let me writethis in a more readable form. Else if A issmaller than 85 and is larger or equal to80 then we should do what it is sometimesgood to include these kind of parenthesessometimes it is good just to make these thingsmore readable that this is one block. Thisis one this is one Boolean, this is one Boolean,this is one to see and this font is E andalthough not writing the parenthesis is alsookay. But writing the parenthesis make codea little more readable. So, for example, ifa is smaller than 85 and a is larger than80, if that is true, So, remember and is trueonly when the left side is true and rightside both are true, then this whole conditionbecomes true. And I promised you that I willshow you the power of comparisons and actuallycombining the Boolean variables using andsand 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 smallerthan 80. And a is bigger or equal to 75. Ifthat's the case, then what should we do? Letme omit the parentheses just to show thatwhether writing parenthesis or not writingparentheses is perfectly okay. I just recommendright parenthesis, so the code becomes muchmore readable than otherwise. Okay, then wehave Brent, let's say, b grade. And let'ssay 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'ssay. And let's just finish this let's elseprint. below. Average, for example, let'ssay that's it, that's our, that's our record.So, we will we will enter numbers, if thenumber is greater than 85, then a grade if,when this condition becomes true, then thisprint will execute. And we will out of thestructure right there. If this condition isfalse, then this condition will be checked.If this condition becomes true, then thisprint will execute. And we will be out ofthis structure. If this is false, and thisis false, then this will be checked. If thisis true, then we print degrade and we areout. But if this is false, then this willbe checked. And if this is true, then we'llprint b minus grade. And we will be out. Ifthis is also false, then we will dive intoL sport and we will say okay, below average.So let's see, for example, let's say the marksare at two. So a minus grade. That, that thatthat makes sense, a minus grade because themarks 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 uponyour 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 megive you one more or one more beautiful thing.let's let's let's create an L without writingan else or let's let's just let's just writelF and implement ELS completely so we arenot going to write ELS explicitly, but weare going to write a program that actuallysimulates ELS So let's see, if a equals let'ssay, three. If A is larger than 10, then Brentlet's say larger than that. Now, we are notgoing to write else, but we are going to achievethe aerosport.Tell Ifnot,a is bigger than 10. To see, then print yousee that I mean, that's beautiful. If thiscondition is true, then go there. If thiscondition is false, then not have false istrue, then you learn here. And you need notto write an expert if you want just I've implementedI have implemented l spark using l f. So seethat. 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'sshorthand and LDAP structure in in a bit more,lengthy way. So in the next video, we willsee if condition inside or in the body ofanother if condition, which is called a nestedF. 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 bodyof another F. So let's take an example tounderstand what nested if condition is simplywe can understand if condition inside anotherif condition, that's all rest of the storyis same. The way it works, it works even ifit is inside the body of another if or oranywhere, actually. So let's say we have inputa number, and then we check if x is largerthan 10, then you move inside the if condition.If that is true. If that is false, then youare here, whatever you write here, it willwork from here. But let's say x is greaterthan 10, then you print your number is greaterthan 10, your number is above 10. Let's saylet'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. Thisparticular statement is inside this particularif condition, if this, this condition becomestrue only then you dive in, otherwise you'renot. So here you're checking if x is largerthan 10, then you move inside and inside you'remaking more checks. So for example, if x islarger than 10, then you print or do somestuff here, then you apply Further more, morechecks more graduality more, whatever yourlogic is. So let's say here you're checkingif x is larger than 20. Now, if this conditionis true, then you move here else now thiselse is of this if if x is not larger than20, then you move to this else l squat andyou're here. So and we can have another ifinside this particular F or an F inside thisL 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 verylengthy 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'ssay we take some number and if a is largerthan 10, then we say okay, Brent, larger than10 and do more stuff, Brent. That's inside.If condition, okay, then then maybe we haveanother check if A is larger than 20 thensay rent greater than20 Yeah, greater than 20. And you can rentnow rent inside the nested if, okay. Elserent 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 allit's fine. So that's it that's that that'sthe structure. So let's see, let's give aninput which is larger than, by the way, ifinput is not larger than 10, this if conditionis false, then you directly dive to this printstatement and all this structure is not goingto be executed, this is this complete thingis called the body of this if condition, andthe body will only execute if the conditionbecomes true, whether that condition is justa single condition, or you have a combinationof a lot of comparisons and a lot of Booleanswhatever, if this condition becomes true,whatever that condition takes form of, thenThen and only then you dive into this part.And when you are in this part, then that'sa 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 particularif condition, and that's the body of the elsepart, see the the body of the top if conditionhas this kind of alignment, all the statementsthat are in the body of if condition, theystart the same alignment, and all the conditionsall the statements that are in the body ofthis particular if condition, they have theirown alignment, and this indentation is necessityjust to define, for example, which statementis in what kind of block for example, if Ijust press a tab, then another tab, then thisprint statement is in this L sport and thisis the indentation that is defining the placementof this print, if for example, I press I alignthis with this, this particular structurehere, then this print statement is insidethis if condition, this is the indentationthat is defining the placement of differentstatements. And if the print starts from here,then it is completely outside of all if conditionsit is like this way. So let's run this boardand see what happens. Let's say we brand let'ssay 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 printedinside the top if that will be printed, thenthis check will be executed and this conditionwill become false because 12 is not largerthan 20 then you will go to the else partand less or equal to 20 this number this stringwill be printed and then inside the else partof nested if that will be printed and thenyou will be out of all if condition then outsideof all F's that will be printed. So let'ssee whether whatever we have said is corrector not. So yes, greater than 10 inside thetop if less than or equal to 20 inside theelse part of the nested f outside all F'sYeah. So that's what the nested F is. Andby the way, you can have you can have forexample, more if conditions inside the nestedifs 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 necessarilythat you always write print statements youcan do any interesting stuffinside inside the nested if of nested if findand then you can write the else part of thisparticular if condition here if you want toor or whatever I mean you can have as hilariousstructure as you want, but that completelydepends 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, forexample, 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 cansee that completely see that program. I mean,yeah, it makes perfectly sense to me, forexample, you take an input, if that is largerthan 10, then you're here. If it is largerthan 20, then you are here. If it is not largerthan 20, then you're here. Okay. So let'ssay it is larger than 20. If it is largerthan 20, then you are here further, if itis larger than 30, then you are here. Otherwise,you are here. And once and by the way, ifA is not larger than 10, then you are directlyhere. Wow. So let's run this code. Let mejust scale it down so that you can see itmore. You can see more text. Let's see. Solet's run this. No errors. Great. So let'ssay the number is let's say 25. So, what doyou expect the result. So the number is 25is greater than 10 inside the top if it isgreater than 20 inside the nested if it issmaller than or equal to 30. So inside theelse 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 thingthat I have already told you, but just letme tell you the power of indentation. Youare here for example, in this particular ifcondition, that's the if condition and that'sthe nested if, and that's the else part ofthis if if you move this L sport in in theindentation or the alignment with this ifthen this is else part of this if and thisis not the else part of this If so, rememberthe power of indentation the this is the indentationthat defines which part belongs to what whatkind of block or structure in Python. In otherlanguages. Sometimes, for example, in c++,they they normally use to write these curlybrackets to define a block and their indentationdoesn't really matter. But in Python, thisis the indentation that actually defines eachand everything. So, for example, this is acrucial example if this else just moves backwardsand aligned with this f you get this elsewith 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 thisnot 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 toldyou that the indentation has already toldyou but I just I just found to make a slideover this elsewhere because that's important.Sometimes you may get confused whether thiselse belongs to this F or that F Well, theindentation defines this LS belong to what?Okay, I end thiscontrol flow indentation here. So from nextvideo we are jumping toward loops. But beforeloops, I just want to I just want to writea lengthy program in F LS f there are combinations.I just want to write a Jupiter program foryou to to get comfortable with F nested fthe conditions that are ands and ORS and notsare stuff like so. So So in the next videowe will be practicing more on Jupiter forif conditions and then from the next to nextvideo. We'll be jumping toward loops, thevery very powerful structure. Okay. Hope tosee you in the next video. Okay, so let'sjust practice this if condition a little bitmore in this particular video and we are goingto 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 neverbe 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. Commentor description with a single line. If yourcomment goes on multiple lines, it is goodto 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. Sowhatever 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 problemin form of text. And then we will be solvingthat problem using using the code. So that'sjust 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, integerportion, 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 portionis 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 problemthat we are going to solve. And this is justto commit now we are outside the command that'sa 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 toget comfortable with the if conditions, let'ssay let's say that number is x is input, letme convert that inputinto ourreal number. That's it. Okay, we're just assumingthat the user will enter a real number. It'sreal number. real number might be I mean to38.0, that's a real number or 238 itself,that's also real number. That's okay. Butwe're not assuming that the user will enter,let's say some characters like ABC or stufflike sort of just just assuming that. Okay,now, assume that x contains real number, itmay be an integer. By default, maybe userjust enters 10. And that's it. So it may bealready an integer, then we have to checkwhether that 10 is whether that 10 is evenor not, or the user may enter 11.7, or theuser may enter minus 34.7. Or the user mayenter just zero or user may enter just zeropoint 30 535. There are a lot of possibilitiesthat a user come up with this exe can containany kind of number, and we have to check accordingto. So how can we move let us just see, whetherthat number let us just extract the decimalportion, the portion before point. Let's justextract that how can we extract that thereare 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? Andif 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 decimalportion, the portion without this particularthing? How can we extract that? That's, that'stricky. That's kind of tricky. Yeah. So any,any ideas? I guess this? The the structureI 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 integerportion? Or maybe there is a function thatactually round down? Let me check whetherthere is a function float or not? No, floatis not a function, I guess. So let's say roundx. Okay, now y contains the rounded vol valueforever the Xs we are now assuming that xis 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 thelet me so we just subtract the integer portion.So the let me in teacher portion, let's saythat'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. Forexample, for example, just Just think aboutit, if When, when, for example, if the valuewas 29.6, and the rounded value will become30, so 30 minus one will be 29. There is whatwe 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 subtractone and we get the proportion. Otherwise,the rounded value itself is the portion, justjust let's just run this, run this code fornow and check whether what whatever we havedone 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 numberis, let's say 25.3 45.367. Let's say, obviously,the integer portion here is 25. So let's saylet'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 thisagain. And order this time let's give it to45.8. Okay, the integer portion is 45. Butwhen we will round We will get to 46 and 46minus one, we will dive into this particularif 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 give0.2 the result should be zero, it is zero,right? Let's run it again and give it let'ssee, 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 numberwas 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, thenwhole this logic just works okay, then elseWhat should we do? If x is positive, thenthis logic works effects is not positive,then what will happen? Then how can we findout the integer portion because first we haveto find out the integer portion and then wehave to find out whether they are integerportion is even or not finding out whetherthey are indeed a portion is even or not mightbe simpler. But first, we have to find outthe integer portion. So for example, let'scheck the behavior of round function on negativenumbers, 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 inthe positive numbers. So round function isactually working roughly the same way it shouldwork in the positive numbers. Okay. So whatshould we do here? Any idea? Maybe, maybewe first convert? Maybe you first convert,by the way? Yeah, maybe first convert thenumber, let's say y equals around x again,like before, but then what? Then what? Somaybe this rounding helps the same way? Maybethe rounding helps the same way. We shouldextract 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 ify is greater than x, what should we do? Ifit is negative y is greater than then whatwould what will be the portion? It will bethe integer portion will be portion will bewhat?y minus one or one? y plus one? Yes, you gotthe answer? That's y plus one. Great. Andelse I guess we have in future portion. EqualsWhitesell, I guess, yes, I guess that's thethat's the good. That's cool. I guess that'schecked, by the way, but I guess that's thecode. By the way, this else part is, thiselse part is same in both of these conditions.So maybe, maybe we can combine this code andwrite a more elegant code, but I guess thiswould work. Let us just print the integerportion, just to check whether we are workingwell, so far or not. So let's enter let'ssee 12.3 The result is 12th grade. So it didnot change our previous I guess our previouslogic. 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 whenit 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 conditionshould flip. Yeah. So we are making an errorhere. Let's fix that. Okay, let's run thisagain. And see Let's say minus nine pointminus nine d 3.2. Minus 93. Great. So thenwe have let's see, let's run it again. Minus8.9. minus eight. Yes, we are working perfectlyfine. Once we have integer portion with us,we just right here. At the very end if integerportion is your portion, remainder with two,if that equals to zero, if that equals tozero, 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 minus87.3. That's odd rate. So you see the power,if condition and, and how can we think inwriting these programs and stuff like so?That was a lengthier video, I know. But Iguess you get a very good look and feel of,of if conditions and thinking and buildinglogic and all that stuff. So in the next video,we will start loops. So that's a beautifulstructure, hope to see you in the next video,the best way to understand loops is to thinkabout 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 usergives you a number, let's say integer number.And you want to print all the numbers tillthat number, let's say you start from one,and you keep on moving and printing all thenumbers, 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, andthen 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 inn, we can just print, we could have writtenthis thing, print. Brent, I, let's initializea variable by with one, Brent I, and thenI equals two i plus one, or in Python, wecan write this quickly as i plus equals toone that means Ithat means in I store a plus one, this isthe short form of writing this. And then afterthat, you just apply an if condition. Forexample, here, you can apply an if conditionand say, Okay, if I is smaller than n, youkeep on printing, and after printing, youjust increment again this, then check theif condition and keep on moving. Well, thatis visible if n is five, or n is three, whatif if n is let's say, if t 1000. In I mean,you're writing all that structure again, andagain. And again. I mean, that's a lot ofcode. Well, the loops are just a solutionfor 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, youevaluate 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 blockonce you check this condition again, if thiscondition is again true, you will dive intothis block again. Then check the conditiondive into the block then check the conditiondive into the block. As long as this conditionstays true, you stay in the block you youmove inside the block. Once this conditionis false, then you exit this while loop thenthe loop terminates and you move on to thefurther processing just like an if conditionjust like if conditions if if the conditionbecomes false, you accept that if conditionand 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, nowone is smaller than five, the condition istrue, we move inside, you print I, the valueof i is one. So that's what you print, youprint one, then you change a, you incrementi with one, that means i equals i plus one,so I becomes two. Now the body of the loopfinishes, 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 smallerthan five, yes, it is true, you move insidethe block again, you print two, then you updateI, 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 issmaller than five, yes, you move inside, youprint three, you update, I, you check thecondition four is smaller than five, yes,you move inside you print four, and then youupdate I and then you move on now five issmaller than five false. Once the conditionis false, you will not dive into the bodyof the loop, you will exit the loop and youwill 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 interestingprograms, most of the interesting problems,these are the loops that play a very hugerole. 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 makethis a little bigger, just do. Let's say thatinput and input is a number, let's say n iis your surgeon, let's say let's say one,while I is smaller than n, you may have writtenthis parenthesis just to just to create thereadability just to make readability. Andotherwise I mean, this is also Okay, that'sperfectly fine. If as long as I is smallerthan n, keep doing the following you whatyou do is bring, for example, the square ofI paint the square of I, that the square ofit, let's say, and then you say, Grant, forexample. This is a question number. And thenyou just print I, that's the iteration numberI have the loop.That's the equation number I this is justthe spring, this is just a string. And that'sour variable, its value will be printed. Thisprint function takes as many arguments asyou pass. So you can you can write a commahere and continue whatever you want to print.That's very flexible function. Okay, thenwhat you do you say, Okay, I plus equals toone. By the way, this i plus equals to oneis the same as i equals i plus one. You see,I have just commented here just to explainwhat this is doing. If I just write i equalsi plus one that is also that is also correctin 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 forexample. So let's run this code. Let's runthis code. For example. Let's say n is equalto five, then we have five. So this is one,this is the aggression number one, then twosquare is four, this is the aggression numbertwo, then three squared is nine, the aggressionnumber three, then four square is 16. Thisis the iteration number four, and then theloop finishes. That's it. That's the firstsnapshot of the loop. We will continue fromhere 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 loopand we saw one. One program related to whileloop, just printing Just printing a bunchof 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 youcan apply an if condition inside the bodyand check that an at each iteration a particulardecision should be made or not. For example,in this particular case, I'm going to printI whenever I is an even number, so, I is somenumber if it is even then printed, else passthis pass statement for example, is just astatement of saying that do nothing It isjust a shortcut of writing do nothing we couldhave we could have omitted the whole elsepart along with this pass and still the codeis equivalent but sometimes writing this pastmake the code readable just so so writingthis boss statement just means do nothingand 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 equalsone one is less than five Yes, one is notan even number. So go to the else part elsemeans boss, which means go on and then incrementi this print statement is outside the loopthis 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 moveback to is smaller than five years. Two remaindertwo is zero Yes. So brand two, so two willbe printed. Because if executed else willnot execute and I will increment because Iis not inside the if condition it is insidethe body of the loop. So I incremented I becomesthree 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 twois zero, yes, so Brent four. So else willnot execute now increment i, once you incrementi you get, for example, I equals five, nowfive is smaller than five false, so you goout of the loop and you print down. And that'swhat this code is. So, you can have if conditioninside 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 sometimesrarely required. Okay. So, next there aretwo important statements that are there, oneis break one is continue, I want to focusthese statements because they have a deeplink with loops. A break statement where everwritten inside the body of the loop tellsthat exit the loop immediately whenever thisbrake is encountered, whenever this brakeexecutes, it exits the loop immediately andbrings you outside the body of the loop. That'swhat it does break. So for example, if I becomesif I becomes divisible by 17 and the remainderbecomes zero, you will print a break and thenwhen this break statement will execute youwill exit the loop immediately regardlessof what is the value of AI What are otherstates wherever break exits the loop Okaygreat. Now, the continue continue statementscontinue statement wherever encountered continuebrings the next iteration loaded regardlessof the remaining remaining statements in theloop for example, when this continue willbe executed, no matter how many statementsare there onwards that are there, in the bodyof the loop, the loop will not finish itsiterations iteration by going through allthe remaining statements, but it will startanother iteration immediately. So continuebasically skips the remaining body of theloop and starts another iteration. Here Ihave written this. true true means while truemeans always run. You might be thinking alwaysrun it's an infinite loop will it will itwhen we will exit the loop because this truestatement will always stay true. We're notchanging this true anymore. There is no conditionhere. That's true. While true means alwaysgo inside the loop but once where wheneverthis Break his encounter, you're outside theloop right away. And this break exists, theloop does continue skips the remaining remainingportion of the loop body and starts the newiteration starts another iteration. So thiscontinue means start another iteration immediatelyskip the rest of the stress of the statements.So the rest of the statements inside the loopbody. Okay, so let's just practice this breakand continue with just just in Jupyter Notebookto get a better look and feel of the loop.So let's say we have, let's say again, let'ssay n equals let's say 10. Or we might havetaken that as an input, let's say n is equalto 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 tozero, then just break the loop tells ELS.Else, what you do is really you incrementa else what you do is, if I is if I is notdivisible by nine, then what you do is i equalsi plus one, that's true. By the way, previously,we we have written this way. So either wayis 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. Andthe reason is, why it is Oh, one is not oneis divisible by nine, only then you couldhave break. While true. Why? Why the loop?Oh, it does not print anything, we could haveprinted 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 statementdoes. So let's see an application of continuousstatement. That's for example, just copy andpaste that code into another cell and seehow this continue works. So, let's say wehave a loop like so. So, what we say is likethis, if I is nine is not equal to zero. Ifthis is the case, if I is not divisible bynine, what you do is you get take i plus equalsto one and then continue continue to the nextstatement. And whatever else you write herefor example, brand something brand somethingelse something else whatever that is goingto be printed and what wants to continue willwill be encountered whenever this eye is wheneverthis I divisible by nine is not true. If Iis then you continue once this AI is divisibleby nine for example, then you will not followthen you will not dive into this if conditiononly then these two statements will be printed.Because this this continue will not allowanything further that should happen. And oncethese are printed, let's say we break ourloop right there, let's say so if for examplefor the very first time one is not divisibleby nine, so I equals two. So continue thesethree statements will not be executed thenext 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 onlythen we will break and we'll exit the loopand print the data. So let's print here. Brentinside, if so, let's run this code, let'srun this code and see what happens. That'sthe 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 whenyou are inside if when you continue when whenthis is the body of if condition when if conditioncompletes, it should print these two things,but continue is telling the cursor to go backto the next iteration and move on. And oncethis if condition becomes false, only thenyou get this distinct printed this thing printedif this break was not there, you do you thenagain was going to the while loop and youwill be running an infinite loop and thenyou have done so that's what this continueand break does. So, in the in the in the verynext video we will see another kind of loophere we saw the while loop in the next videowe will see a for loop very powerful and veryfamous kind of loop for it does almost thesame stuff as while loop while the while loopruns based on a condition they fire the forloop it runs based on contracts a counterloop that many times it should run and soon. So we will see the details of for loopand the application The for loop in the nextvideo hope to see you in the next one. Okayin this video we are going to discuss forloop and other kind of loop in the previousvideo we saw while loop although most of thestuff almost all of the stuff can be achievablethrough while loop and sometimes it becomeshandy to apply for loop. In this particularexample, I'm going to populate a list. Sobefore actually moving towards for loop let'ssee very shortly what a list is, althoughwe are going to be or we are going to explorethis lesson in much more detail when we willdiscuss the data structures module but justfor the sake of example, a list is a collectionof different kinds of elements for example234, that's a list of three elements. So twothree and four the list can contains differenttype values, for example two 3.4 and stufflike so, we can access different elementsfor example, L of zero means the very firstelement the indexing This is called the index,the index starts from zero then index oneis so if we print for example, Brent Elifzero the result will the result that willbe printed will be two similarly we can appendmore values inside a list append let's say53 and list after this append operation, thelist will be having these values 234 53 wecan remove delete, update and do a lot ofstuff we will see lists in detail, but justfor this example, just think that list iscollection of a lot of elements and we canadd insert more elements we can delete elements,we can change elements and so on. Or we canjust initialize the list with just an emptylist and start inserting elements one by oneand expanding that list. Okay. Now, this isan empty list for example, and four is justa variable for i in this range isn't it greaterrange then means sequentially give a numberone 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 afterevery equation the range will give anothernumber as long as the numbers they are smallerthan 10. So, the last number that this rangewill return will be nine. So whatever thisis written inside is not included and it startsfrom zero. So as long as I is in this rangeis lower than 10 as long as that you thatthe body of the loop just like the body ofthe while loop. So first time I will be zeroand zero is smaller than 10 Okay, you printi i plus one and abandon the square of thatin a list. Then next time this range willautomatically return the next number intoI. Now next time I will contain one next timeI will contain two Next time I will continueIn three, four or 5678 and nine, once thevalue of AI becomes nine, that's the lastiteration of this body of the loop. And afterthat the loop finishes. So let's just writeon this very very first time I will be zerowhen the loop enters its body very first timeI will be zero and one will be printed becausewe are printing i plus one, at that time thelist and the empty list will be having onenumber which is zero square. So list willbe having just one number zero, because zerosquare, so, next time I will be one and wewill print two and the list will contain onesquare which is one, next time I will be threewe will I will be two we will print threeand 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 squarewhich 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 ofthis in, in Jupiter just to get more comfortablewith with list as well as the for loop. Solet's see, let's say we have an empty list,let's say an empty list. Just to considera list like this L is just a variable, youcan write another variable a name, that'sa variable name L. Okay. So for i in range,in is a keyword range is a function in isa keyword, i in range. For example, let'ssay then, what you do is you brand, your brandi plus one or whatever you want to do, that'sthe body of the loop, and Eldad a band, that'sa 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 wholelist. So let's print the list. And you cansee the result 1-234-567-8910. And that'sthe 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 justone, for example, b we want it to start fromzero, it reaches 10. And let's say we wanttwo jumps to be taken as two rather than oneand one. So the very first time so that'sthe start location. That's the end locationwhich is not included start location is includedand location is not included. And that's astep size. So very first time I will be oneyou move inside, then a jump of two will betaken the next time I will be so very firsttime the AI will be zero, then you move insidethen the jump of two, then you move insidethen a jump of two then you move inside aslong as you stay smaller than 10 you willmove inside the loop body of the loop. Solet's see what now printed let's print justI rather than i plus one there was an errorwas the error 00 the range function does nothave 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 withthis. 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 nexttime I becomes 10. But 10 is not included.So you're out of the loop. And that's thesquares that you got. It is not necessarythat you always start from zero, you can startfrom one and you can j take a jump for examplethe jump of three. And it's not necessarythat you just reach them you can reach forexample 20 it's up to you it's completelyyour choice. And in that case, you have thiskind of vibrations. So this range functionreally is helpful for creating over over aloop body or a structure. Okay, great. Sothat was introduction of for loop and we haveiterated here on on our list we just haveactually populated a list using for loops.Okay In the next video we will see more detailsof 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 loopin 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 elsepart of for loop as well in Python, not inother languages. I don't know any other languagethat has this L spark maybe there is somebut I don't know.So this else part in Python, particularlyin follow, this else part or else that wasblocked will only execute if four completesits iterations. For example, this is a seta set like a list is is a collection listis defined by square brackets set is definedby curly brackets, the set is just similarlike the set in mathematics, we will see theset lists tuples dictionaries and many ofthese 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 objector one data. 4.9 is one data, which is a floatingpoint data and Jerry is one data which isa string data. Okay, so this S has three elements,three different elements. So now for x inthis set, as long as x is in the set, thevery first time the x will be Apple, so itwill 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 printApple next time x will be 4.9 it will print4.9. Next time x will be cherry it will printcherry, and the loop ends because there isno item in sets to iterate over. Because theloop finishes it's complete iteration thereare expected three iterations and the loopfinishes those now the else part will executeand you will say okay, loop completed. Soiterations. Well, you will be wondering inwhat case the else will not else will notexecute. If you apply any brake statementinside the loop body, which means you forcefullyyou forcefully remove some of the iterationsthat were going to be executed but the loopdid not complete it did not complete citations,then the L spot will not run. So let's seean example in in in Jupiter to get a goodgrip on this else. Okay, let's define a setS. S is a variable name. You can have anyvariable name that say it Apple, or let'ssay 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, whenyou 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'srun 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, forexample, as long as x is an N, if I say okay,let's say I take a counter here, I equalsone, 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'ssayelse just for readability else was now thiselse is else of this four. And this else iselse of this if and this POS statement isjust a statement for doing nothing. Now whatyou do when is equal to one you Brent thisi plus equals I becomes two two is equal tothree false, so you pass you move on. Nexttime, 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 breakjust disrupt that one more iteration thatshould be there, because the loop could notcomplete its iteration due to this certaincondition, this else part of the loop willnot execute, and you will go directly outsidethis loop. So let's run this code and seethe result. So you can see this apple fourby nine outside the loop. I would recommendalthough this else is there for for loop,but I would recommend to avoid using ELS inthe beginning, I mean, you may be confusingthis else By the way, there is a there isa mistake here, this l should be ended witha colon here, okay. So I would recommend tonot use LS clause for a for loop in the beginninguntil you you really need it. Because youmay confuse this else with the with the Lof F condition. And you may think somethingelse and the program behave in a differentway. So either way, if you want to use LSLS for a for loop is there in Python. Okay,just one more example of for loop. And herewe use dictionary, I'm introducing some datastructures here just for fun, we will seethese data structures in detail later on.So dictionary, that's a key value period likeset, but one item is consists of two numbers,that's called a key. And that is called avalue. That's a key. And that's a value likea dictionary, we have key and values. So nowas long as x is an X, X represents two keyand d is our dictionary and D off x representsto whatever value that x points to, for example,Apple is a key that points to 44. Cherry isa key that points to gain. For example, ifwe're ID, apples, apple, the result will be44. Similarly, d of Jerry, the result willbe game. Okay, so let's I create over thisdictionary using this for loop. All am I showingyou that this for loop is very, very handyof creating over different data structuresand a lot of data and stuff. Whereas filewhile loop is more handy and checking theconditions and stuff. Although you can doall the stuff using while loop you can alwaysstuff using for loop but one is better overthe 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 valueis 10. Let's say my key is B and value isminus 19. And let's say my key is C and myvalue is let's say ABC, let's say that's mydictionary. So for x in the Brent the keyas well as the value of that key. So now youcan see the key is a the value of Stan Thekey is B the value is minus 90 in the keyof C the values ABC. So this far loop is reallyreally handy and iterated over a lot of datastructures and stuff although it has otherapplications as well but this is handy. Okaygreat. So that's about loops for loops. Andwhile loops These are two kinds of loops inimportant loop these are two important kindof loops and they are inPython, in the next video I will directlygo to Jupiter and Jupiter notebook and wewill be practicing for this for loops or whileloops. We will be practicing the loops wewill be doing actually examples of nestedloops we will be actually solving a problemlike we did in the if conditions we solvethe problem Previously, we wrote a code forit. Here we will also write a code and wewill be get a good grip on the loops. So hopeto see you in the next video we will solvea problem in Jupyter Notebook directly. Okay,hope to see you in the next video. Okay, welcomeback. 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 havecomments. 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 anotherlist making another list that contains allthe items in sorted order from minimum tomaximum, ie, your result will be another list.Like, in this particular case, we will behaving minus five, which is smallest, thenwe will be having one, then we'll be havingtwo, 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, thenwe'll be having seven, and then we'll be havingnine. So that's your, that should be youroutput in another list. So assuming this listis available to you, or any list is availableto 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 tosort. Let's say this is available. Okay. Okay.So, what should be the logic? What shouldbe 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 justfinding out a minimum from the list. Let'ssay we are given a list and we just want tofind out minimum number one a minimum fromthe list. So how can we move that. So let'ssay 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 asI is an L, if I AI is smaller than m, thenif AI is smaller than m, then m should containAI. 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 valueas well as the position of that value? Forexample, we not only want to just find outwhat 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 indexas 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 maintaina counter, let's say a counter is C equalsc equals zero, for example, right now, andC, just plus equals to one, that's a counterand then this ID x is just that C, whateverthat 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 blockthat helps us finding out the minimum value.How can we actually how can we actually dohow can we act? So the basic logic is youfind the minimum value and swap the that valuewith the very first value, okay, great. Andthen move the loop next time find out theminimum 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 thirdvalue and so on. So do that stuff and justrearrange the same list using this but, buthow can the so that's the logic find out theminimum value. So happened with the firstvalue and then start from two till end startfrom start from the remaining values, findthe minimum so appid with the first valueof the remaining list, then reduce the liststep by step and you will be having a sortedorder, but how to start with how to find outlike this how to how to do that. So, any ideaand we are going to so for example, in thisparticular case, if I want to swap the list,what I will do is I will say okay, swap withzero at the at the at the zero, so, I willcontain a temporary variable, temporary variablewill contain the value of zero, this zero,so what I will do is at least zero, rightthe minimum value and the minimum value. Soat zero you write the minimum value, but atthis particular index, from there, we foundthe minimum value, just place the just placethe the value at the very beginning. So inafter that, after that operation, the minimumwill be at the first position, or the zeroethindex, and that value will be some minimumvalue will be swapped with the very firstvalue. So let's run this code and see whata list looks like after that good. So yousee, for example, the minimum value is sweptby the first value, whatever the first valuewas, but we want to do that progressivelyfor for the rest of the list, we want to findout the minimum and follow up with the firstone 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 basesthat will indent all my code. So for j inrange, length of the list, whatever the lengthof list, let's say for G is that so what Ido is M is the gf value the index right nowis 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. Solet's say i in range, start from G and gotill length of L, one by one, take the stepof one. Okay, great. So what next? Now thevalue will be L of I, rather than simply Lof 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 thegf value, you slap the gf value with the minimum.And you do that. And that's it, you keep onmoving and offer after the outer loop finishes.If you branch your list, you will be havingthe list sorted or at least we hope so. Somaybe there is a bug in the code or maybethere is a problem in the code. But we hopethis will work. What we are doing progressivelyBy the way, this is a nested loop. This isa loop inside the loop and that's and thenwe have an if condition inside the nestedloop. Loop inside the loop. Great. Let's seehow it how it works. If there is no Oh thereis an error length of range. Oh, we haven'twrite 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 ismissing. 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 veryearlier, where we solve this problem usingselection sort, but they are we just wrotea pseudocode. And here we have a code muchsimpler than actually the Python code. Ifthe problem was just sorting there are builtin functions to do that, but I'm just tellingyou how these loops and if conditions andall that stuff can be used to communicatewith each other to match with each other toto actually perform a problem solving taskwhen given a problem. Although we will seelater on in Python, most of the problem solvingtasks, I mean many more of them, there area built in function for those that are availablefunctions for those you need not write allthat stuff, but to mastering to to masterany 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 ofstructures with you. So mastering these structuresis really essential for problem solving andprogramming 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 haveseen 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'mgoing 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 verypowerful 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 functionby a scenario. Let me give you a scenario.The scenario is let's say you are writinga 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 taskmaybe 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 printthis, or maybe you want to print more or dosome more stuff. And let's say you want todo this again. And again, whenever needed.Somewhere, whenever you complete a particulartask or something, you want to print all thesemessages, and then somewhere else, whenevera particular event occurs, you need to printall these messages again. Now one way to dothat is to write just these print statementswhenever needed in the program. One way isif you want to perform a task and the taskhas a lot of coding, maybe maybe maybe a verysmall amount of coding or maybe a very largeamount or magnitude of the coding. In thiscase, we have just three statements, but maybewe have a task that we want to perform againand again and it is really a very lengthytask in terms of the coding.So, one way to do that is to just write allthe coding in coding somewhere and definea function and that function means the functioncontain all the tasks that you need to perform,whenever you need to perform that particulartask. Just in your coding, just call thisone statement, just this one statement, andthe whole task that is written under thisunder this content maintaining this as a headingthat will execute automatically I mean, however,I mean, that task that is under this headingmay 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 codethis again and again we do not write to codewe do not write to we do not want to writethe same lines of codes again and again andagain. And again in our program. Just writethis particular lines of code once definea function, just like a task. Whenever youneed to perform that task, just call the headingor the name of the function. And the wholetask under that function will execute functionsin almost all programming languages. Theydo that even in mathematics. They do thatIn Python, the syntax of defining functionis you if you want to define a function, youhave to first start with D E F meaning definitionor defining, then you need to write the nameof that function the name of that functionname 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 writeit is good to suggest the names of the functionsthat are very descriptive to make the codereadable and manageable. So, here I have writtenthe function name is sprint success, you canwrite any name, then you start parenthesisthen you end parenthesis and then you writea 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 thisfunction is invoked or called, this body cancontain if conditions for loops inside, Imean, this can have a whole lot of codinginside it. And whenever you will call thisfunction, whenever you will type this command,wherever in your coding, the whole task underthis will be executed automatically againand again whenever you like. So, let's takea 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 youwant to know where this notebook is located,if I want to, for example, invoke that notebookagain, when you will run your Jupyter Notebookfrom the Anaconda prompt, you will be havingall the files that you are working on. Andone file is for example, this you just clickon that, and your file one or more files,whatever you want to open up that will openup in the Jupyter. notebook. Yes, so it isopening up, it's a lengthy file, so it maytake may take a second. Okay. Let me justtake a better zoom level, just to Okay, sowe 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 saythat's the, that's the body of the function,the body of the function here contains onlytwo statements, okay, then you run this, yourun this command, just like Shift Enter, yourun this. So thatit is it is reported in the symbol table,there is a symbol table inside the Pythonmaintaining Python is maintaining all thevariables all the function information inside.So once you run this cell, then the then thisprint success function will be registeredto Python. So that whenever you want to callthis function, again, it will be available.Now if you want to perform this task, let'ssay you want to perform, let's say you wantto perform this task whenever you want. Soyou just call this function, this is calledcalling of the function. whatever I'm doingnow, when success and that's it, you pressShift Enter, and the all the statements thatare under this will be executed. And you dosome other stuff, let's say three plus eightthat is that is 11 do some other stuff. Andafterwards, if you want to do the same processagain, then you call this function again andall the coding inside the function will beexecuted 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 functionwhenever you need. It supplies a lot of managingpower, a lot of debugging power if you havean error for example, inside the function,you just go to the code we just go to thecode of the function itself and fix the errorand come back You need not to you need notto go all over the code if you have not definedthe function and you have called these linesof codes everywhere inside your main code,then it will become very difficult to handleAnd function actually provides a lot of alot of simplicity of managing and readabilityand, and a modular approach in that sense.So that was our first. That was our firstfunction. We will be talking about more, we'llbe talking more about this functions in thenext 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 sometimescalled 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 containa lot of code, for example, you have a particularfunction, let's say, fun, let's say it containsdef, fun, and it does a lot of a lot of complicatedstuff inside. And it is sometimes requiredto know what this function actually is doing.So this document string is one way of describingwhat the function is doing. You might be thinkingthat if you're writing this document stringinside the where the where the coding of thefunction should be written, we should openup that the coding file and see what the functionis doing, or should we actually open up thisfunction implementation where the functioncode is written. And then we have to readwhat the function is doing. Actually, Pythongives you another power. If you have writtenthe 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 actuallyopening up with without actually seeing what'sinside the funk without actually opening upthe file that contains the implementationof this function. Let's see, let's see. Twoin Jupyter, notebook imore, completely whateverI'm saying right now. So for example, let'sdefine a function. def print success. to let'ssay the function name, this function is printsuccess to the function name is print successtwo, although it's not a very descriptivename, but the specimens are also not correct,but that's fine. Print success to here I justdefine a document Strank. The document stringmay contain maybe just in one line, or itmay be a multi line, it is like a multi linecomment, or maybe a single line comment ifyou want. But it starts with the three quotesand ends with three quotes. Let's say I writehere this function is doing nothing exceptrenting. message, printing a message, let'ssay full stop. And then I further define let'ssay I define more in saying that that messageisHello, let's say, let's say are any descriptionyou want for this function. Now, this is adocument string, and it will be availablewhenever 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 functionwe are we are not available with this function.We are not available with the code of thisfunction. And we want to know what this functionactually does. First of all, we can just writeif we write pri, and just press tab, the tabwill allow us to access all the functionsthat 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 printsuccess to let's say and we write a questionmark in front of it, and then just press ShiftEnter, it will pull the document string itwill pull the document strength whatever wehave written and we will get to know whatactually this this is doing. So this documentstring actually does a lot of job furtherif we I mean this is this is kind of wheneverwe need to know what a function is doing.The document string is one way to just goand check what is what is happening. Rightnow this function implementation is in frontof 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. Andwe need to know what those functions are doing.So document string is one very, very healthyway of describing our function. And I willrecommend to make your habit writing documentstrings, every time you write a function.I was telling you that if you write a doublequestion mark, then it will not only pullthe document string for you, it will pullthe 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 istrue for the functions that are that are,that are the functions that are third partyfunctions, or some other person have writtenthat function and so on. For example, youknow, 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 lengthfunction 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 implementationis not in c++, I haven't told you that a lotof a lot of implementation of Python itselfhas 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 wantto get their implementation, they get theircode, the code will not be available for mostof the functions. So that's so whenever youwrite a double question mark, and the answeris the same as a single question mark, that'san indication that this particular functionis 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 languagesinside, Okay, one more thing, I can writeHelp, help command and I can get this Brentsuccesssuccess too. And the help of print successto by just typing this help command. So, thishelp will tell us, you see the Help is tellingus the document strike I mean, this help onthis function, if and this and this is thefunction we have written, this is the functionwe have written, this function is doing nothingexcept whatever description we are givingthere. If, at some time, if we are supplyingthis function to somebody, or making a packageof a lot of functions, that we are writingthese documents, strings will help to getto know how to use these functions. By justknowing the function name, we can, this documentstring actually tells us how the what thefunction 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 knowwhat the function is doing. let's print, let'scall this function. And whatever written insidethe function will be called See, this is onlycalled this is just acting as a comment andit is basically a comment. Yeah. Okay, great.Stay with us. There is much more about functionthat 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 thefunction can the coding or the behavior ofthe function can be dynamic, based on basedon 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, themost interesting functions are the functionthat receives an argument. And an argumentis just considered an argument just as a variableand performs its task according to that tothat arguments. argument. Just take a singlesimple example. Let's say rather than havinga function print success, we have a functionprint message, and it it prints whatever messageit 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'ssay 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 willperform dynamically based on based on whatinput argument you are supplying there. Youare 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 shouldhave written document string. Although documentstring is not essential. If you do not writedocument 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 powerof input arguments by again, going to ourgood friend Jupyter Notebook. Okay, so let'ssee. Let's say we define a function defineBrent grant message, let's say, edit receivesan argument message. And this argument isjust a variable, it's just a variable. Andlet's say we say okay, print message or further,let's say you say, if is in stance messagespraying, 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, hereis 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 documentscreen for it. The function rents the messagesupplied by the user, or brains, that messageis 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 lotto do with strings. So so just for now, Imean, that's our function print message, let'ssay if the message is of string type, thisstring does not good, this is this shouldbe simply str this should not be that is instantsteak like this, your input argument is nota string here is what you have supplied. Hereis what you have. So here, we can, we cansay here is here is here is the typeof whatyou have supplied. And then we can just printthe Type, Type MSC. So the goal here is tojust create a function that prints a messageif 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 stringform. Let's say this print message functionreceives a string, let's say that's our logicor 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 byquestion mark if you want and it gives usthe document string If however, we want Theimplementation 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 thisfunction, 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'sprinted. 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 havesupplied, it's an integer type rate, you canyou can have, you can have, you can call thisfunction 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 instructthe function, how should it behave withoutactually writing the whole logic of the taskagain, and again, if written all the logic,once, actually, this is actually the logicstarts 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, youjust 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 supplymore than one arguments, maybe, maybe twoarguments, maybe three, maybe four, maybefive, and maybe we want to supply severalarguments. And we want to do some task basedon the values of those arguments, or thosevariables. So in the next video, I'm goingto show you multiple arguments. Okay. Hopeto see you in the next video. So in the previousvideo, we saw we can define a function, andwe can supply input argument to it. And inthis video, we are going to see that we canactually send more than one arguments to thefunction these arguments are just variables,these are just variables, whatever value wewill supply to these dynamically, becausePython is dynamic dynamically typed dynamicallythey 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. Soguess 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 withthat. So let's go to our friend Jupyter Notebookand see an example of a function with multipleinput 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 inPython that's a built in function. I'm goingto write my own function, let's say it containsa 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'slet's, let's create another variable, see,that is a power B. Okay, then we print thisC, and we are done. That's it. That's ourgoal. So we register that function by justjust calling the job by just pressing theshift enter in Jupyter Notebook. And now wecheck what this function does. Well, thisfunction can be horsepower, just like builtin power function. Okay, just to Just to remindyou again and again, the importance of documentstrength, I'm writing this again and again,let's run this function, my power, let's saythree ways to recover for illness. So theresult is 81. Oh my god. So whenever, by theway, if you don't have POW function with you,although you have, you can you can createyour 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 functionwith more than two arguments to find, let'ssay, display types. That's it, that's yourfunction display types. And all you know,is our check arguments, let's say, check ourx. That's it, that's your function, and A,B, C, D, let's say E, these are the inputarguments. And let's say, at some tasks, youwant to know whether all the five variablesthat you're working in somewhere, whetherall of them are numeric values or not. Ifthey're not numeric values, you're not movingon, and you're doing something because youwere extra, let's say you're, let's say you'retaking input from somewhere reading from afile 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 intofloat, then you're not processing, then you'renot moving on, and you're going to check theinput arguments again, and so on. These kindof functions are there because whenever youcall certain, whenever you want to do processingon data, sometimes it is required to checkthe 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 justto just to focus on if is instance, a thenB. andis instance see if all of them are? If allof them are? If all of them are integers orfloats, then do something then let's say Brent,a plus b, plus C, maybe, or a plus b plusc, raised to the power to just print theirsquare, let's say else are if they are ifthey 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 checkarcs, check. arcs, check arcs, let's say three,four, or five. So now you have all of themare great. Let's say you have jet arcs. Andyou call this check ARDS.On,let's say, three, four, but this five is astring, let's say, Gee. Now we'll be havingan error. The input arguments are not allof the expected types. One of them or moreof them or whatever. Yeah one more thing thethis function is expecting three argumentsif you call this function by less than threeor more than three arguments you'll be gettingan error for example three four although thisfunction is accepting three arguments, you'recalling it with just two you're getting anerror because you have not specified all thearguments that the function is requiring althoughthe the arguments that you have supplied theyare of the type that it is expecting, butyou 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 notsupplied three arguments. later on. In lateron, we will see how to write a function thataccepts a variable number of arguments, wewill see that but right now, in this particularway, if you write the function, if you definethe function in this particular way, you haveto define the arguments the number of whateverthe number of arguments it is expecting, youhave to supply exactly as many. Otherwiseyou are getting an error. Okay, so that'sabout the multiple arguments. Okay, what next?Well, next time, in the next video, we willsee that what is the what's the importanceof order of these input arguments? What willhappen 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, thirdvariable? Is there any ordering inside theinput arguments? Yeah, there is. So let'ssee in the next video, in the last video,we saw, how can we pass multiple How can wedefine a function with more than one inputarguments, it is important to know that theorder of the input argument is really, reallyimportant. So whatever argument at the calltime, for example, if you call this particularfunction, the name of the function is f, that'snot 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 secondvariable c one, the third variable is C three.Now you let's say call this function likelike this, let's say two, four and nine, whatwill happen is this too will be copied inC two, this four will be copied in this Cone and this nine will be copied in this Cthree. 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 writtenthere, the first value that is passed at thecall time will be passed to the first variablewhatever the name of the first variable is,the second value at the call time is copiedin the second symbol, whatever the name ofthe symbol is. So, this ordering is reallyreally important. One way to work one workaroundfor this is at the call time, you actuallydefine the variable names and their values.For example, you call you call F and you sayokay c one has this particular value, butthis way you need to know that there is thesymbol 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 namesalong with their values, then you are orderfree. Now you change whatever whatever iffor example, you call this way c two is b,c one is a now no matter in what order youhave 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 forthe functions that has many more arguments,it is it is good to it is good to call thefunction in this particular way. If thereis a chance that calling a function in a differentorder may may may become confusing and stufflike so. This actually gives you more gripon this ordering issue. if if if you're ifyou're happy with if you're very smart andWhen you say Ok, I will always supply in aparticular order, I will always read the documentstring first, and then I will call that function,that's okay. Otherwise, this is also a featurethat is available at the call time, you assignthe values of the functions that are thereat 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 willbe copied according to their names. So andthat's a good feature. That's a very goodfeature. 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 threevalues. 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 theC, 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 willbe 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 tothis particular order, we just say okay, thisis three, this is game, this is to be calledlike, 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 ais to fine. B is three. And C is let's sayagain, if you want these numbers, now, ifyou call a function like so, that will happen.Now, if you change the order, no matter whatorder 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 saytwo, and B is at the third position three,the output will stay the same. And that'sa, that's a beautiful, that's a beautifulthing. So that's one way of handling withthe order. If you if if you think at calltime it is important to define the variablenames, 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 toI mean the C one matches with C it must matchwith C one, C two must match with C two andso on. So you need to know these names. Okay,great. In the upcoming videos, more featuresof functions are are going to are going tobe discussed. So stay with us hope to seeyou in the next video. So we in the last video,we saw the ordering of input arguments ina function.And we saw a fix to it. I mean, if you ifyou if there is a chance that you may missa proper order, there is a way to fix thatwe saw that in the last video. Here, we haveanother another thing to discuss this x variablex input argument This is the variable thatis defined inside a function although thevalue it receives is copied from somewhereelse, but it is defined inside the functionthat is also the function variable or theor the variable that is in the scope of thefunction 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 youneed the value of this variable. to do somefurther process, let's say, what you do islet'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'ssay seven. And let's say you call the functionadd a, b, now the value of a will be copiedin 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 besaved. For example, let's say a variable isD, let's say, and then you want to do somemore processing on D, let's say d doublestarfive, mod three, and maybe you need to applyan if condition on that if that equals tozero, then do some stuff otherwise, so let'ssay you need this variable out, what willhappen is this C variable is not accessibleoutside this function. And the reason is theC is defined inside the function when thefunction body completes its execution, theC is lost sees no more available, C is definedwhen the function call has been made, whenthe when when you're executing the statementC is defined and a memory location was createdin a C sometimes called the function spacein the memory or process space that is createdin memory. But once all the body of the functionexecutes all the functions that were insidethe variable they are lost, what how can youHow can you receive this value? How can youreceive the value inside see outside thisfunction? So, that is, that is question inthis slide, how can we do that further,this particular function can access all thevariables that are not defined in this function,but that are available outside this functionand are defined already. For example, let'ssay I have a function, f. And the functionis let's say I have a function f. And so ifthis function is defined, like so f, let'ssay F is your function, and it has to findlike D, E, F, and that's it. And here it printslet's say, some variable, let's say a. Let'snow now you know this a variable is no longerin F not even defined in F, but as long asthis a variable is defined, before callingF for example, that's the cell where we arewriting the code and we say okay, a is equalto seven, and then we just call this F, becausea was available before calling f a will isaccessible here. So, the functions the variablesthat are available before the call, they areavailable inside the functions, but the variablesthat are defined inside the functions, theyare not available outside. That's the problemfurther, if we define this ad here is equalto two now, this a is sometimes called thelocal variable or the function where the variablethere is local to the function. Now, thisa is is is defined inside the function andall the accesses to a will access this valueto rather than the sound considered soundhas a separate location in memory, and thistoo has a separate location and memory, bothhave names a, but this a will only be referredto when the function is executing, after theafter the execution of the function completesthis has gone from the from the memory andthis will still be available, the seven willstill be available. So it is good to knowand by the way, if a was not defined here,and you still call F, then either you willbe getting an error, or this a might be aglobal variable or available in some packagethat you have already loaded or stuff likeso, in that case, this eight will be accessedif it's a global variable or accessible. So,it is good to know the the scope of the variablesinside the function because when you're callingthem what functions if this if x is alreadydefined, for example, if x is already definedlike 34 and then this x is 34, as long asthis x is not defined here, if x is definedhere, this is this x actually is the localcopy and that will be accessed inside thefunction. Once the function is gone againx will be 34. So, it is good to know the localcopies or or the function space itself. Thebut but the problem here is how to accessthem. This variable the value of this variableoutside the function, because this is completelydefined insidehow to access that? Well, well, there is afix, 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 savedthese 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'sdo three. Now, this value, this value C, whichin this particular case is five, that valuewill be returned in D, and all the propertiesof this variables are returned in D. So justlike the C is copied in D, and this is availablefurther, whatever you want to do with thisD. Okay, so yeah, so return statement is there.So, in the next video, we will actually codethis in Jupyter Notebook and see the returnstatement running and we will see the scopeof the variables and all that in Jupyter Notebook.So hope to see you in the next video. In thelast video, we saw a scope of a variable particularlyif a function if a variable is defined insidea 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 kindsof things, which is sometimes called schoolscope of a variable. And further, we discussedwhat if we want, what if we want a value ofthe function that is computed value valueof some variable or some result that is computedinside a function? What if we want that tobe accessed outside, outside the function?So we discussed that in detail in the lastvideo, so let's see all those concepts ina running form in Jupyter. notebook. So let'ssee how it works. So first of all, let's definevariables, let's define a function, let'ssay define, let's say, my ad. And let's sayit receives two arguments, let's say a andb. And then let's say C is a plus b, let'ssay that C are our c value, that's a c valueor 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 thefunction. 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 copiedin 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. Whatif we want to access because this is definedinside the function? What if we want to accessthis? I mean, what if we want to compute someresult and then use that result outside thefunction? So the way out, as discussed inthe last video is return statement. ReturnValue. And now if we call that again, letme let me go if we call that again. Now, whatwe haven't actually registered, by the way,remember this, that's, that's a common errorI 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 somebodyOh, we, oh, there's somebody is still notstill not accessible. Because some value isnot 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 thisoutput in a variable D. And then let's justprint D and D is five. Great. So one morething. Let's say we define a variable here,of variable outside the function, let's saythat'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, andit receives nothing, but it prints this, that'sa variable. out side the function. And that'sit. That's it, that's a function. Now, whenwe call this function, this variable outsidethe 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 somewhereelse, and it is global or accessible, it willstill be accessible. However, if we definea 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'sthe 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 thevalue will be three, because this variable,this particular variable that was inside thefunction, it got destroyed when the functionfinishes. And this is available again. Soyeah, so you need to know, by the way, it'sa good practice whenever you want to, wheneveryou want to access a particular variable inside,it is a good practice to pass that variableas 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 wantto access inside the function. Okay, so onemore thing, this, this function g is returningnothing. 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 sayit is not printing anything. So this, andthen we call this and that's it. So it hasno return value. By the way, in Python, evenif you even if any function, even if a functiondoes not return anything, it still returnsa value, which is called none, which you cansee here. So in Python, a function alwaysreturns a value. If you write a return statementexplicitly, it returns that if you do notwrite return statement, when the functionbody finishes, it automatically returns none.Let's see the type of this output. What isthe 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 particularvalue, if you for example, in a particularfunction, let me write a function here. Let'ssay d f, that's the function is H. And theninside that function, you do something, let'ssay print, a, let's say then you define avariable, let's say a equals to three, let'ssay, then B equals let's say five, and thenyou add those values A and B. And then youdo some other stuff, let's say plant something.And then you just write a return statementwithout any output or I mean it is not returninganything. You can still you can still I meancontinue writing the function body more andmore. But what happens is whenever the firstreturn will be encountered,the function returns from there. So the effectivebody of the function is just that the functionreturns right from there. If you return aparticular value for example C, you can receivethat value outside the function. If you donot return anything, just type a return statement.That means exit the function right away. Itworks like the break statement and loop. Rememberthe break statement it It resembles to breakExcitement bulletin means just exit the functionright away, no problem. And by the way, whenreturn is called the default return valuethat is returned is none type if the returnis called without, without an argument here,so for example, let's run this function. Let'ssee. And let's call that function Ah, yeah.So it prints a, then it brings something andthen it returns. And it returns, for example.It returns nothing but anon. It returns ornot. And if you didn't see, for example, saying,then it returnsa C, value of C, which is eight. And thistime 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 hastwo purposes, one, you can return a value,two, you can return, you can just return thecontrol, 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 sayour is our function. And we just have a equalsfive, b equals seven, and D equals let's saysomething. And then we just return them a,b, and A, D, and D. So return statement canreturn 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 returnedin X, it will be copied in x, b will be copiedin y, and D will be copied in z just as asequence as you as you keep the sequence inthe return statement, if you change the sequenceand 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 andjust print all these things X, Y, and Z. Soyeah, five salmon and something. So this returnstatement 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 havefeature to return more than one values. Andmore than one values of any type A can havedifferent types, you can have different types,you can have different type, and so on. Sothat's about the that's about the return statement,as well as the variable scope. And whetheryou can access a variable that is outsidethe function or inside the function, and soon, and all that kind of things. In the nextvideo, we will talk about what if we wantto access arbitrary number of input arguments.I mean, we do not know how many argumentswill be there inside. But no matter how manyarguments a particular user is giving, let'ssay we want to write an add function. JustJust to give you an example, let's say youwant to write an add function that says defineadd that say add to another function, addtwo. Let's say it receives an arbitrary numberof arguments. D in I don't know how many andit has some implementation, then anybody whowants to call this add to it, if that persongives two or two arguments, then just twoshould be added. If the person gives threearguments, 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 thedefinition, the total number of variableswhen we specify, we have to pass those manyarguments for sure. If a single argument ismissing, or a single argument is just morethan the specified number of variables, wewill be getting an error. But how can we handlethe situation where we have an arbitrary orvariable number of input arguments? How canwe handle that? So to answer this, or to get,how can we do that? See our next video? It'scoming. In the last video we were talkingabout how can we handle arbitrary number ofinput arguments. For example, let's let'ssay we want to write an add function. Thatshould be a To add any number of let's sayinteger or floating point numbers that arepassed in. Remember last time, we discussedin an earlier video, that when you are defininga function, the total number of variablesthat you are defining, you have to pause exactlythose many input arguments. Otherwise, you'regetting an error. But but this may be requiredsome time that we want to add a universalkind of add function that has that has capacityto 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, veryhelpful. Because sometimes we might be callingthat function by just two arguments. Sometimeswe might be adding might be calling that functionwith, let's say,three arguments, and sometimes more argumentsor less arguments and so on. How can we havethis kind of feature available, but the implementationis just one time implementation? Well, Pythonhave a very, very easy way of handling thisarbitrary or variable number of inputs. Andthe way you do that is when you receive whenyou are defining a function, you just writea star, and then just Brent let's say, onevariable name, let's say arcs. And then afterthat, this arts will act like a list. AndI mean, it will be having a lot of propertiesare this arts has a property, this this xlike list, so all the arguments that you willsend in will be received like, like you'rereceiving 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 rightnow just think it is a collect all the collection,it is received by indices, for example, theARDS, the very first element is indexed byzero, it is at the zero location. At the zerolocation, 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, nomatter how many arguments you pass a list,it will be of that size, and there is a functionlength le n that is handy to just check howmany arguments are there. Now if you passtwo arguments, the arcs will, the length ofthe arc will be two, if you have three, ifyou have passed three arguments, the lengthof the arts will be three and so on. No matterhow many arguments you pass this arcs, itwill receive all them in one by one and allthe elements in that arc will be indexed by012, starting from zero until the length ofthe arcs. So see, for example, here, theysaid the sum sum equals zero, let's, let'ssay we want to add all these for i in range.And inside range, we just give the lengthof arcs for this example 12345, the lengthof arg is five. So I will start from zerotill till four, because five is not included.So the very first time I will be zero, andour eggs in subscript zero is actually thevalue value of the first variable, which isthree, so three is added to zero, then nexttime, I will be one and add the position onefour 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 valueof i will be four, you know how this loopworks, we discussed the loop and loops indetail. And as you move on, you actually exploreall these numbers. And this variable sum actuallycontain the sum of all the variables. Nowyou can return the sum and that at this particularfunction 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'ssay we have define, let's say we have anyfunction, my ad, they might add, let's saythat 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 canwrite the name arcs or you can write any otherother variable limits. This is this is justthis is just a name of a variable. Okay, thenlet's say we have let's say we have s equalszero, which is some, then we just apply aloop. I guess you know, the loops we havelengthy 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 oneby one. And this is again the same as S isequal to s plus r x i. Either way you writethis way or that way, both ways are fine.Then when the loop finishes, s contains thePsalm, just return it, and you are done. Wow.Now, let's call this add function, my adduniversal. And let's call this function astwo, four and five for these, and let's justprint the result. Let's just print the result.Okay, the result is 11. Well, because twoplus four plus five is 11. Now let's callthis function for let's say, for for, let'ssay, five arguments. It works. It adds allthese five numbers. Wow, that is great. Imean, 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 andso on. Depending upon the number of arguments,we need not to write separate functions. Wehave just one function working in all scenarios.While so, yeah. That's doable. I've done infront of you. No problem. Yeah, Python allowsthis.Yeah. In the next video, we are going to seehow can we actually handle the same kind ofscenario. But we want to handle the sequenceof the input variables in a very controlledway. Remember, in some of the previous thisthis year, in this order of input arguments,remember that we receive three arguments andwe pass the three arguments in a very controlledway. And then whatever these are, we don'tcare whatever the order here if we don't care,what if we want to fix the issue? Or we wantto become more careful for input argumentorderings. But then we also want the arbitrarynumber of arguments. How can we do that? Yeah,wait for the next video. And I will show youhow can you do that? In the last video, Ipromised you that I will show you how canyou 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, andC three maybe. And then something. What ifwe want an arbitrary number of arguments tobe passed, but we want their control. Forexample, let's say this particular variablesymbol name that acts as a key, that's a variablename, and that's the value. So let me callthe 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, whatif we have a lot of key value pairs? Whatif we have a lot of them. And we also wantto check which value is of what key, let'ssay we want to specify those. But we wantto 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 toperform accordingly. No matter how many inputarguments it received. Yeah, and and maybeinside the function, we may have applied acheck that if the key value is C one, thendo this processing, if the key value is Ctwo, then do that kind of processing and soon, let's say, based on different variablesymbol names, we want to process the valuedifferently, how can we achieve that, andstill having the need that these number ofvariables can be can can be in a variable,variable length, they can be an arbitrarynumber of those. So Python gives you again,a very, very simple way. Rather than writinga simple single star, you write a double star,and then you receive in whatever variablename. And now in this double double star meansyou are receiving a key value pair list. It'sa list of key value pairs. We will see thatthat resembles two that resembles to a datastructure in Python called dictionary. Wewill see dictionary later on in detail butright now just just consider that this inputargument this input variable C, it containsa, it contains a list of key values pairs,and then you just you can just iterate overthe sea you can just apply a for loop to checkthe contents of this Remember, we have actuallydone that kind of thing in the, in the portionof loops. Yeah, here. Remember that was akey. And that was a value that was a key thatwas a value. And we did that thing, we couldexplore the we were able to explore the dictionary,just just using for loop. Yeah, it's the samething here. It's not exactly but you can thinkof that that's exactly the same thing. Soyou 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 firstkey, then C of x point to the value basedon the based on the key x, and then x pointto 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 variablenames and the values, but you can do verycomplicated processing, if you want to, let'sgo to our friend Jupyter Notebook to justget convinced that this indeed works. Let'ssee. So let's define a function first. Sod f, that's the function name is Brent, allvariable, variables, and values. So that mightbe a function name. While that's lengthy one,but descriptor one, maybe we can make it moredescriptive, paint all the variable, variablenames and values, while that's more descriptivea guess. So it receives, let's say, doublestar.Any variable, let's say the variable nameis 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 justcontinue, and value is value is our eggs ofx. So let's say you, you done this, you didthis. So the variable name is this, and thevalue is this, okay, and you want to do thisfor 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'ssay the variable first variable name, let'ssay is a, and its value is three. The secondvariable name is let's say B, its value iscapital B, let's say the third Will you thirdvariable 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 fourthvariable name is why its value is 6.7. Andfurther notice, you can you can pass variableand 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 andtheir values. Let's see what we got. So well,variable name is a and the value is threevariable name is B, and the value is B, variablename is C and the values CCC, variable nameis why and value is 6.7. You can give an arbitrarylampi list here if you want. And Python justallows you to do that. And it allows you todo that in a very, very simple way. That'samazing. That's amazing. I mean, that's, that'swhy a high level language or radio, a powerfullanguage should should have a feature. SoPython does have this feature. I'm reallyamazed. I'm really, really astonished by time.By the way, I'm not saying the other languagesdon't have this. several languages actuallysupport this kind of feature, but Python supportsit 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 orderingis 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'llpractice we will play with these functionsa lot. And we will be calling one functioninside the other function and so on, we willbe having one better program just just programand noodle Jupyter Notebook just to get comfortablewith this functions. But before that, let'shave one or two more things to discuss aboutthe functions. Yeah, let's see. So I hopeto see you in the next video. Okay, I reallywant to talk about these default values fora function as well, because that's importantand mostly needed. The default value is avalue of the input variable that you assignwell, while you are defining a function, andif 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 thisfunction without the input, then this valueacts as as if you have passed this. So thisis the default value if you do not supplythe value, this is the value that is goingto operate. And by the way, you can have multiplevariables with default values, some variableswith default value is defined some variables.With default variables, a default value isnot defined, and so on. So you can have thisone here must be taken here that the defaultvalue, when you actually define the function,and you compile this function, actually, youyou run the cell shift enter in Jupyter Notebook.At that very time, this variable is assignedthis value at that particular time, it isnot assigned at the call time. So sum equalsto zero is already there, when you actuallypress Shift Enter for a cell that containsthis code.Now later on, if you pass a value, that valuewill be overwritten on some, if you don'tpass the value zero will go on, it looks likevery easy, but one care that I want to mentionhere that I haven't mentioned earlier, inPython, there are certain variables that arethat are referenced rather than copied, Iwill discuss the referencing in the copyingdata in detail in data structures. But letme 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 willhappen 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 Lis pointing to this L is label for that ltwo is also labeled for that, which meansactually in memory, this is not the copy ofthe structure that is made, I mean this isnot like in variables. For example, if a isequal to three and b is equal to a, a willbe a will be a position in memory, and B willbe a separate position in memory. That iswhat a view of the memory in ordinary variablesare. But there are certain variables in memoryjust for memory efficient and cost efficiencyand time. People have people have designedthese data structures in a way that when youcopy them, when you just assign a variableto another variable, the memory view doesn'tchange the just it's it's another name forthe same for the same for the same memorylocation. So what happens is if you changeany value, and let's say l two, let's sayl two, at the very, the zeros and add thezero index, let's say you change that by minusnine, the because it is the same view in memorythat changes minus nine. And now if you printthe elements of L rather than l two, you willget the changed value, you will see the changevalue. And that happens. Now why that is importantin terms of these default values here forthe function. The reason is, if you are acceptinga list, let's say the default is a list, andyou're accepting a list and you are also definingsome default value for the list. If that'syour definition, let's say then this listthis default value is assigned at the ad thevery first at the very first time, and thisL is really a local variable inside insidethe inside the memory. Now when once thiscell is run, not the call time at the at thesowhat call the compile time, when the cellis run this L is assigned this and that justhappens once. Now if you call this list withsome 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 expectthis 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 compiletime and they stay fixed. So that care mustbe taken. I will show you that example thatparticular 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 thispoint. I just want to mention this becausethat's important difference with ordinaryvariables that I mean default values, just,I mean, just like like a value. And if youdon't supply a value, the default value justworks. But with the variable that are referencedby 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 notare compiled time. Actually, this is not acompiled language, I should not use the wordcompiled compiled again. And again, just thinkwhen we define this function, and we run thecell at that particular time, the defaultvalue is assigned. And the default value neverchanges. It stays fixed. Yeah. So and I willshow you that example. Why don't we move toJupyter 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 modenotebook and see the default values. For example,let's see.Let's say we have define a function, let'ssay GG, and the default value s is equal tofour, let's say that's a default value. Andwe want to print let's say s, if available.From the call time, if not available, thenfour will be printed. Now we print now rightnow we are going to print, now we are goingto 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 thelist is, let's say 123, that list, and thenl two is simply let's say l two is L, thenwhat we do is we change the contents of Ltwo, let's say we change the very first valuein L two, and we place that values minus nine,and then we print L. Now, you might be expectingthat l is a different thing, l two is a differentthing. Because l and l two, they both arepointing to the same memory. This, the contentthrough l two actually changes the memoryview and l also changes and that gives theresult minus nine in L. Well, the behaviorthat I want to show you is different in thedefault values. When we when we talk aboutfor example, let's say we define a function,f f and it accepts a list and the defaultvalue is empty list, or the default valueis let's say one, two, that's the defaultvalue, let's say if, if no list is passed,the default list is one two. Now, in thisparticular scenario, if we just print, sofor example, for i in the list, brand, I let'ssay we just print all the list. That's it.Now we will press Shift Enter, and at thistime this L is assigned this value, and that'sa default value that never, that is not goingto 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 ShiftEnter. 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 twoactually is copied in this L because we suppliedit. So l and l two you may tend to think thatl is now also pointing to L to an L has alsothe same contents as l two. So if next timebecause because of the behavior of these listsbecause they are by Reference. Next time youmake 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 twoand next time, if we call this function withoutinput arguments, then l might be pointingout to L two values. So, 12 three and fourmight be printed, but that is not going tohappen, 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 youdo that in in the default value structure,that, that, that might work in a differentway. And the reason is, you, you must knowthat these default values they're assignedat, 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. Andby the way, the default if it was a simpleconcept, I guess I have made it too complicatedby telling you layers and default values andcreation of these variables, at what timeand at the call time, I made this complicated,I guess, I shouldn't have told you the listvalues 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 wewill be practicing functions in detail onon Jupyter notebooks. So just be or one morevideo with me. Hope to see you in the nextvideo. Okay, this is probably the last videoon on the functions. Yeah, we will, we willbe having one more video. But but that willbe like coding and practicing all the conceptsthat we learn about the functions not? Notsomething 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 youabout a few questions. Let's say you have,let's say, let's say you have this particularfunction, and you, let's say my ad, my aduniversal, let's say we have written thatfunction, 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 masterpieceyou have generated, it can add an arbitrarynumber of values pass in it well, but thisparticular function is written inside thisparticular file, which is mastering Pythonzero to hero. Later on, let's say two or threemonths later, you are writing some code forsome, some project or you are doing somethingsomewhere and you are writing code, and thereyou just needed.You just needed a, you just needed a codefor adding a lot of a lot of values together.And then you just remember, oh, I have writtensome function somewhere. How can you use thatfunction? One way is to just go back to thatfile mastering Python zero to hero, and justcopy this function, this particular this codeand paste in the new file, run that, registerthat and then call that happy. What if youwant to use let's say, 100 different functions,let's say you have written a lot of functionsin a lot of different files. And now you wantto use all of them. And, and let's say thisis a repetitive kind of demand several timesyou notice that this usually happens thatthis particular kind of function, you requirealmost every almost in every project, let'ssay a set of maybe 50, or 60 functions thatare that are required always, one way to dothat, as I told you is to jump just copy pastethose functions in every file, run them anddo that. Another way is to just just I mean,make a module a file of containing just thosefunctions. And whenever any of those functionsis required, just import that module intoyour coding file, which has one line of codeand then access all the functions as if theywere 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 thatcontains functions that you want to use inseveral different coding projects or the functionsthat you don't want to write in your the functions.Having the implementation that you don't wantto write in your grant coding file, so youcan have several of those functions stayedsomewhere else in a different directory theyare residing there, whenever you want to useany of them, you just import the whole moduleand use the functions. So, so module is justa 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 verycareful 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 makeone coding file, or that that is the mostimportant for you, that is called a modulewhere wherever you want to use any of thosefunctions that are there in that module, youcan call it, you can use it. So that's aboutthe modules we are going to make. I'm goingto 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 cessmodule. 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 inthe next video, I'm going to tell you whatthat extra work, very little amount of workwhat that extra work you have to do. So here,for example, my funks.py, that's my Pythonfile, and it contains these two functions.And let's say I want to use one of these haveboth 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 aboutmodules 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 haveyou have to make this path available. Thereare a lot of built in modules that are alreadythere 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 yourmodules, you have to eithereither copy those, those modules into themodules that are built in or if you want tomaintain them separately somewhere else, thenyou have to add the path of these in the searchpath as well. And the way to actually insertthis path is sis dot path dot append. Andthen you actually write the the path of thedirectory where this module file one or morefiles are located. Once this is added to thepath, now you can write the import. And youcan import your file and your file as it isor you can import your file with some othername if you want, you can rename that on thefly if you want. Once this is imported, nowyou can use all the functions like the builtin 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 theirand so on. for, for, for for very large kindof projects. It is good to make modules. Actuallyit 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'smake a module, why not? So let's make a module.Let's say let's go to Jupyter Notebook. Let'screate another file. Let's create anotherfile, let's say new Python three and let'slet's name this file as my IE let's say let'slet's name this file as my universal, let'slet's use underscores my universal functions.Let's classify the name. Let's create anothernotebook. Right now it's just a notebook that'sdefined some functions. Let's say we wantto 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 towrite a function that that just accepts alot of arguments. And you want to check whetherany 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 needthis function in several places. Let's sayin in your core, you're expecting numericalinputs. And if the input is, and let's saythere are a lot of variables that you areworking on if and if any one of them is notnumeric, you might want to check all the allthe variables and their values. One way ofdoing that is just to create a list. And that'sit. 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 maybewe just are happy with just one. So let'ssay for so the output, let's say output islet's say, R or the return value that value.Let's say that is already true. And we willsay 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, thenthere 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 returnfalse return means return, whatever. Otherwise,if we finish this loop, if the loop finishessuccessfully, and there is no return statementthat is called already, then we return, maybetrue, we need to do not need Actually, thisvariable. Let's see. So this function willreturn true if all the variables are eitherint or float. If any of them is not of thistype, 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, definelet'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 isjust to add all the values and return thesum. So let's say s equals zero for x in forx in ogs, as plus equals to tax, and that'sit, then return us, let's say these are twofunctions. 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 somethingelse. Let's say my name let's say that's avariable, my name this, this does not thismy name variable does not belong to any ofthese functions. And my name is Python. Courselet's say that's my. So that's it. That'sfile with name my universal functions. Sowhat we do is we download this file as a.pifile.pi file. So what we do really is theGo to File, let me just zoom this out so thatyou can see the download options. We go toFile Menu, we download this, as we downloadthis aswe download this as well as by file, so Pythonfile. So let's download this, or we can writethis Python file as in some other editor ifwe want. So open folder, there is a Pythonfile here, copy it. Now copy that file. Andnow 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 wantto 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, Imean, let's let's call it as, let's call itas ABC, for example, ABC, whatever. And youjust made that and just copy that Python filehere, my universal functions.by. Now, if yougo back, if you go back to your there, thereis a Jupiter, here is a Jupiter. Now you goback to your code, this is your file, go backto your code, let's say this file is no longerhere. 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 themodule, you need to know that that was mymy word. So I just I just don't remember thename, let's import my universal functions.How it appears, actually, when I when I haveEric this part, then this import command andafter the dab completion, just fetches thatfile. 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. Nowyou can use the functions if you want, forexample, you can check the implementationof 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 somewhereelse. And you can call this function likelike the built in functions, my apps dot addall numerix. And you can have for example,let's say accepts the input arguments, let'ssay 234. All that says six. And that's it.That's the, that's the return value, you canyou can save the return value in some othervariable, let's see. And then later on, youcan print this see our do some stuff withthis. See, that's one thing. Another way ofimporting the same thing is let's say youdon't want to use all the functions, you justneed this add all the metrics, let's say that'sthat's the only function that you want touse 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 renamethis function as something and you can callthat function the same way. So you do thatnow. You need Not to write any dot kind ofthing, you just call add all Numerix becauseit is important now, and you say, Okay 234567and you'll save that in let's a D, and thenyou print the if you want, or do whateverwith that. That's it are you can import severalmultiple 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 severalmodules. And the several modules may be arrangedin in a directory structure, where the directoryand the sub directory and the sub directoryand so on. So the modules that are arrangedin directory structure, although they areaccessed, much like the same way, that directorystructure is sometimes called package. Andthese are basically the packages that arethat are most useful. And we will be seeingsome data science packages, like NumPy isa data science package. Then, we will be seeingpandas, that's a data science package, wewill be seeing matplotlib that's a data sciencepackage for plotting and visualizations andstuff. So packages, just the modules thatare arranged in directory structures. So nowyou know what module is. And the old one,Venus two, we actually missed to import thename of have to see the name Vivi have saveda name there as well. So let's go back. Andlet's go back and do that and see how, howmany things are available. Let's go to someother 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 modulefile does not require to only contain functions,it can contain any information, any data thatyou want to use in other files, other codingand stuff, and so on. So, yeah, that's aboutmodules. 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 functionsthat are calling each other and so on. Sowe will be practicing more on about thesefunctions, not theoretically, just in JupyterNotebook, just to get a better look and feelof of functions more. And after that practice,we will be then jumping towards data structurestarting 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 multiplefunctions 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 withif conditions, then we solved another problemwhen we were done with loops just to get agood grip on loops. Let's solve a problem.Let's just solve a problem using using thefunctions 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 sortinga 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 containsall the items in the sorted order, from minimumto maximum, your result will be another listlike this. And we solve that using loops.Okay, let's solve the same problem. Exactlythe same problems that solve the same problemusing a different way using a different userusing functions just to get a grip on functions.So let's say that's our problem we want tosolve. 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 justmake a function, let's say define, find minimumand the function accepts a list. And we'retimes the minimum value in the list not onlythe minimum value of the list, but also theposition of that minimum value. So find minimumas well as find out Some minimum as well asthe 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 findthe minimum. Okay? As long as the the minimumis defined for the items of the list, forexample, the list items, or let's say allthe metrics, okay, how can we how can we dothat? 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 didin 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 shouldwe write here? Let's see a counter. Let'ssee. Concrete let's or it may be that citycounter right now is zero for x in L. K, ifx is smaller than our minimum value, if that'strue, 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 moveon. 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 minimumvalue. So that's the function for for readability,we might be adding an else clause just writeballs. And that means the if condition finishes,I'm in do if this condition holds true, dothat stuff, otherwise do nothing. That's justbecause of readability. If you want, evenif you don't write the else clause and passstatement, even then everything is fine. Solet'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 valueas 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 willbe 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 awill contain the minimum value, and we willcontain the index of the minimum value. Sofine men, for example. And the list let'slet's give it the list. 13423409. Let's saynow the minimum value is zero. And that minimumvalue appears that 0123. That's the thirdindex. So b should be three a should be zero.So let's see, what's the value? What's theresult? So Brent? A, B? So A is zero? Yes.And the position of minimum is three, I guessit is working fine. rate. So that's one function,find a minimum? Let's find another let's writeanother function. Swap. So define. defineanother function, let's say swap values. Andwhat we do is it it actually accepts two indicesindex one that actually accepts list thentwo indices, index one and index two. Andwhat it does is it actually swaps the valueof index. So index, one value should go toindex two position and index two value shouldgo 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 variabletemp that contains l ID x index one, juststore it in a temporary variable, then atthis particular index, next one, just copythis value. Don't worry, we'll see lists indetail. Later on now list. Now at index one,the value of index two is copied. But it isnot 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 twovalues 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 altothat is swept values. And let's say we passthe list and we want the values to be sweptat 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? Sowe have find a minimum function, we have sweptvalues function. What else? So yeah, whatshould we do? Now let's write the main functionsorting. Let's write that function. And wewill 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 returnsa sorted list. Okay, what should we do? Whatdo you think? What should we do for the veryfirst time? Well, first of all, we shouldcheck whether all these list it contains thelist contains all the numeric values are notlet's say we're just doing this for numericvalues. 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 functionis 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 andwe just need that function we just need thatfunction one just from from my universal functionsimport what import check if Numerix checkif not numeric, as you can write that functionname something else, but justice. So you importthat function. Now you may be able to usethat function. So after that, you can usethat function. If check, if not, numeric listor remember that function returns true ifall the values are numeric, otherwise, itreturns 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 printingan 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 itis 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 willbe fine minimum. We'll be finding out theminimum and then we will be swapping the minimumfromwhat should we do what we we have alreadya function find a minimum that we can calljust right away we have a function swap valuesthat we can call right away. We already haveused this function. How can we combine allthese 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 likeit looks like a different thing. Maybe? Maybe.So, let's just write out, let's just for xin the list, let's start thinking here forevery element that is in list for x and listwhat should we do? We should we should findout the minimum and slap the minimum withx r. So, we should find out the minimum aswell as the index of the minimum and shouldslap 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, thecounter is zero, which is just the index,which we are going to do is we are going tofind out the minimum minimum and index wherethe minimum lies. So, by find minimum in thelist, so, it will return us the minimum aswell as the index where the minimum lies andthen what we do is, we will say, Okay, okay,what we want to do is, L is actually L isswap, swap values with index see swap valuesand list with index c. So, index c shouldbe swapped with ID x and C plus equals one,will that work with that work? So, after thiswill 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 updatedhere. And, oh, there was a problem. When weare finding out, when we are finding out theminimum, we are finding out the minimum fromthe list. And every time the same minimumwill be returned. That's a big problem. So,looks like this fine minimum function is notdoing our job, what we need to do really isthe, we should go to find min function andgive it that start your stock your final minimumfrom a particular index. So, don't don't searchthe whole list to find the minimum, startfinding out the minimum from the followingindex, for example. So let's give a startindex and maybe an end index. But let's givea starting next. So start searching the minimumfrom right from there. How can we change allthe code right now? Oh, that's bad thing.Let's change the code. Let's say that's thestart index. Start index. That's it. Thisthe index right now is start index and I isalso start up VB we may use a range functionhere, that might be much more feasible tous. So let's use a range function. Ratherthan this let's change the coding a wholelot. That's a bad thing we need to changethe code for i in rangestarting from start index, starting startingfrom start index, ending at length of thelist and doing a step of one Okay. Now x reallyis x is really list at the index i okay ifx is smaller than m then this is that an indexis 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, thereis a problem. Oh, we just missed this columnhere. Great. We fix it. Okay. Now, so if valueis there, maybe this works. Maybe Doesn'tmaybe there is a bug. Let's see, let's let'sjust call this function. So let's call thisfunction l two is sort list. And let's passthe 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 isa 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 instancethen return false. So if everything is intor float, so if x is int or float, then returnotherwise return true. So it returns trueif all our if all our numerix. So it returnstrue if all our Numerix so not true meansfalse. And why why does Why does returningfor us? So that is just was let us just seewhy it is returning false. That's that's thebad news that something is happening wrong.Let us just see how this is working. So thatis just check. Check, if not numeric. Andlet's pass the list this list. And let's seewhat is returned. Let's just print the returnthing. But it is either true or false. Soit returns a false why it is returning a false.It is a bad thing. Why does they're turninga 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. Maybean old bad, why not? Or maybe some other fancyeditor. Let's open this up and see what ishappening. ad format font, let's have a biggerfollow on and see what is happening.Self face one of 20 bugs are bad, they'rereally 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 andthe loop will be running if anywhere you whereit is finding out where it is finding outbasically. So this this is working reallyfine. Let's, let's let's write this functionsomewhere inside our notebook and see whatis let's say rather than this. Let's say thisfunction like check the metric to check numericto check it not numeric to let's call thatfunction and see what happens check numericto it is returning false again. Why does returningfalse? 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 eightmight be a problem. Let's see. Maybe. I don'tknow. Well, well, there is still false. Imean, I'm stuck here. Guys. I'm stuck here.I don't know what to do. I don't know whatto do. I have to debug this function, I haveto go inside that function and see what ishappening. 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 nota lot of arguments we have to pass all thesearguments in in a different way. I mean, ifyou 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 justgo 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 checkif not Americ for lists, rather than variablenumber of arguments. What should we do? Let'swrite another function that check for thelist. Let's write here check numeric to itcontains the list for exam just accepts listello or maybe l or whatever x or art justsimply, you can call the or l list. And itgoes through all the list. And does does thesame job as previous. So now this will work.So the function that was there in our moduleis no longer working, and it will not work.So we are not going to use the function thatis in the module, we are going to write anotherfunction that will help us here. And we havewritten that, and here we go. It just chainedthat function to that. And we just we justthrow 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. Ifthey are no longer working or no longer beneficialfor you, you can write new functions, youcan call them you can. Yeah, all that stuff.I guess that that lengthy video taught youa lot of lessons, how to how to code actually.And this actually happens when you are doingtasks that are really big. You have to definedifferent functions, you need to define differentfunctions for modular approach, and focuson each function as a separate entity. Andthat 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 implementationfix that everything else stays the same. Yeah,so too lengthy a swap here. Okay, now youhave done a lot of practice about functions,loops, and a lot of stuff. That was all thebasic programming in Python. In the in thenext video, from the next video, we will seethe real power, a much more real power ofPython where you need not write a lot of loopsand a lot of gold and still you will be ableto achieve a lot of stuff. And for that weneed to go through the data structures thatare available in Python. So from the verynext video, we will start seeing strengthsthat study or structure we will see less indetail we will see set in detail we will seedictionary in detail we will see tuples indetail. And after going through all thesedata structures and getting a good grip forthe data structures. Then finally we willmove we will move to the packages that areavailable for data science, particularly NumPy,pandas matplotlib. And we will see maybe Iinclude maybe I include one or two videosfor psychic learn as well. So hope to seeyou For the whole new phase in Python, thedata structures, so we'll hope to see in thenext video. Okay, let's dive into the longawaited strings. string is basically justa 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 typein, in almost every language is, the reasonis that almost all the data all the text thatappears in sequence of characters, so makingthat sequence of corrector, the whole textas one kind of data type, and writing specialkind of functions to, to deal with that textmight be necessary. And that's what the stringis. In Python, for example, you can declarea string variable s, or any variable name,by just double quotes, let's say ABC, areour equal monthly by a single quotes, eitherway is fine, d f. So either way is fine, youcan 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 willend with double quote, and that will be fine.So don't mix them together. If you're usingsingle quotes, use single quotes, if you'reusing double quotes, use double quotes, don'tmix them together, that might be much moreconfusing later on. So let's say this S isa string, Python is the best language fordata science. That's a D is another stringthat is defined by single quotes. In thiscourse, we are going to learn Python, thenyou can print s, different in a differentway, let's say you will call you can calla brand s, you can call a print to D. Or youcan just by the way, you can you can add twostring variables s and D. And the result isa new variable. That's how the plus symbolworks 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 theother string with it. And the result is anew string. Now that's a new variable, youcan 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 fordata science, sci fi. Okay, it's good fordata science, let's run these two, and seethe 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 takesan arbitrary number of arguments, we can printhello, then we can print anything in anothertype, then we can print another Hello, let'ssay hello to hello to that's a multi multivariable 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 haveused these kind of, I mean stuff a lot. Wehave used print function. And we were usingthese double quotes again and again. But butthese are actually strings that we will bethat we were using later there. So the springfunction actually accept strings and all thesekind of Normally, the whenever you use print,normally you're using it normally you're goingto 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 formin the screen form. And we want to processthe data we want to find the anomalies indata, we want to fix them again, we want tostay in the text. So it is good to have adata 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 firststring ends, the second string starts rightfrom there. What if we can get in a threestrings? s plus another string that just containsa space corrector? Then this string? Why dowe whatever that is there in double quotes,or single quotes, whatever, one correctorto track character, all these things are calledstrings. So now we are concatenated, threestrings 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 datascience and so on. Well, soyeah, so that's basically the introductionof string. What if we want for example, toconcatenate? What if we want, we have a variableA, which is 12. And let's say we have variableb, which is the price of this book, let'ssay the price of this book, and a is 12. Solet's say this is our price. Now price isin integer form S is in book form, let's saywe want to make another string we, that containsthe following kind of thing, the price ofthis book is and then whatever the privateprice 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, andan integer cannot be concatenated the stringin a straightforward way, like plus, how canwe how can we make a message like the theprice of this book is, whatever the valueof the price is, one way to do that is toconvert the variable price, the Convert thetype 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 nowit can be concatenated with with the restof the string, and we will contain the messagethat we want. For example, if we now see whatis free, that is, the price of this book isthis book is 12. Oh, we don't have a spacebefore. So let's let's type a space, theirspace is also a corrector can be handled instrength, while so that's how we can convertdifferent types to string. We can have a floattype, we can convert that to string, and soon. 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 argumentsof then price, that's exactly the same thing.The price of this book is 12, the price ofthis book, however, consider one thing, theprint function automatically adds the spacefor different kinds of arguments. You cansee that here, yeah, you need not to specifya specifier space, the space is automaticallyadded if it is if it is considered to be adifferent argument in the print function.Okay, great. So that's the introduction ofa 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 youin the next video. A string might be verylengthy, or may span I'm in very lengthy andmay span more than one lines. Or maybe theformatting is in a way that you want to evenif even if it is not very lengthy, you willstill want the different chunks of the samestring to be appear in different lines. Sothere is a way to declare multi line strengthagain using either three single quotes orthree double quotes. And then three doublequotes 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 linestring. If you now print, for example, ifyou call the print function on this multiline, 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 justcreated multi line anyways, if you if youcall that print function, this will the printwill display the string as it is like it isthere. So let's see the and by the way thatthe same multi line string kind of fashionedremember that that is used for comments aswell. If you have comments that span on multiplelines, you can use this. So this multi linestring really is if it is not saved in a variableand used as it is somewhere in the code, thenthat acts as a multi line comment. Great.So let's practice the multi line string inin Jupyter. notebook. Let's see. So let'ssay we have a variable A that is multi linestring. And let's say the spring is this isline one.Then we have this is line two, and then wehave this is last line. And this line is three.That's it. Okay, great. That's a multi linestring. Let's see. How can it Brent a, whathappens? So this is line one, this is linetwo, 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 youreally want really want the following kindof stuff, you have, let's say brand. So whatyou really do is you want to bring the followingthe following options are available. And theoptions are, let's say dab, dab, dab, let'ssee a hyphen, a. And that does play from athat 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'ssee. Okay, the following options are availablehyphenate has nothing hyphen B I mean, allthis 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 sometimesthis multi line string, it helps to formatour message in a way that we like. So that'show helpful in most of the cases further ifyou write this multi line, by the way, ifyou write this multi line, comment in thestart and end of any good script. That meansthe if you write this multi line way of definingthe strings at the start and end of any goodscript, 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 thecomment. 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 becausebecause the string really is, is basicallya collection of all these characters. Whatif we want to access a particular character?For example, this is the first graduate isd here, the second Gregory is at the thirdcorrect? Is it the fourth record is S, thefifth Gregory space and all? What if we wantto access particular characters inside thestring? Because the string contains a lotof directors? What if we want to play withsome 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 seein the next video, how can we index differentcharacters inside a string, I hope to seeyou in the next video. Okay, in this video,we are going to actually access differentcharacters inside the string, sometimes calledindexing, the term slicing is basically morerelevant to arrays, lists are actually theimmutable structures, but we will see,I'm just comparing, because you may listenthis term slicing again and again, but reallythis indexing but we will see the indexingor slicing sometimes is you these two termsare used interchangeably, we will see theexamples 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, Ihave 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 accessthe very first corrector the the indexingthe number, the positioning starts from theinteger zero, that's the first corrector.So if I want to print out of it, that willprint g if I access for example, if I writethe index three, what do we mean that meansthe 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 beprinted and you will be seeing nothing becausewhen a space is printed, actually, nothingcolorful 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 morewe can we can we can actually access, we canactually access a substring inside a stringas 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 includethe corrector at index three, which is hecorrectly at index four, which is space, letme 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 isincluded. This is not included. So we canaccess a substring. So starting from threeand ending at eight. Let's see, let's seean example. And you'll come back to this slideagain, after after a few minutes. So let'ssay we have a spring as let's say, how areyou? And who are you? That's it. So let'sdo that. So spring, okay. And what do we reallywant is we want to access for example, the,we want to access the element to access theelements, you have to write the square brackets.That's a standard notation. In Python. Wheneveryou have a collection and you want to accessdifferent elements, that collection mightbe a string that collection later on, we willsee might be a list. Maybe a tupple dictionarymay be a set. Maybe a NumPy array may be apanda's structure, I mean, anything that isa collection, normally it is accessed by Ithas different elements, and we want to indexthem. The indexing division is square brackets.And indexing always starts from zero ratherthan one. In Python. There are some languagesin which the indexing starts from one forexample, 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 somebenefits. So starting with zero is okay isokay. So let's say we want to access elementat index five. The element at index five isactually the sixth element in the string startingfrom zero. So first, second, third, fourth,fifth, sixth, so our will be printed. So let'ssee. Our is printed. Let's check the let'scheck the type of this return value. Let'scheck the type of this this one element whichis our what is the type of it subtype of differentelements in a string different charactersin a string? What are the typesSo what is the type of it. So the type isalso 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 andevery one character is also a string. Morethan one. correctness is also string, as longas they are accessed from a string. Okay,let's access for example, the element numberthree 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 fromthree to nine, let's say, and the the rallywill be our why or we may move to from forexample, we may start from the very beginning.So for example, index zero, we may end atthe 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'sa success, you. And similarly, we have minusthree, and that will access why, or we mayhave start from let's say, minus, start fromlet's say, minus eight, and go till minusthree, that means go back to go back to minuseight index, and then move to minus threeindex, okay? And minus three. In this case,let's see what was the result are, what isthat? 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 notincluded. minus three is not included. Soit has to stop here. Okay. That's minus fourminus 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 popularin, in in mutable data structures. What Whatis a mutable data structure? What is an immutabledata structure? Well, yeah, I should tellyou right now, you can change, you can notchange any corrector in the spring. That might,that might look like a bad news for you. Butonce 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 notpossible. And the reason is, the string isa data structure, the string is a variabletype a data type that is immutable, immutable,are unchangeable. Once created, you cannotchange 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 substringand copy into another variable, for example,but the contents of s cannot be changed.So all the kinds of data types in Python thatare 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 thedata structures that are mutable, that aremutable, although, you can use time slicingindexing both interchangeably. But it refersto roughly in reference to fetching the substructure or substring. In this case, in thelist, it will be a sub list or so on. So that'swhat slicing is. Yeah. Great. Why don't wedo some more fun with this spring?Yeah,let me show you more fun with this rank, moreindexing, 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 willfetch all the corrector starting from indexzero, all the way to index 12, but not including12. But it will take a jump of two ratherthan taking the jump of two. So first greaterthan 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. Sofor example, if you remember the string, that'sthe string. So it starts from h Fine, thenit skips Oh, and go to W, then it skips bassand go to a then it skips R and go to E thena skip space and go to u and then it skipsOh, and go to a shoe and then the cloud achievedand we stop there. Wow. So the general wayof slicing or indexing the general way isyou have a starting next start, then you havean index and then you have a step size. Ifyou do not mention the step size. the stepsize by default is one that we were doingalready. If you do not mention the end, thedefault end is the building and the totallist size. If you do not mention the startthe default start is zero. For example, letme make that a comment and just practice afew for example. Let's start from zero wedo not mention the start let's start fromzero and go to 12 if you do not mention thestarting index that starts from the very beginningzero go till 12 Okay great. If we do not mentionFor example, we start from three and we donot mention the end that means go till theend starting from index three including thelast corrector Okay, if we do not mentionthe 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 beautifulway 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 particularway. The Start and End index they are theyare just swept and you get the string reversedway. While so that's the reverse great. Isn'tthat fancy? Yes, it is. Okay, a lot aboutindexing, you can find out the length of anystring by using l m function, you can findout the length of any substring if you wantto if you have a substring using again a lampfunction, alien, that's okay. Okay, and nowyou've seen how to access sub strings andhow we cannot change the elements of a stringbecause it is immutable, but we can accessthem, we can access them, we can just displaythem, we can analyze them and so on. In thenext video, we will see some functions thatare supplied for string processing, what wecan do with strings, I mean how can we manipulatethose strings, although we cannot manipulatethe contents of a string, but we may copya string we may get explained, manipulateit and save it to another variable and howwhat kind of functions that are availablein 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 availableto play with the strings. In this dense stringdata structure, let's say you have the stringa a lot of spaces, these are a lot of spacesat the beginning and these are a lot of spacesat the end there are some spaces in the middleas well. So, there is one function calledstrip all the functions of the string theyare called by taking a dot A dot somethingThese are called methods you can loosely callthem functions, but those kind of functionsthat are related to some data structure andcalled with dot, they are sometimes calledmethods. The term method is more related toobject oriented programming actually stringis 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 programmingis, this a dot some function that operateson this a.One difference with method and function iswhen 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 toknow about the difference of matter and function,the rest of the story is perfectly okay. Evenif you don't know that that's fine. Okay,eight outstrip, it operates on a which meansthat a is passed in this function as justas input argument or it is available thereinside the function implementation. And thenthe script function, what it does is it removesall the spaces that are in the beginning,and removes all the spaces that are at theend, and returns another string that has thathas no spaces at the beginning and no spacesat the end, and the new string is copied orcreated in a variable b, let's say whateverthat we believe we can, we can have anothername of that variable. So let's see. Let'ssee the running form of this script functionin our friend Jupyter. notebook. So let'ssay 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 saya dot strip. Okay, and that's sprint B. Sob is actually everything without spaces withoutthe starting spaces. And without ending spaces,it does not hurt the spaces inside. So that'sthe script function, sometimes processingthe data. When we when we read the data froma file, it may have a lot of spaces at thebeginning at the end, maybe due to formattingissues or something like so and it is thisfunction is available. If we want to removethose spaces from beginning or from the end.Let's see more functions. Another functionis 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, aequals A, B, C, D, E, F, G, and some directors,some other directors and Q f, let's say that'sa string. And now what we do is b equals adot lower. What it does is it converts allthe string to lowercase. For the charactersthat are already in lowercase. It doesn'thurt it. For the characters that has nothingto do with lower uppercase, it doesn't hurtthat 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, wehave another function called upper for example,C is equal to a dot upper that the like thename 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 substringand replaces that substring with another substring.Okay, let's see. For example, let's say wehere we want to be have the same a, let'ssay the a is this thing. Let's say that'sa and what do we want to do is we want toreplace the semi colons let's say with withwith the semicolon, we want to replace thesemi colons with statics. So what we can dois we can say okay, d equals a dot replace,replace the semi colon with with let's saysteric. 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 wantto replace one is there one semi colon Onesemicolon with a string. For example, thestring is star star, and, and hashtag or someperson. That means one semicolon will be replacedby 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'sthe result what it is further if you want,for example, if you want, for example, let'ssay d equals a dot replace, if you want thisparticular substring, that contains the twosemi colons, if you want the two semi colonsto be replaced by another substring, let'ssay two semi colons, let's say. And that isalso possible I mean, you, you replace onesubstring with another one. Right? There isone more function called split. That whatit does what what the split does is, for example,you have a string, for example, let's saya equals a string, let's say, ABC, then youhave this colon, then you have d f, then youhave semi colon, then you have ads g y, there'sDan semi colon, then you have y y 3223. That'sit. 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 thatare 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 nextvalue started and so on. Let's say you wantto separate them, let's say you want to justsplit 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 canspecify 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 thefirst element of the list, this is the secondelement of the list, this is the third elementof the list, this is the fourth element ofthe list and so on. Because once you willsplit, you will be having different elementsthat are split it out. So if your brand forexample, l we will be having a list of differentstrengths, ABC and all that, Oh, don't worryabout the single code, the single core anddouble core is the same thing. Now we canaccess for example, the third element or ormaybe the second element by index one. Andthe second element here is D, E, F, and wecan work more on that. Okay. Is that it? Imean? Are these the only functions that areavailable? stripped function lower a birthplaceand split function? Or is that it? That'sall the spring is about? Maybe there are morefunctions? How many functions are there instring? How can we use them? What are thewhat are the total number of functions? Whereis the list? We visit documentation? Shouldshould we follow some book? Should we go tosome tutorial and find all the string functionsand see how to use them? Well, if you wantto do that, you can do that. But there isanother smart way. Let's say a is a stringthat you know, you write a dot and then apress tab, and all the things that that arethere in in string, they will they will appearin front of you on several things. You cango to this, you can go to that you can goto that and so on. So just you can check thedocumentation of a for example, if you ifyou 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 presstab. 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. Theseare the functions that are available thatstarts from C.Okay, let's focus on capitalized. Okay, whatis that thing how to use it? That's presscolon, question mark and see what this isand what it does. Okay, so here is the documentationhere is a doc string returns capital. I usedto 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 capitalizedand 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 Whatis a? Let's see what is a? A is the followingstring is the following string, so it doesnot 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 capitalizedjust capitalizes the first corrector. Letme let me read the doc string, again, returnsa capitalized version of the string, morespecifically make the first corrector haveuppercase and the rest lowercase. Okay, thatmeans if we have a string that has a mix ofvalues, the capitalized will do the following.It will convert the first character to uppercaseand 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 therest of the directors there as it is. Andthere are other functions as well, a dot Adot, 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? Solet's see what is a load count. It's a builtin function called matters is an instanceof 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 apprenticeof a substring. Great Oh my god. So basically,there are there are a whole lot of functionsof strings that are available, there are severaluse of the string, there are several waysof molding and playing with the strings, someof the functions that are available, someyou can make your own, you can make your ownmodules on top of that, to customize yourwritten to customize according to your requirements.A lot of these are available, and you shouldknow how to use them. And first thing if youwant to do something with strings, or withany data type in Python, first check whethersome method is available or not. And one wayto go that is just right away from here. Andother ways to go to internet and see I wantto do this in Python. with strings, whetherthere is a function available or not the goodchances are there will be a built in functionthat is available. And in that case, I willencourage to use that function rather thanto write your own one because using the builtin function, or the method that is tied upthere will be much more faster probably thanthe function you will be writing at your endeven if you're too smart in algorithms. Soyeah,so that's about the spring matters, thereare so many other methods that are available.In the next video, we will see some more somemore manipulation and processing and somemore working with strings. And then we willmove to other data structures. Okay, hopeto see you in the next video. In the lastvideo, we saw some methods of string. Andthese are just a few of them, a lot of themare available. We just we just discussed someof them. In this video we are going to talkmore about strings in a particular way. Forexample, what if you want to find out whethera particular substring is there in a stringor not. Let's say you have a string and youwant to know whether a particular substringis there inside a string or not? Well, youcan easily find out that using the end keyword.And similarly not in means the reverse ofthat, or the complement of that or not ofthat. And in keyword always will return eithertrue or Boolean or false. If it is insidethe screen, it will return true if it is notinside it will return false. So let's checkthis the implementation of that in, in, inJupyter Notebook. So let's see. So let's saywe have a string ABC ABC. And we want to checkwhether this string is there in this particularstring or not. So the return value is falsebecause 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 leastonce, then the result will be true. In thelast, in the last video, or maybe in the veryfirst video for strengths, I showed you thatyou can use plus with strings, can you comparetwo strings using less than or equal to? Imean, how to compare two strings, whetherthey are same or not, for example, ABC, that'sa that's a string ABC, I want to check whetherthat string is the same as ABC or not, whatwill be the result? So so so the questionis, is this double equal to is used can beused for comparing two strings? Well, theanswer 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 stringis less so than the other string, maybe this,maybe this operator is working based on thelength 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 thebased on the alphabetic order, and you know,the alphabetic order, a B comes first andB and C and all the alphabetic order thatis there in English dictionaries. That's howthe strings are working here. And the alphabeticorders for all the special characters willalso be defined in Python, for example, that'sa special graduate, for example, maybe thisstring is this string smaller than the followingstring. Yeah, we've done for false, becausethere is particular ordering. In, in Pythonthat is defined for these characters thatthis becomes first and there's like, a becomesfirst and B, B becomes first and C and soon. 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 alsoavailable to check whether a particular stringis inside a substring is inside or not toin another string. One more thing that I wantto talk about in that, for example, what ifyour 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 arelearning string here. Let's say you want toprint this, you want this string to appearin 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 writethe double quote here, scraping. And here.That's it. But there is a problem. The reasonis, the reason is when we call this, whenwe write this double code, actually, the stringends here, exactly the string ends here. Andwhen we write this single code, and this doublecode, another string starts here. And thisis no longer a string. I mean, what it hasno data type inside. Well, how can we theninsert these double quotes inside? Well, thereare several ways. One way is to use escapesequence and escape sequences just like itis you use a slash and then whatever you useis considered as a corrector. Inside the stringthat is you're using it now if you want anotherdouble quote, you use a user corrector whichis the backslash or maybe a forward slashand if you use that That means that meanswhatever that is coming in front of it shouldbe used as it is, rather than, rather thanconsidering that that's a special string definingsymbol. Now in this particular case, you'llbe having your double quotes available, andthe backslash will be just out, it's justifyingthat don't touch this double code, it hasnothing to do with defining a string. It isjust because I want to highlight this word.Another more. Another more easy way is touse 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, thatmeans go to new line, we are now on an otherline. So this backslash n actually puts everythingthat comes after to a new line. That's anescape corrector. Similarly, we have an escapecorrector, backslash D, that actually insertsa tab. Whenever we want Sophie, then a tabthen 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 morething that is important. For example, let'ssay you want to print. Let's say you wantto print some address on the right, let'ssee, Mac's slash back slash forward slashwhatever that is called name, backslash Dr.Let's say you want to do that. And your goalwas to just print that box, what will happenis this backslash n will be treated as a newlineescape sequence. And backslash n will tellOkay, go to the next line and create the restof the things. But because backslash D isnot any escape sequence, it is not listedinside, 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 alreadythere for a new line that is treated in adifferent way. If you want this to be usedas a deus and you don't want these, you don'twant this behavior, you just want that allthis should be greeted in a very literal orraw sense, then you should just apply andare there in our will tell, okay, that's,that's a raw string, everything inside justtreat that as a raw string, there is no escapesequence inside. Great. So and there is muchmore about strings, we can talk but that thatwas the most important that I that I toldyou, at least to me, we can explore this moreactually, you should now explore the smallerWhat are other functions of string, how canwe play with strings in another way and stuffandso on. If I talk about strings, I can justI mean, I can give a whole course on stringsas well. But here I just give you a snapshotof strings. If you need more about strings,I mean you should be searching on internetof seeing documentations and seeing basicallywhat you want according to your requirements,search the functions probably they will beavailable. Okay. In the next video, we aregoing towards list topples, sets and dictionariessome other data structures that we were talkingabout earlier, we will be going to explorethem in more detail from the next video. Hopeto see you in the next video data structureinformally or in a very naive sense is basicallya collection of a lot of basic data typesthat contains data one structure contain alot of data. And we can define sometimes severalmethods and several specialized kind of functionsare customized and define just because ofthat data structure to perform efficientlydifferent kinds of I mean for different kindsof tasks, we may have to define or we mayhave to choose different kinds of data structures.The basic data structures that are availablein Python is a list tupple set and dictionary.These are the basic data structures that areavailable. We can create our own data structuresif we want to. But most of the problems almostall of the problems mostly they are solvedby these four basic data structures. Althougha lot of these are not that efficient. Thereare efficient ways for customized kind ofproblems, 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 arethere to make it faster. Anyways, data setin a very loose term is collection, it isa collection of a lot of values a lot of datainside. And all these data structures listtupple 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 elementor item, another item or element can be ofstring type, another element can be off, let'ssay floating point number another elementis a whole list itself another element isa topple and so on. So different elementscan be of different types. And that makesthis heterogeneity that makes these four datastructures much more applicable and much moreabstract. And they can be applied to almostall the problems. So let's see one by oneand let's compare them together because thebest way to understand four of these is justto compare them which can do what as comparedto the rest. So let's let's compare them andlearn how can we use those in detail. So listfirst is list list is ordered ordered heremeans it is indexable which means there isa particular element number one is at positionone element, there is an ordering of elementsfirst element second third 25th element, thereis an ordering of element with respect totheir position. So that's what we mean byordered changeable or sometimes called moremore reasonable term or more usable term ismutable. 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 anotherelement and that's perfectly fine you canchange it that what we mean by changeableor more popularly called as mutable duplicatesmeans the list can contain more than one oneelement more than two, I mean, at the positionnumber three, you can have the same item andposition number five you can have the sameitem that so the duplicates are allowed tupplehowever, although ordered, there there isan ordering of elements there is there areindices 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 haveto create a new topple if you want to, butyou cannot change the items in the tuppleand the duplicates are allowed again set onthe other hand is unordered which means thereis 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 elementwith index you cannot change it, but whatyou can do it you can insert more elementsand you can remove existing elements if youwant to. Again, the set like in mathematicssets does not contain any duplicates. So oneitem appears just once we will see the examplesDictionary of very, very, very powerful datastructure. Again, it is it is dictionary isjust like a set, it's a set it is unordered.Again, chancer bow, you can change them butyou 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 eachitem consists of consists of a pair and oneone value in the beer is called key and anotheris 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 inpandas basically all the data is basicallymanaged, just like a dictionary if you ifyou have a good knowledge of dictionary, youwill be having a very good grip very quicklyon on a Big Data Science Library or Big DataScience package which is called pandas becauseeach and everything in pandas is handled justlike you're handling a dictionary. So it'sit's a really powerful data structure to knowabout.So, so solist is mutable dictionary is mutable setis 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 everyof them is a collection of different values.And the values can have different types. That'sthe that's the abstract power of all thesedata structures. So, in the next video, wewill, we will, we will actually try to geta good grip on list topple set in dictionaryand we will actually define them code andaccess different methods of those and we willbe we will be trying to become comfortablewith with these data structures by codingthem in Python. So hope to see you in thenext video. Okay, continue in previous videowe were talking about data structures in thelast video. So let's go to the Jupyter Notebookand see how a list can be defined or declaredhow a tuple can be defined or declared setand dictionary, let's see how can we makethese data structures in Python? So then oneby one, we will compare how can we accesselements of the list? How can we insert moreelements in lists tuples are in dictionaryand and see the comparisons of all these oneby one operation by operation. So let's see.So let's go to Jupyter Notebook, our friendthis file is getting lengthy, lengthy, let'slet's make multiple files. Let's say thisis 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 anotherfile. Python three. Yeah, so let's name thatfile as this part two, let's start a new filethat that file was on in that was okay tostay with that file as well. But just let'smake 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 justin 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 formatthe notebook, the purpose is just to showyou the power of Python. So I just omittedwriting these descriptions more and more,but just write a few descriptions in the starand 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 definethis 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 thelist. 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 topplethe variable name has I mean, if you havewritten t that has nothing to do that it'sa tupple. That's because the Python is dynamicallytyped. When you will write the parenthesesthat 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 thesethings they can contain each element can havea different type. But then, even if we includethis three again, because the set cannot containthe duplicates, later on, we will see onlyone copy of three will be there in the set,the other will, even if we want to includeit will not be included. Okay? Then let'ssay a dictionary. dictionary is again definedlike a set, but but each element is a pair,separated by a colon. Let's say the key valueis 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, anotherelement, another element may have a key withstring. So so the keys can be of differenttypes, 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 keyvalue pair with key as, let's say, c. andthe value is, let's say, cc. CCD. That's acharge coupled device. Okay, anyways, so.So again, now you know how to define lesshow to define a topper, how to define a set,and how to define a dictionary. The differenceis, is the main difference here is in dictionary,because one element consists of two valuesrather than one. Okay, let's print that andsee the types let's print all the types sprintdied off. So let's paint them. That type ofL is. So the table L is just printed. That'sL, let's print that. Let's see the other types,let's print the rest as well. So just copythem and B is the type of list L is that thetype of topple is D. And that's a D, thenwe 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 istopple the time of s is set. The dive of Dis dictionary. Oh, great. So that's how youcan define these lists. You can define listyou can find topple, you can define set, andyou can define dictionary, no problem. Next,let's see how to access different elementsfrom from these data structures. What arethe way for example, to access an elementfrom a list, let's say the element numberelement that indexed with one remember theelement that index with one is element numbertwo, because indexing starts from zero. Soyou can access that using the square brackets.If you want to access from topple again fromthe square brackets exactly like the list.In set, for example, you cannot index it becausethe set has no ordering. First, second thirdelement is no longer there. But you can youcan, 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 youwant to access value, for a particular key,you just create the dictionary variable nameand then write the key and it will returnthe value. Okay, so let's practice this inin Jupiter. Let's just practice this in Jupiter.So let's say list value at index one. So that'sbrand new, this list added next one, the valueshould be printed as three brand topple atindex 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 trueor false. And then print the and just accessthe value with the key 23. So let's see whathappens. 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? Thevalue is the value is two three. Let me justdescribe more about this D. What is the valueat 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 wehave defined as we have defined this duplicatethree But if you see the elements of s, thereare no duplicates. And it does not maintaineven any ordering, I mean, we have defineds 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 secondor third element and so on. Okay, so that'sabout the defining, declaring or accessingdifferent elements. In the next video, wewill see more about about the data structuresactually, actually want to spend some timeon the data structures because that will bea basic building block for for the data sciencepackages, too. If we if we know very wellabout these data structures, these data structures,we will be very fluent in the data sciencepackages and working with those. Okay, hopeto see you in the next video. Okay, in thelast video, we define less topple set anddictionary and we actually access differentvalues. 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 indexablelike strings. And I want to show you thatall kinds of indexing that you have seen instrings, exactly works and list as well asin tupple. So let's go to Jupiter, and seewhat a list is, for example, a list, if youprint the list, that's the list, it has thesekinds of values, if you just see the list,for example, starting from index one, endingat index three, that that means the same biga slice for example. So index one value isthree, index to value is 4.9. And the lastelement is not included. So, if you get thatyou get three and 4.9. So exactly the same,the same kind of indexing that you have seenin strings, exactly there is working hereas well. So for example, if I say list, startfrom 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 wesaw in in string indexing stays exactly thesame in list as well as in topple, so toppleFor example, let's access element from let'ssay from the very beginning till the tillthe third element, that's not the third elementtill index three, which is actually the fourthelement. So topple unless they are exactlythey will be exactly index as as it as itis. 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 thethrough the strings. One difference here thatI will explain later on, because list is mutableit is changeable, I will discuss one thingthat one use when you slice it, when you geta sub list then actually it refers to thesame memory and if you change the sub listcontents, the actual list chord changes. Thatis that is true for list in slicing. And thatis true for sets and dictionaries, in thecopying the references and so on. So I willdiscuss that later on. But rest of the thingsare roughly the same as as they're in stringindexing. Actually, indexing is almost thesame everywhere in Python, it has this kindof slicing is almost the same if you knowthe index, how to index planes, you know howto index lists, if you know how to index lists,you know how to index couples and stringsand, and everything. And by the way, if youknow how to index strength lists, you willbe very fluent and NumPy. That's the verypowerful data structure. That's very powerfulkind of array processing package. with withwith some defenses that we will see buteven the indexing is same in pandas when youare working with large amount of data datafile and stuff like so the indexing is moreor less the same that you've seen in instrumentswe will we will cover indexing, masking andfancy kind of indexing in much more detailin NumPy. But this stays the same as, as you'veseen in in, in strengths Okay, so now canwe can we expand the list can we add moreelements? 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 callan add operator, you can just add plus andyou just insert in other lists like like twostrings are concatenated by plus two listscan be concatenated, or combined togetheragain by plus, but there is a faster functioncalled append l dot append. That is sometimesfaster than using this operator we will seethat topple because it is immutable. You cannottouch any content of the double you cannotactually insert any element to a topple youcannot delete any element to a tupple. Thereare workarounds for example, convert a tuppleto a last change it then convert the listto a tupple. There are ways to do that. Buttupple in its true sense, in the literal sense,it is immutable. You cannot insert any elementsyou cannot delete any element you cannot changeany element. However, you can combine twotuples. Together, you can concatenate twotuples together again by plus operator andsave the result into a new double that's possibleset. The you can insert elements using anadd function add function allows you to justinsert one element. If you want to insertmore than one elements, then you can callan update function that actually accepts morethan 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 valueto a new key and key value pair is just insertedthere great, you can delete or remove anyelement from the list using D l Command Dl l one that means the this particular elementis deleted from the list that is possible.Deleting particular element from the tuppleis 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 youjust give the element that you want to removethat as possible, it will be removed and youcan delete the whole delete the whole variablethat is always available. Similarly, you candelete a particular item from the dictionaryby just deleting by just calling the D ofthe value for example, whatever the key is,so you call with the key and call the Deleteand it will delete everything I want to mentionhere for to remove items from the list thereare 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 thedictionary, 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, aswell. So let's let's let's let's end thisvideo here. And in the next video, I willshow you all these operations that concatenatingtogether, inserting more elements, deletingdifferent elements, I will show you all thesethings in in Python. So So hope to see youin the next video. Okay, in the last video,we saw how to insert different elements todifferent 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'sgo to our friend Jupyter Notebook and seeall these concepts in a running form. So let'sgo. Okay, so let's say for example, we havelist, that's our list. Let's append an elementto the list or maybe more elements, that isL plus. Let's say we can have another listfor example, howarethat's six, and then you that's and thesetwo lists will be appended and the new listwill be as you can see this similarly we canappend an item using append function for example6.8 that will also be appended and this willcontain these kind of values. So yeah, soboth arrays are fine. This plus is this pluscan be used to append to append to lists andthis append function can be used to simplyappend 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 combinationof 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 intothe assembly, the tuple is immutable, youcannot insert another element, you cannotdelete 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 callthe 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 insertan element that is already there. So for example,one, then the duplicates will no longer bethere, but the new elements will be inserted.Now let's see the state of D, the state ofD 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 mightbe, for example, a new value. Well, and nowif you see D, the D, the contents of the Dhas changed. Well, that's simple. Yeah, great.Can you concatenate two dictionaries togetherusing a plus operator? Is it possible? Isit possible to concatenate two dictionariestogether? Let's see I have another I haveanother dictionaries dictionary D two. Thatis that say the key is why. and the valueis why why? And then we have another key letterZ. 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 leftyou with this question. You try to answerthis. And in the next video will answer thisquestion. But try to answer this questionyourself. And one way to try that is justto go in Jupiter and just dive and check whetherplus is working or not. Or maybe there isanother method and stuff like so. Okay, great.Hope to see you. Oh, I have not used the Dl delete and all that stuff, and so on. Sothis question is there, let me use the removingthe elements. So let's say l is this list.If I want to remove an element, let's sayelement number three, if I want to removeelement at index three, which is this stringname, 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 functionremove. And whatever I want to remove, let'ssay want to remove game, and the game willno longer be there.Great. If I want to remove some element fromdictionary, again, let's say that's the that'sthe view of dictionary. I can call the AddI 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, thisparticular item is gone. Okay, great. I cando that. But But d L is not the only way ofdoing that. There are so many methods. I mean,a lot of methods to do that. But just to justto compare all these, I'm just giving youthe most similarities and differences whereveravailable. Okay, great. So I have asked youa question in this particular video. Can weconcatenate two dictionaries together, particularlywith a plus operator? If yes, then we aredone. If not, then Are there other ways andstuff like so that's the question. So hopeto see you in the next video with more onthese data structures.Okay, I asked you a question last time. Canwe 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 cannotinsert another dictionary to this dictionaryusing a plus operator. Because this plus operatoris not defined for dictionary, what we cando is we can call an update function, becausedictionary 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 insertthe whole new dictionary inside dictionaryas as as follows. Yeah, so the answer is usingplus operator No, but there is a way usingupdate method. Right. So next, we focus onthe copy function, the copy function is availablefor less the copy function is available forset, the copy function is available for dictionary.So let's see the need of this copy functionhere, I want you to be very careful. Becausethat's, that's really important. Let's saywe have a list, let's say, That's list. Andby the way, the same goes with set and dictionaryas well, whatever I'm going to do with list,let's see a list. Now, what you do is youcopy the list or you just make another variable,like you can assign the value of l to anothervariable l two, what you do is that now ltwo is also has this, now these are two differentvariables, L is this variable, l two is thisvariable. So you might be thinking l two isseparately a completely a new thing. And Alicenew thing, you might be thinking that bothare independent. But Python internally managesthe data structures, most of the data structuresin a way that because the data structure isa collection of a lot of data it has it isconsuming a lot of memory, what it does iswhen you assign a variable, or data structureto to another variable, it does not actuallycopy all the contents, it does not actuallymake a new memory, and store the contentsin this. It actually this variable also actuallypoints to the same memory as this. and and,and and the consequence of that if you changeany value, for example, in L two, let's sayyou change the index to value from this, theindex to values 4.9. Now you're working inL two, let's say you change this L to valuefrom 4.9. To Let's 4.9. Let's see you do that.So you might be thinking that this happensin L two, well, in L two, that has happened.But what it also does is it does the samething in L as well. So l also changes. Thereason is L and L two, they both are pointingto this structure in the memory. And whetheryou approach that structure through L, oryou approach that structure two l two, you'reapproaching the same memory anyway. And thatis called referencing I mean, it does notcreate the data, it actually create a referencein the memory to actually create a new namefor the same memory. And both are pointingto or accessing to the same memory. And ifyou really want the behavior so that l twobecomes different than L and what I what Ido with L two, that should not affect L, thenyou should call copy function. l two is Ldot copy. Yeah. So that's the function, I'llcopy. 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 differentcopy, same concept, go with the set. And sameconcept go with with the dictionary. If youif you just make another way will s two nequals two s, then if you change the contentsof 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 availablefor double. Because even if you assign thisT to T two, you can now not change D two becauseit is immutable. So having a copy functiondoesn't make sense in tupple. Wait.One more thing regarding slicing. Let's sayyou have let's say you have Dell that's availableto you like so that's L and let's say youmake l three another list by slicing Let'ssay a list from let's say one to five, let'ssay. So you start from index one, which isthree, and you go to five by not includingfive, 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 thecontents in L three, these contents, thesechange will not reflect an L. So if you dothe slicing, slicing picks a copy by default,it does not pick a reference. And that's ahuge difference between this list and a NumPyarray, when you end it, we'll see that whenwe 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 youdo 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 slicetorian anything the actual the actual contentsalso changed. And there is a reason to dothat there is a there are efficient reasonsto do that and stuff like so, again, the dotcopy 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 anycollection in any array, in any, if you doselect a collection for even for mutable objectslike list, you get a copy, but in NumPy array,the things the things these things, this particularthing 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 exploremuch more functions of lists tupple, sevendictionary and what you can do with each ofthem, and what you I mean, in which scenario,what kind of thing is more suitable for theother that completely depends upon the problemat hand. But what we can do in what what wewill do what we'll be doing in the less nextvideo, we will be seeing some using some functionsof just list. And then I will be just justletting you to explore the the tupple setand dictionary and all their functions onyour own. And to see what function or whatmethod is doing what for what, which kindof data structure. So in the next video, wewill be seeing some methods just for listdata structure. Hope to see you in the nextvideo. Like in screens. Let's Let's explorea lot of functions in list. Although in, inin sets and dictionaries and tuples tuples,as well. But many more functions are availablein list. And by the way, let's see how manythings are there in this list. And let's sayl dot tab, and tab will open up a lot of thingswith me for me abanda we know already clearcopy, copy, we know already count, we don'tknow count, extend, index insert, pop removereverse some of these functions. They makesense by the adjuster name. But let's seeone by one. Let's see some of those. Whatthey do. One way to do that is go to internetand 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 aboutan 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 toa list maybe. Have you thought about that.The append method just takes 111 object. Maybeit takes a whole lot of list. But then itmay be possible that a list is appended insideanother list and that whole list becomes becomesone element because list can contain otherlists as elements are that's a problem. Yeah.So let's see more functions. Yeah, so let'ssee clear what this clear What is this clearwhat it does? Sometimes I use help, sometimesit's used that remove all items from the list,oh my god, if you call the clear that thelist 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 doeswatch. So let's see. So Bob removes and returnsitem at index defaulted the last, which meansif you also that's the default value rememberthe default value. So, if you call a partfunction without an index, it will returnit will remove the index it will delete thelast item and it will give you that it willreturn that are if you give an index, it willremove that value at that index. And it willafter removing it will return you that. Soyou can use it wherever you want. So thereare many more functions for example, you cansee 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 ofreversing any way, this way. So now if yousee the list is again reversed. So I guessboth 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 updateis destroyed is a subset of the other. Yeah,add by default or update by default, actuallytake a union. So I'm not seeing update function.Here it is update. Oh, union is there updateis there, which means the list you're seeingis here is not a complete list you may bewriting, what are the functions that startfrom you. So here are the and and severalothers. Similarly, you can go to dictionaryand call for several functions clear copyfrom keys get items. That item might be mightbe interesting. What is this item? what itdoes? 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 items23 with this, be with that new key with that,and so on. Great. So actually, the purposehere is not to tell you each and every function,what it does, it will take a whole lot oftime. You can go and explore all these functions.The purpose here is to tell you what kindof data structure has, what kind of propertiesand what are the similarities and differencesin between. So if you remember this one slide,for list, double seven dictionary and sometext that is written out above, you'll behaving very good knowledge of where to pickwhat kind of data structure in practice. Soin the next video, I'll be actually goingto Jupyter Notebook as our as our style andI will be coding or solving some problem foryou that will involve list topple set or dictionaryare one of them or we will be choosing basedon problem what kind of data structure iswell and what so we'll be doing that. Butbefore that, I just want to I just want toI just want to mention that list tupple setor dictionary they can contain any items insideany kind of type, which means a list can containanother list. A list can contain a set a listcan contain a dictionary, a list of dictionarycan 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 instanceof I mean, a list can contain multiple lists.And those lists can contain more or less andso on. So before actually going to problemsolving, let me give you a flavor of thathow abstract these things are. Let me giveyou a flavor of that in in just just in acouple of examples. So in the next video I'llbe giving you a couple of examples based onthe 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 completelyon Jupyter notebooks. So get ready, I hopeto see you in the next video. Okay, let'ssee the abstractness of all these data structures.Let's see just one example. Let's say we havel 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 allthese 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 keyis 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 keyis 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 oneexample, 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'ssay, a, I will, I will get the whole list.And not only that, I can again access thewhole element. And then after that, for thatelement, I can access for example, the thirdelement, the element at index three. So thisparticular, this particular first level willextract the list. And that will in that isjust the indexing or for that list. See, forexample, ifI access D two, and inside the tool, if Iaccess the dictionary that is inside, andlet's say I save that dictionary in k, thenit I can see the contents of K but I can justfor example, this or I can just access allelements of this dictionary, or k by justhaving 4x in gay brand, for example, x andk of x, just do that i can i can just do thatwe have done that in loops as well. So I wantto tell you that the these even if for example,if you want to create a list l let's say lthree let's say you want to create a listthat can contain a whole list that can containwhat will get Oh, I mean one element is thelist another element is to pull another elementis the whole dictionary inside and then youhave some other elements let's Lee's gameand that's perfectly fine i get i mean youcan do that, these data structures are muchmore 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 thatwill be a dictionary object and you can extractthat element and play the way you want toplay and whatever. One more thing if you can,for example lists we can let's say we wantto make a list list very quickly for examplelist off all the squares till till startingfrom zero list of all the squares till till10 for example zero square one square to squarelet's say we want a list of that. So one wayof doing that is a quick shortcut is to justuse the loops so in loops, for example, weright okay, x square for x in range. Thenfor example, so it will start from zero gotill nine, including nine and you will getx one by one. And all this index is for makinga list of x squares where x starts from zeroand go to go to including nine go to nineone by one and that's how you can make a listand I'm in these kind of these are kind ofshortcuts. Again, you can make a sale Forexample, 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'ssay three. So, start from index two go till20 do not include 20, but take the step ofthree, and you can now have a set, which iswhich is this. I mean, there are, there area lot of ways of working these working withthese. One, one can explore more and moreabout 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 thatdictionary can contain a topple and that willhave an element which is another list andso 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 theseone of these data structures or we will tryto choose one of those. And that video nabylengthy may be small, because we may havebugs inside. And we will we will play aroundwith these data structures in the next video.So do attend the next video because it's reallythe practice and you will get your hands youwill get a very good grip on the data structuresin the solving the next problem that we arethat we are launching for you, okay, hopeto see you in the next video. Okay, let'ssee a problem just to get comfortable withthese data structures. So let's let's designsome problem and solve that problem here usingusing 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'ssay you're a teacher, you are a teacher. Andyou havedifferent student records to learn recordscontaining containing ID of a student andthe mark marks list in each subject, wheredifferent students have taken different numberof subjects. And all these records all theserecords are in hardcopy. You want odd copy,you want to enter all the data in computerand 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 youhave 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 takendifferent 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 wantto 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 thedata, how to collect the data. So let's writea function for that. So let's say define afunction, 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 datafrom the from the user, and the data is inthe form of you first say, okay, ID, studentID, let's say that is inter, or actually input,enter student ID. So he enters the the personenters the student ID. Yeah. So adopt, youmight have define a dictionary, maybe a dictionaryD, that is empty right now. But you may, youmay add and remove different values. So whatyou do is, you add a student ID, you get astudent ID, and in the string form, and thenyou 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 usingfor example, if you have five subjects, justwrite the five subject marks by separatingeach 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, youhave 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 andmore data from the user user will keep onincreasing the data. But one thing that wemust know is that if for example, a studentID, student ID is already in D, if that isalready 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 isthe following. What we want to do else iswe will make a dictionary, we already havea dictionary with a student ID as our key,that's our key. And at that key, what we dois be the pick the marks list, and just splitit using comma because you're expecting andall the marks they will be saved as a list.So that will return a list. List of stringvalues. These are not indeed values, theseare string values. But all these lists theyare tagged by this ID. So that is a dictionarythat will be that we'll be getting populatedon 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 thatis equal to let's say no, that is equal toNo, if this is the case, or if there is noenter 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 userinserted, if that's a no, then you returnthe and that's it. Otherwise, you keep onmoving. So that's the whole goal. So you keepon asking the, the, you keep on asking moreand more values. If whenever the teacher entersa no, then you just return. Otherwise, youkeep 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 withthat, then after that, we will see how toonce we have this data collected from theuser, then we will see how to compute marksfor each student individually average marksand so on. So let's just check whether thisfunction works or not. So let's say we haveour dictionary that says student student datais equal to get data from user, let's justcall 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 twoin just the first tool and just have thesethree subjects, then internode width, so Iwill enter something else. And oh, what'sthe problem? There is a problem. If more studentstaught 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 guessnow it will work. So let's do the processagain. So 12, let's say, and the marks arethe six comma 45, comma, let's say a bad subjectwith let's say, 13. into no to quit. No, Iwill intro something else, I will keep onmoving. The other student is the student IDis 45, let's say. And the marks that thisstudent has gained, actually, let's say thisstudent 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'ssay four. Okay, then internodal, quit. No,I want to insert one more, so do anythingelse 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, and45. 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 adifferent ID. That's the ID and the marksare let's say 45, comma, 45. That's it. Andinternodal grid. So let's say I enter No.And that's it. So now I have received thestudent data, if I show you the student data,that student data is student data. That'sa dictionary, that's a dictionary with thewith key 12. And that's a list. But this listcontains all the values that are our stringtype, we will see how to handle that. That'sa 45 as a key value, that's ID and that'sthe marks list. And that's the ID in thatsmall list. Okay, great. Now we have studentdata. Let's write another function that helpsus working on the student data, basically,we want to find out the average marks of eachstudent. And then we want to print those.So let's define another function and get averagemarks of each student. And that function actuallyreceives this dictionary, let me call it asD, any any variable, that's a local variable.Okay, so what we want to do with that is thefollowing. Average marks for each student's,so we will define another dictionary, let'ssee everage marks dictionary, let's say thatis empty in the beginning, maybe, and thenwhat we do for x in D, let's icreate overx and d, what we really do is we go to thewe find out the list of located at ELLs arelocated at x L is basically D sub x. So that'sit, that's our list. That's our list thatis located there. So then what we do for iin L. So for all i that is an L or let mecall it for marks, marks in L. In this particularlist, 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 plusequals two marks, but convert the marks tointeger because they are already in stringformat. 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 whatyou 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 butlet's stay gradual and add x, you just writethe average marks. And the average marks cancan be computed by s divided by length ofthe list, whatever the list is. So that'swhat 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 beginthen we can then just display by populatingthe average marks. So let's see, let's callthat function. So let's call that function.So ABG marks for example, equals to get aVG marks, and let's bond these student datainside. And if there is no error, then itwill return everything. Then just print theaverage marks for each student for x in aVgm. brand, let's say student and Brand XGod average marks as then you just Brandtokay ABG m of x, x, and that will displayeverything Oh, if there is an error, non typeobject is not equipped. I prefer nine typeobject why non time object? We have done somemistake. Yes. Maybe. Let's see. Let's see,for example, when we run this, so let's runthis and create a cell Let's run using altEnter to create a cell everage m What is thatthing? 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 thedefault value is none. raid actually not sogreat. Okay, great. You have this and nowwe have something in Emirates marks. Yes,this is and now we can just populate thatand we have this student 12 got average marks38 student 45 core average marks 90 49.2 andstudent 20 He got average marks as 45.0 Okay,great. So that was just a review of splitfunction 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'sabout the data structures. From the next video,we are actually diving into the data sciencepackages. And we will start from NumPy andwe will spend some time on NumPy and thenwe will be moving towards pandas, which isvery, very powerful built on top of NumPyand after that, we'll be moving towards matplotliband we will also try to give you some snapshotsof psychic learn as well. So hope to see youin the next video. Okay, the next few videoswill I will discuss NumPy which is the whichis the very very popular package for numericalPython. Actually NumPy is like list but itis much much faster than list.One one restriction if we restrict the listof 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 theymust have same type all elements in the listfor example, they have same type then thatlist with all the same type, there is whatthe NumPy looks like, but NumPy is very, verymore faster. And the reason is, even if youdefine a list with all the elements that arelet's say of same type Yeah, but because listin abstract way can handle heterogeneous kindof objects, the functions that we will applyon these items, they will no longer be fasterfurther to store each element we have to storethat information or metadata for that elementin NumPy, it is both I mean, it is efficientwith respect to memory, because if the typeis saying we need not to save informationabout each element, because we need just tosave the information about the type becausethe type is same for all elements furtherwhen the type is same, we can write functionsthat are much more faster than then then alist. So NumPy is very, very popular, it hasvery very fast universal functions availablethe methods that are available in NumPy. Andit's a package i mean it's it's a whole directorystructure containing a lot of packages insidea lot of modules and so much at the end ofthe day, it's it's it's simply or in laymenterms, it is like a list with all the sametype objects and it is much more useful whenall these objects are numeric type, althoughyou can have a NumPy array with with springdata types, I mean all the strings are allgeneral objects as well, but the the mostthe power mill the power of NumPy array willbe will become much more evident when we willbe working on numeric type data. So in thisparticular in this particular course we willfocus more on numeric data then other kindof data. So that's how you you write importNumPy is installed or if you if you have installedPython using Anaconda NumPy is already installedthere it is in the side packages kind of abuilt in package. So import NumPy we can stayas it is but we can rename this NumPy justNP that's most popular name, we can writeany other name but if you see the books orinternet or somewhere this NP somehow becomesmuch more popular. Okay. Now we can definean array for example NP dot array that arrayis just a method of NP kind of function. Andwe can define an array using list this isthe list of several numbers or we can definearray as as a topple as well. So whether wegive a topple whether we give a list an arrayis defined and then we can see the contentsof this array, this NP array so let let'sjust 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'sright, 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 forexample. So if we print for example, a itwill give us a but if we just see the typeof a it will no longer be list it will bean ND array numpy.md array that n dimensionalarray, 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 thetype is the same the it's a NumPy object ratherthan a list or a topple.So that's how you can create the the array1111 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 datathat is integer 32. At defined time, for example,we can we can specify the data type if wewant we can specify the type if we want. Forexample, in teacher that means as in teacherhere, we can here we can define, for example,the type as float, for example, so data typebecomes float. There are several other otheroptions that are available to define the datatype but, but even if we don't define thedata type can be defined automatically basedon contents. That's what the dynamic typingmeans. So if we now define type that is, ifwe, if we now check the type of a that is,again in digit 32, but if you check the typeof be the type that that might be a floatnumber, yes, that's float 32. Again, thereare 64 bit support as well, I mean, we candefine here there are several options hereavailable. So that's the that's how we candefine the NumPy array that's just gettingstarted 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. Andwe actually declared a NumPy array using alist as well as a topple. In this particularvideo, we will be seeing some of the propertiesof the NumPy array variable or sometimes calledthe 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 actuallythe that actually stores the information ofthe data type of the elements of the arrayof NP array, remember NP array, all elementsof NP array they must have same data typeit cannot store heterogeneous arrays as itis. Okay. Now, there is another property sometimescalled the dimensions are n them. That tellsactually, what are the dimensions of of thearray, I need to explain this term dimensionswith the following example. Let's say forexample, that's, that's that's an array justconsider that a list for example, 123, that'sone 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 needone 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 listthat 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'san array. For example, a One is this arrayand a two is this array. Now if we need toaccess any element in this particular array,we need two indices. First of all, we haveto 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 elementszero, let's say this, this whole array isa So first of all, we say okay, zero meanswe are going to access from from a one anda to one of those. So zero means the firstone, okay, now a one. Now inside a one whichelement, this is the zeroeth element, thisis 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 calleddimension of the array. And m them that actually,that actually defines that that actually describesthe this property, the total number of dimensions.Consider, for example, this is a 2d arrayor two dimensional array, let's head out totwo dimensional array A one, and let that'sanother two dimensional array a two, that'sanother two dimensional array, a three, forexample, 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 thereason is to access any element, we need threeindices. First index will define which oneof these we are selecting, for example, let'ssay you're selecting that. So one index isneeded that index is one for example, theninside this structure like so, we need twomore indices to locate a particular particularindex. For example, because it is a two dimensionalarray, it has two one dimensional array, sowhich one dimensional array you are, it hasmore, it has many one dimensional arrays,so which one dimensional array you want topick, let's say the sixth one will index withindex five, now you have located the fifthor sixth array. Now in that array, what elementlet's say the eighth element. So we need threeindices to access a particular element. Sothe dimensions of this array is three. Solet's play with that in Jupyter, notebookjust to get more comfortable with with theterm 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 dimensionalarray, let's say four, five, and six, that'sanother array. And that is an array of thesetwo 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 importedNumPy, we should have. So import, import NumPyas NP? Okay, we need not to import that everytime. Actually, I'm recording this video aftera few after a few hours. And I'm really Ihave restarted all these things. So I haveto import now for the first time. But onceimported 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 thereare 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 firstarray, there are two arrays with index zeroor one. So I am going to look into the firstarray, which is 123. And in that array, I'mgoing to look for the element number two elementwith index two. So that's how you can accessthe elements of multi dimensional arrays arearrays with more, more kind of dimensions.Let's say we have another array just to justto get more familiar with NP array, let'ssay, and we have a list. And that list actuallycontains that list actually contains threeone dimensional arrays. Not only that, actuallyOh, I'm confusing you a lot. Let me know Letme just, let's say we have 123. Let's saywe have three one dimensional arrays. Let'ssay we have another 2459. The the sizes ofarrays, 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 arrayhas 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 thatis in the secondary index with one, and thenin that array, it has index two. So I've accessedthis element, oh, we're not too many indicesfor an array. Why?Why is that? Why too many indices, for foran 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 havemade 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 definemulti dimensional arrays, the the number ofelements for each dimension, they should stayconsistent. For example, if the first arrayhas three elements, the second array musthave three elements, or if the secondary hasfour elements, and the first must have fourelements. If that is not the case, the arraywill not be defined like a multi dimensionalarray. 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 arraynumber two, and in that array, select index,select the value indexed by two, which isfive. So accessed no problem. And that staystrue if you if you're going to define forexample, a three dimensional array, let mejust give you an example of three dimensionalarray that's a C equals NP dot array. Andlet's say we have one, two and three. Andthen we have another array, for example. 456,remember or so let's say that, that we canhave one more for example, we can have onemore list, why not? So let's say we have a00 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 numberof elements and stuff. Let's say these elementsare our minus of the, the other ones, let'ssay there's minus, minus, minus and this isplus one. And now we have this, if you seethis thing, that's a 2d array. That's a twodimensional array, that is also a two dimensionalarray. 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 shouldhave defined this with commas. Rather thanrather than spaces. Actually. Yeah. The reasonI 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'reokay. With MATLAB. By the way, just as a sidenote, MATLAB allows you to have commas aswell as spaces, but this Python is just restrictseverything to comma. That's great. Okay, thatis C. So now, if you check c dot n them thatis three, if you for example, want to accessthis particular element, what should you do?First of all, you select the, the one of the2d arrays, there are two 2d arrays. So thisis the first 2d array and that's the second2d array. And if you For example, want toaccess this particular element, this particularelement, which is minus three, if you wantto access that, you first have to access oneof the two 2d, two dimensional arrays.So let's access the second one with the indexone. Now you are in this particular 2d arrayin that array with list which 1d array you'retalking about. So I'm talking about the veryfirst 1d array, so the very first 1d arrayis indexed by zero, and in that one D array,which element you are talking about. So I'mtalking about this element that has indextwo in this particular array. So now, if youpress enter, you will get minus three Wow.So that is basically how and by the way, youcan make a four dimensional array, a fourdimensional array will be an array of threedimensional 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 typeof 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 wehave discussed and then in the next video,we will talk about shape and we will discussmore 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. Andwe also saw an example of defining a threedimensional array in Jupyter. notebook. Letlet's discuss another property which is whichis the shape property. Let's see what whatthis shape actually represents. So let's goto Jupyter Notebook and see what actuallythis shape represents. For example, you haveseen this C as in the last video, we definethe C as a three dimensional array that containstwo arrays of 2d. And each 2d array containsthree 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 whatthat 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 twodimensional 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, tellsyou 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 youcan define a NumPy array, for example, a asNP dot array with just one element, let'ssay 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 a1d array. Yeah, it is. see another thing?For example, b is equal to NP dot array. Andyou define it with let's say three. And whatare the dimensions of B, it looks like thesame, the dimension of B should be one asas their the dimension of A is one, it lookslike the dimension of B is also one. No, it'szero. Because that's an array. If you passit as as a list. It's an array of one D ifyou just define just one number that can bedefined 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 lastone days, you get a duty. If you're gettinga lot of duties, you get a 3d and so on. Geta look and feel Yeah. So that's what it is.So yes, In this video, I discuss the shapethere 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 elementsin the array. So, how many elements are therethat is size. There is also I guess m bikesproperty, that tells the how many total numberof bytes that the destructor is taking insidethe memory. And there are several other Imean properties, if you just apply a tab andget certain things, you will see a lot offunctions. And you can you can check a lotof properties that some of these functionswe will explore later on. Sometimes they arecalled the universal functions, we will seethem because they are very, very fast. Andthese functions the vectorized implementationof these functions. That is the reason whyNumPy is so so fast, and why it is so popular.Anyways, so in the next video, we will goto explore the NumPy a bit more. And we'llshow you more fun stuff with the NumPy. Sohope 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 area lot of ways to create arrays from scratch,for example, what if you want to create anarray containing all zeros, so there is afunction in NumPy NP dot zeros that tellsyou how to do that. Similarly, if you wantto generate a lot of generate an array containinga lot of ones or all ones, there is a functionto do that and stuff like so, there are somefunctions that are actually used a lot andI want to discuss those. One function is NPdot arrange, actually, this is a single R,this is not a two Rs, this is single r NPdot arrangement, one R and NP dot arrangedfunction, what it does is it creates an arrayfor 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 valuesin that array starts from 012, all up to 99.So that's an array. That's a quick way tocreate an array with all the numbers till100. Yeah, so let's see, let's see runningexample of this NP arrange method in JupyterNotebook just to get a better look and feelof how it works. So let's see. So let's saywe have a equals NP dot arrange. And let'ssee 100. So that's it. If you want to seewhat is inside a, you can see this is an arraywith all the values starting from zero upto 99. Maybe you want to create an array thatstarts from a particular number ends at aparticular number. Maybe those two numbersare different. And maybe this arrange functionactually allows that. Let's say I want tostart 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 indexis not included. That's possible. Last butnot the least, if you want for example, tostart 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? Rememberthat? Yeah, let me pause for a minute, butnot for a minute, just for some seconds. Letme pause. Do you remember this arrange NPdot brains function? It looks like somethinglike 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 youthat? Okay, let me tell you an arbitratoras well here, just just just just spend afew 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 listof 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 youcall 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 createsa list of elements, it now creates a listfor you. That's awesome. Actually, it generatesnumbers, it generates the next number andthe next number as you move on. So it savesa lot of memory and these kind of objects,they are called I craters that I played, theythey never played. But if you want, for example,to get a list, if you really want to get alist, then what you can do is you can callthe range, let's say in the same way, andyou can just write a list. So provide me alist don't just provide me an ID. And thatwill give you a list. How cool is that? Right?Anyways, that was just a side note. It hasnothing to do with this arrange function anyways.So NP dot arrange, it actually returns anarray does not it is not like an iterator,it returns an array, complete array the wayyou want. So that's what this arrange is ithas resemblance with this built in range functionthat mostly used in in for loops. Okay. Next,let's discuss this NP dot random dot permutationNP dot random is a package. And P is a package,it has a lot of sub packages inside randomas a package. Random has a lot of modulesone module is permutation. There are a lotof other modules. So let's see this random.Let's see what it does. So for example, let'ssay a equals NP dot random dot, permutation,let's say permutation. And what I do is Isay okay, np dot arrange, let's see 10 whatit does is, this NP dot arrange will returnan array containing all the values zero tonine, these are 10 values, and then this permutationfunction that resides in the package and Pdot random that is in the random packet ofMP, 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 ina different random order. So let me know printthis a, it will be having all the elementsfrom 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 writesome function on arrays. And you may wantarrays that are that that do not have a particularordering, there are just random arrays, justto test your code just to test how it workson any kind of array. In that case, one wayof getting shuffled kind of array. One quickway is to just use NP dot random dot permutationfunction. The NP dot random package does notonly 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 createsactually, 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 between20 and 30, create some random integer, andit will return some random integer between20 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 integerbetween 20 and 30. So it creates a randominteger. One thing that you might be noticingwhat is the what is the return value? thereturn value? Is we for example, what shouldbe the type of E or do you think? Is thisV is an array? No, it is a number. It's aninteger, the type of VA should be an integerbecause it is returning a random integer itis returning an integer but it is selectingthat integer randomly from 20 to 300. So itshould be integer and it is Yes. Wow.Yeah,so we will be exploring some more functionsin the random package of NP and then we willbe moving towards this fascinating functionscore function called V shape. So there ismore to come for NumPy so hope to see youin the next video. Okay in the last videowe saw a range function that's a very usefulfunction to just create a test testing arrayand just see see the output of a particularoperation or algorithm, just on differentkinds of arrays. Further we saw permutationfunctions permutation function in NP dot randompackage. And we saw that this this permutationfunction, actually, it reshuffles, it shufflesdifferent kinds of odd if if array is appliedto this permutation function, it actuallyshuffles all the, all the elements of thatarray in a random way in a completely randomway. Today, we will explore this random packagea bit more, and then we will see a reshapefunction, but that reshape does basicallythis reshape, for example, if you have anarray, let's say, array, is let's say we havean array with, let's say, 10 elements, andif we call a dot reshape, and we give, let'ssay, two by five, so it will make a two dimensionalarray out of a, which is B, and that willbe a two by five matrix R, that will be anarray, or a matrix with two rows and fivecolumns. And now we can, we can just workwith this B, just like it's a two dimensionalarray, and we can just, we can just treatthis B as a two dimensional array and workwith that. It is it becomes handy sometimesif for example, we want to, we want to testcertain operations on on matrices. A quickway to make a matrix is just to call arrangefunction, and then whatever the result isjust reshape it into the desired order matrixand test the algorithm. So let's go to thelet's go to Jupyter Notebook and check thisrandom 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 forexample, we already have seen Rand int. Andother way for example, array, an array canbe generated, like MP dot random dot RANDfunction. So now, if we create this, if wecreate, let's if we pass let's say 1000, randomvalue array will be generated in a and a eachvalue of a will be a random number betweenbetween zero and one. So all these numbersare 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 distributionis uniform. If for example, you want to plotthe histogram, the histogram or the distributionof a it will look like uniform. Let me justgive you give you one or two plots, usingmatplotlib package, although we will see matplotlibpackage later on. But let's assume that thisis just a plotting package. This is just apackage that helps us plotting just importthat import mat plot lib.pi plot as PLT importthat. And after importing that, you just plota histogram PLT dot hist, for example, andpass a and you can see the histogram is roughlyuniform. I mean, everything is equally likelywe can make more bands, for example, we canhave bands, equals let's say 100. And we cansee almost all events they are I mean justlook 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 randomdot Rand n, and that generates normal randomnumbers, or Gaussian random numbers, let'ssay 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 shapedcurve 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 hasdifferent, it can create different kinds ofrandom numbers from following from differentdistributions and doing in machine learningor in statistics, sometimes we need to generatethese kinds of random numbers for sometimesfor testing purposes, sometimes for addingnoise of a particular type to test our modeland stuff like so. So it's good to have agood 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 justpass two arguments, for example, two by three,and the C will be a two by three matrix. Ifyou see the C, it will be a two by three matrixof four random values. If you see c dot, andthen 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, maybetwo by three by four by two. And that's afour dimensional array with this particularorder. So if you see this C dot m, then thatwill be level b, this. Yeah, so let me letme just give you an interpretation of whatthat thing is. There are two arrays that arethree dimensional. And there are two of those.Okay? Now, each three dimensional array hasthree two dimensional arrays. Wow.So eachtwo dimensional array has four one dimensionalarrays, and each one dimensional array hastwo elements in it. So that's what the structureis. Yeah, get a good look and feel. So let'ssee the reshape function. For example, let'ssay we have d equals NP dot range. Let's saywe have 100 values. And then we say reshapethese 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 dimensionalarray 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. Andthen we can reshape those and build a matrixquickly, and then just test the performanceof our algorithm or stuff like so. So, notonly the reship not only returns the, theI mean, you can you can reshape a matrix,and you can reshape an array into more thantwo 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 threedimensional array containing different values.Yeah, so now you can access it and do whateveryou want to do. So not only the reshape, arrangeand permit random, there are other functionsas well NP dot zeros. For example, if youpress z, and you just see the zeros, and thenyou just press the question mark, you willknow what that function is how can we useit and so on. Similarly, you can have severalother function there is an important functiononce 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 totest your core algorithms based on those.So yeah, so there are a lot of functions thatwe want to that we can work on. So next, sothere are a lot of functions that can quicklycreate a NP array and an n dimensional array.That we can quickly create an array test oralgorithm or use the array wherever we wantto like we're everyone to use. And we canmove on just a few functions like arrangedones zeros, they are there are random dotRand random dot Rand n, and other functionsthey are available. For In the next videowe will be seeing we will be seeing the indexingor slicing inside NumPy array and we willalso be seeing the difference of that indexingwith or slicing from the array In the listor or are the ordinary data structures? Whatis the difference in? What is the differenceof slicing in NumPy? with for example, withthe list, we will see that in the in the nextvideo, 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 thesame as the way you access sub strings orsub lists. And you already have seen, howcan we how can we use the slicing or indexingin lists and in strings, the difference herein NumPy is in list for example, if you sliceyou get, for example, let's say B equals aone colon five, if you slice that thing, fromNumPy, then B is not a copy, it is actuallyaccessing the same memory view as an A. Now,if you change any element in B, the correspondingelement in a will change as long as as a NumPyarray. However, if A is a list or any otherdata structure, ordinary data structure, thenthe slicing this, this kind of slice givesa copy rather than a view. So that's an importantdifference, we need to know that rest of theindexing technique is almost the same. Youdo this kind of indexing that is how you canreverse this a start and step all all thethings are same, except How can play How canwe play with the two dimensional arrays. Let'slet let's see that. Let's see some examplesof indexing one by one in in Jupyter Notebookand see how the slicing actually creates aview rather than a copy. So let's go to ourJupyter Notebook and see how can we play withdifferent indices, let's say a is NP dot arrange,and B dot arranged, let's say 100. And let'sshuffle them. Let's say as it is, let's saythat's a now a, let's say, let's bring somecertain things. Let's A B equals a big allthe elements starting from index three, endingat index nine, Sudan is not included. That'sB, that's blank v. Let's see what's B. Sob is this array. Okay? Now what I'm goingto do is I'm just changing the contents ofb, this NumPy array is mutable, you can changethe elements inside, no problem. So I'm goingto change the elements, let's say one elementin B, let's say, I'm going to change elementnumbers zero, and B, which is three, and I'mjust placing that element as minus 100 minus1200. That's it. That's the case. Okay, nowthe contents of B has been changed. We arebut now let's see the contents of a the contentsof a also has changed. That's a big differencebetween slicing an ordinary Lester adini datastructure or slicing a list, when you slicea list, you get us you get another label,but that label or that variable is accessingthe same memory, the memory actually is notcopied. There is one memory view. And thesetwo different names, whether you access thoseelements using B, or you access those elementsusing a the same memory is being accessedif you change the memory using B or A youwill see the effect in both of the variables.So that's one difference. Now, after havingknowledge of this difference, if we reallywant this behavior to not happen, one thingthat we can call is we can say okay, a, forexample, a, let's say three to 10. And thenwe can call our famous function, rememberthat copy, you can copy that and now B iscompletely 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 thingif you are not going to change elements thenumber is applies you very fast implementationof slicing by not changing the memory viewif if you are aware, your algorithm is notgoing to change the elements slicing willgive you much much efficient access to theelements or the or the sub blocks or sub arrayswithout actually making the copies insidethe memory which can take time and space both.So this is one plus of NumPy Over the overthe 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 thatthing? colon, colon to what? Or colon colon,let's say five, what it will do, it will startfrom the very first index, which is zero,it will go to the last index, but it willpick 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 mejust teach you by example, what this willdo. Yeah, what it will do remember, if youapply a minus here, the end and the startand end they just get swept, and this becomesa step from from the end. So, what will happenis the same kind of impact, you start fromthe very end, then you take the step of minusone from the end, and you just based everyelement, so this is kind reversing the arraywith with kind of step starting at the endrate. So, another way of reversing the arrayis if you want to reverse the array as a wholedisplay minus one, which means start fromthe end and pick every element from the endtill the beginning and the end, and the arraywill be reversed. This element is there, rememberthat 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 toa dot index I guess there is a function indexYes, he has a no index Oh, there is no indexthere. Is there an MP dot index and P dotindex? I want to find out the index whereso in DAX there is no index function indicesor something, I want an index function isthere any index function I want to find outthe index? Where minus 200 is located? Thereare several ways but I want to find one. Sofor example, for example, let me see whetherthere 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 thatdoes the same job. Let me see MPR indicesreturns an array representing the indicesof a grid, okay. So I have to give a gridand then it returns for example, the indicesof all that grid, how can I use that? Well,it becomes it becomes difficult, there maybe 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 playwith the NumPy? Why not? So let's say a equalequals minus 1200. That gives me a Booleanarray 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 falsearray or zero or one array, wherever thereis minus 1200, that index is one that valueis one otherwise it is zero, completely zero.And then what I do is, I just multiply thatwith with NP dot arrange NP dot arrange withwith saying that a dot A dot A dot size, sowhatever the size of A is, so because theseare the indices Okay, then what that's pointwise multiplication grade. So, when I willmultiply them together, what I will get isis 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 Wheream 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 losthere. Literally, I'm lost here, I need toknow how to find out the index where thisparticular element minus 1200 lies. Sothat's aquestion for you as well. I'm also lost. Solet's see you in the next video. And we firstwill solve this problem to finding out theindex of a particular element, or maybe alot of elements. And then we will continuefrom there onwards to see more indexing. Okay,great. So hope to see you in the next videoby first solving the problem, how to findout the index of a particular element in aNumPy array, or maybe more than one elementsin a NumPy array. And then we will be practicingmore about these slicing examples. Okay, hopeto see you in the next video. Okay, let'ssay this element is there. And let's say wewant to, we want to locate that element inthe array, we want to just know where thiselement is in the array. So array has thiselement. Let's let me paint array as it is,this array has this particular element, andwe want to know where what is the index ofthis element inside the array, there are severalways of doing this. One way is to find outtheir index is simply you call the functionarc where arc where for example, org, whereA is equal to minus 1200. And that will returna 2d array. And if you just want any one index,then you return that kind of thing. So ifyou write this thing, you will get the indexexactly of the element that is there. So theindex is three, if you want to change thatvalue, for example, the value should be threehere, if you want to change that value, whatyou can do is you can right, okay, ie x isequal 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 wehave 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 generatesare the values between zero and one, whatthis multiplied by 10, what it does is, itactually scales up all the values to 10. Andthen round function, actually, round downsare actually rounds the values to the integers.Now a will be worse the problem round thatthird round method is no longer there. Okay,maybe there is NP naught round, maybe thatNP dot round, maybe NP dot round is theirYes, and B dot round. So round function ofNP. So this a is a is this array, for example,that's five by four, a four, five rows andfour columns. So let's say I want to accessthe second row. First of all, let's say Iwant 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 indexzero. 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 ifwe want to access the whole second row, forexample, we want the second row. So that'show you call that's how you slice. A normalmeaning of this is you the role should beone and the columns, all the columns, so That'show you access the whole second row. If youwant 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, whichmeans the whole second column that is accessed.That if you see, that's the whole second columnsix, 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 numberone to rule number three, not including three.And then of these rows, you want column numbertwo to column numberfour, let's say. And if you do that, you accessthe whole sub matrix. First, it actually picksrow number two and row number three, becauserow number two starts from one. And then ofthose rows, it picks these columns, and youcan just pick the pick the sub matrix insidemore, you can, you can do a lot of processingon these matrices. For example, this is matrixA, if you just type a dot transpose, thatthese four transpose, the matrix just is takentranspose of it. Further, there is a completelibrary, linear algebra library in NumPy.For example, if you just import NumPy NumPydot linear algebra, as a for example, thenthis linear algebra library in NumPy, hasa lot of functions, Eigen values, chelskidecomposition, computing determinant of amatrix, finding out inverse of a matrix andwhat not. For example, let's say we have ladot 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 bemost 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 thesematrices 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 lastthing, let's say this is our a. And what wewant to do is let's say we want to sort thisA with respect to the columns, we want eachcolumn to be sorted individually, what wecan 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 besorted individually. And if this is a multidimensional array more than three more thantwo dimensions, then x is can be two x's canbe free. So which with respect to whateveraxes you want, your sorting can happen. Itcan do that, if A is one dimensionally, thendot sort function without an access, justsorts just sorts the one dimensional arrayfrom beginning to the end. And if you wantto descending order a sword just sought themsorted 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 goingto show you kind of masking or sometimes calledthe fancy indexing that is much more powerfuland useful in a lot of different contexts.So hope to see you in the next video withmore NumPy indexing. Okay, there is anotherway of indexing a NumPy array. In the lastvideo we saw we can, we can do slicing notation,for example, start from here and here andstuff like so. There is another way of accessinga NumPy array as we have an array and we canjust give the give an index array inside forexample. Let's say a is one dimensional arrayand 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 elementand 17th element, you can just create an indexarray and pass it. And in an index your andaccess your elements using that index arraythat's possible in NumPy array. Further, youcan 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 isa 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, assumethat has eight elements, 12345678 elements.Now you pass a Boolean mask inside, wherewith with obviously, eight elements, a trueor false values, wherever there is true. Sopick 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 seventhvalue, and don't pick the last value. So thatis also possible in in NumPy. One thing thatis important is if you do this kind of indexing,which is sometimes called masking, if youdo that, if you do if you supply an arrayindex, or index in a Boolean form, you bydefault get a copy as as as compared to slicingin slicing, you get a view that's a separatecopy, you need not to call a dot copy function,it is by default, a different copy. And thisis a difference between the ordinary slicingthat you do, for example, start from one gotill 50, take a jump of let's say two, ifthat is your indexing style, that is calleda slicing, the return value is a differentview having the same memory. However, if youdo the, if you use the array index, or theBoolean array called masks, then you get acopy of rather than also so which means ifyou if you get a new array, you change theelements in the new array using the arrayindices. You're not getting that change happento the original array. So that's the differencebetween slicing and masking. Okay, this kindof Boolean indexing becomes really handy.For example, what if you want to exit? Whatif you want to get all elements that are smallerthan eight, one way to do that is just writea and then apply a condition is less thaneight, well, a is less than eight, we'll createa Boolean array. And everywhere where theelement is smaller than eight, there willbe a true otherwise it will be false. Now,the inside array is a Boolean array, and youaccess all the elements with respect to thatcondition. So it will return all elementsthat are smaller than eight. How how fancyis that? Further, you can you can have theseconditions in a combined way. There is onedifference there is an AND operator A andD and, and there isn't an operating in a differentway. So I'm going to discuss the differenceof this and this and as well in this in thiswhole in this video. So let's go to JupyterNotebook 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 theelements of A, B access, for example, thethird element and the fifth element and thesixth 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 elementsof B now, because that's a copy, let's sayminus four, that change does not happen ineight that happens in B for sure. But thatdoesn't happen in a, a does not contain anyvalue 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 toaccess all the elements that are smaller thanlet's say that are smaller than let's say40, access all elements that are smaller than40. So that is possible now even contain onlythe elements that are smaller than 40. Allthe elements while further if you want toaccess all elements that are that are smallerthan 40 that are smaller than 40. And theyare bigger than they are smaller than 40.And they are bigger than 30. Let's say youwant to access all the elements that are between30 and 40. You can just access those elementslike so there is a problem. A dot any a dotall what's the problem here? The truth valueof an array with more than one element isambiguous use a.ne or a dot all. Okay, thisa is less than 40 is a Boolean array is greaterthan 40. That's a Boolean array. So what'sthe 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 becauseit 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'sthe difference between this particular andand this symbol and the difference is thisand AMD an operator It is used when both ofthe sides of this end has what is one objectand it has one true value either true or false.And this particular symbol is used when theleft side and the right side can be arrays,and each element of that array can be trueor false. And so, so, you can think of thisand is using arrays, however, this is usedwhen both the sides are single objects. Sothat's the difference. Other variants of andI mean, the end is like this, that these arethese are the same things, but remember theuse this is used for arrays, this is usedfor single objects. Similarly, there are othersymbols likeorthat is used this way or or that is used thatway. 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 forarrays, the right kind of symbols, they areused for single objects that has true or falsevalues. So these, this kind of masking isreally, really powerful. Later, we will seein pandas accessing different kinds of datawith particular kind of conditioning, thatbecomes really handy if we if we are comfortablewith these kinds of indexing. And that's reallypowerful indexing. Okay. So, I've told youthe difference here between Aaron and I'vetold 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 anotherpackage called pandas. So before pandas moreNumPy is coming, I hope to see you in thenext video. Okay, in the last video, we sawmasking, which is sometimes called the fancyindexing as well. And here we are going todiscuss one more feature of NumPy, which isvery powerful feature called broadcasting.I think, for example, you have an array, let'ssay two, three, a matrix, that's a two dimensionalarray 235 and nine, and you want to add, inevery element, you want to add a number, let'ssay five. So one way to do that is createanother array with 5555. And just apply thisadd operator and you are done. Great. Butthis NumPy allows you to just write let'ssay this is array, a NumPy allows you to justdo this particular thing. And this five isautomatically broadcasted to match with thedimensions 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 sayone three, you want to add this particularcolumn in the first column as well as in thesecond column, but then you need this onethree to be copied again and make a biggerarray and then you do that well, broadcastingallows you if you just write this as a plusone three, it will be automatically broadcastedto match the size of the other operand, whereverthe book broadcasting is possible, there arecertain rules to to know when broadcastingis possible it is not possible each and everytime. For example, if you have this matrix239 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 wantto broadcast this structure, the structuresshould be if if the structure is broadcastedto 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 youwill get an error because broadcasting iscannot happen, but in several cases when youwant to add for example, a scalar multiplywith a particular thing wherever possiblethis broadcasting is possible and broadcastingis just a I mean it just a feature of NumPythat allows you to not repeat to match thedimension of the other operand to apply aparticular operator it does it by itself great.Next, we see some more important functionsto no one is horizontal stack. That means,if you want to concatenate two different arraytwo arrays that are that can be concatenatedtogether horizontally, you can get out youcan call at stack function and that will concatenatethe two arrays together and returns anotherarray. Similarly, V stack is if you want toconcatenate two arrays vertically, if theycan be concatenated vertically, vertically,similarly, there, there is another powerfulfunction sort, and there are a lot of otherfunctions, these kinds of functions, theyare called Universal functions. And they arevery, very, very powerful, very, very fasttheir implementation is vectorized, whereChrist mean the implementation the all loopkind of layer is deferred to at the compiletime and the things are really faster whenyou do a vectorized code. So, having saidthat, it is always recommended to not useexplicitly for loops to achieve these kindof,to achieve these kind of results, whenevera universal function is available, use thatbecause the efficiency of that universal functionwill be way, way way more than then whateverloop loop or whatever function you will bewriting other than the universal function.So, and by the way, there is another functionconcatenate as well, in which you can specifyaxes. And it will either act as horizontalstack 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 neuralJupyter Notebook and see an example of, let'ssay, broadcasting as well. So let's say wehave 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 thelast thing and then we just NP dot around,we just round everything. So that it becomesit 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 happensthrough 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'ssay, a two by one matrix. If you do that,then still, what what will happen is justapply the parenthesis just to show that thisshould happen. First, what what will happenis there will, there will be a column thatwill be added to every column A, and thatagain, 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 anotherway, 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'sit, this is B. Now a is two by three arrayD is a two by two array, if I just concatenatethem horizontally, I will get another arraywhich will be two by five. So C equals np.atstack horizontal stack, at stack, and I willcall these A and B. One thing that you needto 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 mayyou may want to give several values to concatenatetogether maybe you have maybe you have 10matrices to concatenate together horizontally.You have to give all these as a tuple insidea All right. Now similarly, we can do a verticalstack if we want. I mean, one on top of theother. 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 isnot sorted 1/4. It is not sorted? Yeah. Let'ssay we want to sort it a dot sort. One wayof doing that is just call a dot sort, andyou're done. That's the value of a anotherway, 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 ascendingorder. If you want to sort in descending order,then what you can do is you can sort aid orsought, for example, do that in ascendingorder, then what you do is you just reverseit, minus one, and just copy that in a again,now he will be sorted. While sorted in descendingorder. Yeah, great. Um, one more just justjust just to give you one more flavor, ifyou create an array, for example, np dot arrayof strings, for example, ABC, and anotherstring is, how are you and vai maybe we haveanother string? Whew, 785. And maybe we haveanother string, one, three e r, that's it.That's a string. That is possible. As longas 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 isit will sort the strings according to thealphabetic order, whatever the alphabeticorder is, whatever string according to thealphabetic order should become first thatwill become first and the other strings, theywill they will just join. Yeah. So yeah, sothat's about something that is not that isnot the numeric value. Okay, great. Thereis a few more things to come about NumPy array,and then we will be moving towards panda'slibrary that is built on top of NumPy arrayfor better processing of data, I hope to seeyou in the next video. Okay, in last video,we saw horizontal concatenation, verticalconcatenation sort function, we also saw somebroadcasting and stuff like so. Universalfunctions, it should be speed here, sorry,it should be speed, speed. Universal functionsare 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 anexample. Let me let me just create an A NumPyarray with a lot of numbers, and then justapply an ordinary function, let's say wantto add all the numbers in this array B, let'sapply an ordinary function that is not inNumPy. And then let's use universal functiondot sum, and see how speed differences there.If for example, we apply apply a universalfunction to achieve a particular task howspeedy that universal function is, becausea vectorized implementation, as I told youis much faster, how faster let's check thatout in new Jupyter Notebook. That's a magiccommand time ID that will tell us how muchtime this particular task has, has taken.And if you run this command, it will it willcall this function again and again severaltimes. And then we'll report an average valuethat will be much more stable than just callingonce. After that, we will also we will alsowrite our own sum function using loop. Andwe will see whether that is even closer toa universal function speed or not. Let usjust check the speed of universal functionsthat will give you a look and feel of howmuch NumPy implementation is faster. So let'ssay we have an array, let's say B and B dotrandom dot Rand. And let's say that arrayis huge, really huge. Let's say that's thecase. Now what we do is we let's say we wecall 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 NumPyfunction. And then let's say we do the sametask using NumPy universal function and Pdot 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 useNP dot sum and be passed and passed, as anargument, both these things are roughly thesame. So let's run it, it will take a whileIt will take a time because, okay, the sumfunction takes 307 milliseconds, that is nota universal function in NumPy. That's a Pythonfunction. That is not written in NumPy. Thatis not a vectorized code, nothing. It takes307 milliseconds to perform to take the sumof the elements of this array. And it doesthat by applying seven rounds in in Santaloops. However, the universal function takesjust around three milliseconds, I'm assuming2.7 milliseconds, how will how are you goingto compare this 307? With three? How muchfaster you are around? Around 100? times yourfaster? I mean, yeah, I mean, this NumPy isliterally faster NumPy, the universal functionwill 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 takean argument, let's say something, let's sayG. And what it does is for, let's say s equalszero, what it does is for x in g, s plus equals2x X plus equals to x and then just returnas 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 therabee 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 universalfunctions, avoid for loops, avoid your ownfunctions, if the same task has been a canbe achieved through universal functions, wheneverpossible, avoid loops when you are workingwith NumPy. That serious suggestion, followthat, because the universal function writtenin NumPy, they follow the vectorized code,all the interpreted slowness that is deferredto the compilation layer. And the NumPy becomesreally really faster and shows its power whenyou are working on large arrays using theuniversal functions. So I can speak more aboutNumPy. But I have told you some basics ofNumPy. And we end the NumPy here and fromthe next video, we will be moving towardsa very, very fancy and beautiful kind of packagecalled pandas to handle data. And by the way,the pandas library the pandas package completelyis built on top of NumPy. Everything thatis there in pandas is built inside is builton top of NumPy as all the indexing and allkinds of stuff, slicing and speed. All isthere in pandas that is due to the NumPy.So we will see one more package after pandaswhich is matplotlib for for plotting afterwards.And we'll do a project at the end using scikitlearn as well, just to wrap up all these thingstogether. But for now I'm ending NumPy hereand in the next video, we will start pandashope to see you in the next video. Okay, welcometo pandas data science package that is very,very powerful of handling data, manipulatingdata 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 availablein pandas.Let's let's dive in. I mean, this pandas isa very, very fancy library, very, very fancypackage, that you can handle very large amountsof data in CSV files or an Excel files. Whereverthe data is located. The missing entries arethere. You can handle all the data you canmanipulate all the data you can prepare allthe data in just a few lines of Using thispandas package, so let's just start pandaspackage. There are two most important objectsof pandas. One is series and other is dataframe that we will see later on, there isone more index. But the most important oneis, 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'sthe 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. Andyou can create your own indices, for example,like, just like dictionary, this a is a keyvalue. This is a key or index for this point,two, five, this B is index 4.5, C is index4.75. And these index four one, so you canyou can, you can supply your explicit indicesas well. If you do not supply the indices,the default indices are 012, and three, butyou can define your own his own indices inthe way you want. Now, once this data objectis created, you can call the data values andyou will find out the values you can callthe dollar index and you will find out theindices let's see in the Jupyter Notebookjust to get comfortable with pandas. Firstof all, import pandas as PD, maybe or somethingelse. So okay, let's import it, maybe we cancheck what we're going to reveal working inPD dot worryin. The version of pandas we areworking in right now is 0.2 4.25. Read. Solet's create data or whatever variable let'ssay a as PD dot series buzy dot series andthere we just give a list of some values 2345let's say these are the values. And then wecan give index as another list. Let's saythe indices are a maybe the indices need notto 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 handlesone 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 theseries. And by the way, this values arraythat you get, let's check what's the typeof 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 everythinginside pandas, the NumPy is playing all therole inside pandas. Great. So now, let's checkthe index a dot index. That's also a NumPy.That's also an array of index type, that'sa different actually index is also an objectin pandas. That's an index type object withthese kind of indices, we can access for example,this a, just like we are working with dictionaryfor example, a dat returns a value, we canchange the values, we can add different, wecan add more key value pairs. So just thinklike these.Just think this data I'll just like the dictionaryobject that we saw this, these are the keysand these are the values. And this is oneone very good way of remembering what theseries does, and manipulating series The waywe want. Okay, one, we can access a z likethis, we also can do slicing. Let's say wewant to access from A to let's say C let'ssay we want to access all these one differenceis when you access like this, in the normalslicing using implicit indices, for example123 or zero, the final index is not included,but if you access like so, using explicitindices that are there, the final index isalso included. So that is one more fancy wayof indexing using in this pandas. Okay. Great,that's a serious object by the way, we cancreate a serious object by first creatinga dictionary for example. Let's let's go backto 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'screate that dictionary, then we can just createa series object or panda's object, by justpassing this dictionary inside, we can makeanother dictionary for example, and we canmake another series object. So a one way ofdefining the series object is just to is justto pass the data as well as index in otherways to just first create the dictionary andjust 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 nextvideo. Okay, let's say we have two differentdictionaries, let's say we have a lot of studentsand the a grade is defined to be four anda minus grades defined to be 3.5. The b gradeA has a number three, the B minus grade hasa number of a numeric value that is 2.5. Andsimilarly b grade has an American value let'sdo and then we create just a series objectusing this dictionary, let's say rather thanjust the numeric values as GPS or somethinglike so let's say a grade also is definedat 85 marks in total, a minus graders definedat 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 Notebookand 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 hasnumber 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 saythree. And let's say Finally, we have d gradewith GPA value, let's say 2.5. Let's say that'sa dictionary. Okay? What we do now is we createa grades series object, let's say using PDdot series, and just pass this grades underscoreteched. Now this capital a capital B, capitalC and capital D, they will act as indicesand this for 3.53. In 2.5, they will act likevalues. So for example, if we call her andjust now called grades dot v dot values, sowe will get, for example, what is that? Thatjust values, let's say, beget this grade stockvalues, and we get all the values that areavailable. Similarly, if we find grades orindex, we will find out A, B, C and D. Let'sdefine another dictionary, for example, marksdictionary dict. And there is let's say again,a while the total marks are 85. For the agrade, 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 thetotal marks are 55, let's say. So let's saythat's another dictionary. Now, let's createa 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 marksis 85, b 75, c 65, D is 55. And all the valuesthey are integer 64. Ghana values, now wecan access. Now we can play with this marks,for example, if we just want to access forexample, what are the marks? What are themarks between, let's say, for example, whatare the marks given a at a we can access thatwe can change that we can just play like adictionary. What if we rather than using theindex In a, we use for example, slicing, wewant 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 explicitindices A B, C, D, these are explicit indicesand they are there. For example, if you canslice the you can slice the data using explicitindices that you are given that you are givenor implicit indices that are the default indices,the first value index at zero, the secondvalue 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 arealso numeric, and then you do the slicinglike so, then the series object may be confusedwhether I have to use the explicit indicesor implicit indices inside we will see howto resolve that issue, but by this pandasallowed to use explicit indices as well asthe 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 seriesobject is good for one dimensional arraysor data with just one dimensional list ordictionary, kind of with just one dimensions,later, we will see data frame that actuallyis is actually the extension of curl can belooks like it can be looked like as an extensionof series towards more than one dimension,we may have, for example, two dimensionalarrays or two dimensional data structures,something like so. And we will be seeing thisdata frame which is much more powerful, particularlyfor reading data from files and manipulatingit and stuff like so. We will see that inthe next video data frame that running formof 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 datahas if the data in the form of different columns,for example, a record as an array, then youhave another record, then you have anotherrecord. And each element in that record isa different attribute. So this particularway of two dimensional data is very well handledusing data frame inside pandas rather thanseries. So but you can make these data frameobjects using different series objects. Forexample, you have a great object that gradesobject that we created last time, you know,marks object that we created last time, let'sbuild 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 seriesobject. Let's now make grades. Maybe, maybethe name is rates, okay? The name is likegrades. Okay, so grades object, this one,let's make a data frame.Let's say D, or maybe whatever name you wantto 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 datagrades. Let's say let's say we define a dataframe like so. And now if you see if you justdisplay this D, we get a very beautiful lookand feel of I mean this as the index is theexplicit 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 flippedversion or the transpose variant if you want.Great. So that's how and you can have forexample, 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 normallyare attributes. And each row is basicallyone record or one sample of the data thatyou want to work on. So this data frame isreally, really ideal data structure for workingwith files, having a lot of records and youwant to manipulate the data and stuff likeso. 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 arethe values, so, the values inside D is completelyagain, a two dimensional array that is completelylike so. So for example, if we want to accessthis particular element 65, that is row numberthree, and column number one, excluding theindices at row number three and column numberone. So we can access that particular valueT dot values, just assuming that dimensionalNumPy array, row number three is to indexwith do and column number one is index withthat, and we will be able to access 65. Wow,great. So that is there. There are more thingsthat are available d dot for example, columns,d dot columns, columns, it will give us whatare 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 needto 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. Andthat is the name of that column is scaledmarks. And the scale marks are what if wehave 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 thatis just like a dictionary, again, like a dictionary,you just add a new key, let's say, scaledmarks, 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, andthen how can we? How can we compute the marksfrom 90? It is rather than 100. It is from90, I guess? How can we compute the marksfrom 90? If you want to compute the marksfrom 90, I guess they will look like and dividedby 90. And maybe 100 is multiplied here. Iguess maybe the formula. I guess that thatthat's what it is, I guess let's see. So nowif 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'vejust computed this, we justwe just found that we just inserted that columninside that I'm in, there is a process foreach of these kinds of values. Maybe we haveadded this column in a very wrong way. Andlater on, we suggest that okay, we shoulddelete that column. Well, that's very simple.Again, using the concepts again, just likethe dictionaries, delete this, and this columnis deleted from data. And you're again withthe data that you had. So you can add columns,you can delete columns, and indexing is reallyfine. I mean, indexing like like masking,let's say, you want to bake for example, oryou want to bake the DataFrame such that youwant to pick all the records such that themarks 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. Thisis that simple. All the data will be willbe copied into g with this condition. Andthis condition can be arbitrarily complexusing ands and ORS and combinations and allthat stuff. And you have seen this kind ofstuff in NumPy as well. I mean, this is calledOkay, great. So that's available in pandasas well. Okay, so that's how you can indexin the next. In the next video, I'm goingto basically show you one type of problemthat normally happens in real data that isthe missing value problem. Sometimes you reada 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 thosevalues? And how actually pandas suggest youto handle those kinds of missing values, whichare sometimes called Nan values or non typevalues. Also, they they mostly used interchangeablyin pandas. So in the next video, we are goingto handle or see how to handle missing datain pandas hope to see you in the next video.Okay, in the last video, we saw data frameobject. And we saw actually how to add andremove columns how to process data, how toindex how to actually mask or how to applyconditions and selections in in bond as wesaw that very briefly, but in this particularvideo, we are going to see one kind of missingvalue, sometimes called name or not a number,or maybe not anything or sometimes this nuntype none, which is the default return typeof any function. In Python. This non typeis 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 istwo. Okay? The other dictionary is B and C.So for example, that is one record with columnsA and B. So a and b are the columns. On thefirst record, the value of a is one, and thevalue 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 valuec the first row value is not available. Sowe will say this value is missing here. Butin the second row, we have four similarly,the value of a is missing for for the secondrow, and that is a missing value, which issometimes called Nam. So these are missingvalues. And they are typical. When you areworking with data. And you're reading dataon 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 saywe have a,one and B, let's say four, that's the firstrow or record. The second record, let's sayis another dictionary, let's say B is minusthree, and C is let's say, nine. That's it.That's it. That's our data frame a. So nowif you bring this a if you see the data insidea, you will see Oh, what's the problem? Isthis and be heavy? Have you played somethingin a wrong way? Let's see. Oh, we have tocreate 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 thatvalue is missing. And in large data files,this is typical, I mean, there are a lot ofvalues that can be missing. One way that pandassupplies to hell these missing values is tojust fill these missing values with some somefixed number for example, there is a fillna function, fill any function and let's sayyou supply as zero that means wherever thereis a not available or not a number value,fill that with zero, or maybe any any valueyou want to fill that with. So that is Oneway to do that, and now if you see the valueof a is all the non values are filled withthat, another kind of function that is availablein pandas that is sometimes used a that isdrop na that that function drop na, what thatdoes 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 gofor that. But if if the if the missing valuesare a lot and they are spread over a lot ofrows, then dropping all those kinds of records,they will create a lot of I mean data lossand 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 themand later on we will see in scikit learn thatthere are other ways of handling the missingvalues as well, you can fill the each columnmissing values in each column using an averageor using for example, a regression there areways to to handle these missing values. Butin pandas, these two functions are right awaythey are you can fill all them with a fixedvalue for example or you can drop them andyou are ready to go. Okay great. Next, weare going to see oh as as I mentioned earlier,what is the what is the confusion betweenwhat if there is a confusion between implicitand explicit indices. And that I will discussin the next video basically, just to giveyou a look and feel what if the explicit indicesyou supply they are one three and five. Andwhat if you call this this particular commandone 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 howto 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 mentioneda confusion that can be there, if you havesupplied the explicit indices that can conflictwith implicit indices. In particular, forexample, if this is the series object, ormaybe a data frame object if you want to iffor indices, let's just think about the seriesobject, it has these values ABC with indexone three and five, if you for example, accessa 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 behaviorof slicing if you give an American disease,that is to use implicit indices, and by implicitindices, we mean by we mean that what is atindex one at index one this is b, so B willbe printed for example, or B will be fetched,and then you move to do which is C then Cwill be fetched, and these are the valuesthat will be printed, but the behavior mightbe different, you might be expecting to useexplicit indices, which means access one colonthree, and when the explicit indices are used,the last index is also included. And in thatcase, you might be expecting the index oneis of a so as should be printed, and indexthree is of B and B should be printed. Andthis configure might be there if if this isthere. So to handle that there is there aretwo functions one is called l OC. And anothermethod 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'reaccessing elements using the implicit indexwhat whatsoever. So let's, let's practicethis and see the confusion. See the detailof this kind of confusions in in here JupyterNotebook. So let's say we have a series object,let's say a equals PD dot series. And let'ssay it has values as a, b, and c, NASA value.These are the values and index as let's sayOne, three and five let's add these are theindices let's say this is eight Okay, let'ssay we access a using one that means thatmeans the explicit index and that is thislet's say B access and using the slicing operator.Now, this will use implicit indices and itwill access I mean it will access these Band C because one colon three using indicesimplicit indices results that and we mightbe might be expecting that use this kind ofstuff. So, if we are really interested inusing explicit indices, what should we dois we should call the lat function a lockand then one colon three that means, use explicitindices there is to remove the confusionsnow, it will use the explicit index one andthree and if for example, we are interestedin using implicit indices, then it is goodto use ilok function Yeah, now, one one columnthree is to use implicit indices and the implicitindices are like these. So, and like in seriesobjects you can you can you can do the samein data frame objects. Once you are usinglock and ilok then the further indexing insidethese 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 logmeans you're using explicit index ILOG meansyou are using explicit implicit index. Let'ssay for example, we have our data frame, Iguess D, that's our data frame available tous. Let's say I want to access d dot ilok.Let's say I want to access the second rowcompletely 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 thistwo is acting as, for example, if you seethe the second row or the or the row at thesecond index, which is a third row that iscompletely this edit returns that once youhave 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 implicitindexing scheme. Again, you can consider holdthat thing as a matrix. And once you haveapplied this eye lock, then you're free toplay with the indices, like you play withtwo 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'ssay I want to do that. And you can see everythingis reversed. I mean all the indexing likelike nine by all indexing is there in, inpandas. I mean, once you have used ilok insideis just just remember the NumPy indexing andeverything like so. Okay, so that's the logand I log function. In the next video, weare actually going to going to just practicethe 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 readand write the data and play with the data,the data, the real data that is there in insome CSV file, and how pandas will help youto to manipulate the data very efficientlyand 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 somesome functions that are available in pandasto work on real data set the data set I'vechosen as COVID-19 data set that was availableon kaggle. And it's surreal data set thatcontains information of victims recoveredthe total number of recovered people in percountry per province, the total number ofdied people and the total number of numberof reported people per date available thatthat data is available. Let's see the lookand 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 recordnumber. That's, that's a column called observationdate. That's a date, that's a province orstate. That's country or region that's lastupdated when the record is updated was thetime and how many confirmed cases were thereat that date, and how many deaths at thatdate and how many recovered at that date,as the date is moving on and on, you willbe seeing that the number of confirmed casesand the number of recovered cases they willbe 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 lookand feel of that data. In Jupyter, notebook.Let's go to Jupyter Notebook and see. So firstof all, I need this pandas library and pourit that maybe somewhere I need this NumPylibrary 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 powerfulto use the I'm in the SK learn library thereis also a Data Science Library package thatis particularly a machine learning library,or our package that actually gives a bettersupport or a larger support of handling missingdata. Although here I have used this SK learnfunction just for an example. And but butI could have used this data frame fill anyfunction or something like so but I'm justusing that one. Okay, after importing allthese, what I did is I just call PD dot readCSV function, and I load that data and thenI did this stuff one by one. Let's, let'slet's spend some time on all these commandsone by one. And let's see in Jupyter Notebook,what is happening, let's go to Jupyter Notebookand actually read that file and do whateverwe are doing here. So first of all, importNumPy 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'sOkay, 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 readCSV. And it contains the path of the file.The path is located in my directory, it islocated at this particular location COVID.And the name of that is COVID, underscore19 ESCO data. So COVID underscore 19 underscoredata dot c s v. So let's read that file, thefile will be read, if you just see that someof there is a function, let's say head thatgives the top records or the records thatappear just the very top that's that's whatthe 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 thisparticular way. Okay, great. Let's say I justwant to remove this real number because Ithink that is not required. And let's sayI want to remove this particular column. Becausethat is also not required. There are multipleways of doing that. I can call an t l functionon this. And I can call the L function onthat. But there is another way of doing thatby df dot drop df dot drop and in that youjust give the columns that you want to dropone column is serial number, I guess, what'sthe column name? That's s and No. So you wantto you want to drop that column and then youwant to drop this particular column with herringlast 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, istelling that whatever this operation you aregoing to do reflect the changes in this dfframe. If we do not write in place to it,we'll do everything and return onto a temporaryvariable or underscore variable or whateverwe are saying, but the DF the data frame willstay unchanged. So in place true means dothat changing in df variable itself. So nowif we see df dot had flat say, it will nolonger be showing us the serial number columnand 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 dictionaryagain 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 isdictionary what columns you want to change,I want to change observation date, I wantto change that to simply date, let's say andI also want to change province slash stateto simply simply state, our province provincethat say simply that and I also want to changethis country slash region to simply country.So, maybe I want to change this country slashregion to simply due to country cru and trycountry and I want all that should be happenin place. So in place equals true. So afterthat, if you run that, on this particularstep, 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 mayhave a lot of missing values, oh, one way,this date format, the date format is not ina format that pandas internal date format.So let's convert the date format into intointo the internal pandas date format, usingto to PD to date time function. So let's saydf date equals to PD to date time, and convertthis df date in that particular format. Andnow 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, wecan see those let's say I want to just I wantto just count or let's say let's just describeall the data at TF dot describe there is adescribe function that describe all most ofthe statistics of the data, I mean, the totalcount of confirmed cases are these the deathsare these recovered are these these many columnsare there these many values are there. Themean 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 functioninfo, it will give us the more informationabout the null increase and the nominal increaseand so on. For example, if you see the totalnumber of data columns are six, the totalnumber of records are 6162. The date increaseis always available. The province entriesare only 3700 available, the rest increaseour null increase, so province increase mostof the increase or null increase and theyare there, maybe we want to drop those ormaybe we want to impute those increase andstuff like so, but they are not increasedthat are available in the province column,some of the province, some of the provincevalues 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 datais 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 missingvalues. One ways to do that using simple mburofrom SK learn. Another way is, as we alreadyknow, just df dot fill na fill na with, let'ssay a bit let's say not available with let'ssay a string, some string not available, that'sit that string and with that, if you fillthat fill any using that now, after that,we will be having all that data, the missingvalues will be filled according to Let's seesome missing values because in the provincethere 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 ofthing that is available by a psychic learnand so on. Okay, after that, if you now seethe information info, now, you will not beseeing any null value, all the columns arethere, 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 callthe 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 detailedway. Because this this particular video isgetting lamp here lanthier. me I'm stoppinghere in this particular location. Next time,I will show you the group by command in thein the panda's data frame. And I will showyou what that does. So, we will explore allthat code that is written here. And we willhave in the in the upcoming videos when wewill 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 howthey 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 videoright from this command. And I will tell youwhat is happening what is the scope baikmanso hope to see you in the next video. Okay,in the last video, we were discussing thisCOVID-19 file, and we reached here but wedidn't use this SK learn in pewter, we justuse the fill na function of data frame. Nowlet's discuss this group by command or a Curiein in pandas that is much more visible. Let'ssay our goal is now for example, if you goto 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 see10. Let's see, what you want to do is youwant to just see how many, how many totalconfirmed 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 therecovered 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 equalsdf dot group by and in group by what you seeis for what kind of columns you want to youwant 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 ofwhat kind of what kind of, for example thevalues you want to see because now you'redropping? Well after grouping I really Wantto see because data is gone once I drop, allthe dates, they are grouped together all theprevents that are grouped together. So, whatI really want to see is just the country andI want to see the confirmed cases. So, pickall 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 andjust I want a big group all the countriestogether group all these things together andadd all the records under each country. Sosum all of them, and maybe we want to resetany index if it is there. So for example,preset, we set index. So that So, after thisCurie For example, this group by query, whatwill happen is this df two will contain asummary of the data with respect to each countryand the total for example, in this particularcountry, the total confirmed cases are theseall confirmed cases till now, and the deathsof these and recovered as these for this countryfor each country, now, each country is describingAustralia 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 togroup all these with respect to country, whatif we want to group all these with respectto country and then date for example. So,first we want to group them by country, socountry 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 samewith one kind ofwith one kind of let's say we want to firstgroup by country, once the, it is groupedby the country, then I want to group themby 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 thatwill be displayed here. So let's see df twonow, df two. So if you see df two now, youcan see, for example, this particular country,it has just one record in this country, ithas one record, then this country for thisdate has this record for the same countryand other date has same record and all thedata is also sorted. I mean, now you can seeall the records in a very incremental way.So that may give you a very good look andfeel of what is happening or, for example.Another thing What if you want to what ifyou want to, for example, find out all therecords, all the records, you just want tofind 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'slet's let's get just let's just pick all therecords for which the confirmed cases arelarger than 100. And let's copy all theserecords just those records in this. So ifwe do that, we have d3 available, and we haved3. This, I mean, these are just the recordsin which the confirmed cases are for surelarger than 100. Just those. Yeah, so we cando. 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 realdata set. I mean, there is a lot more thatwe can do with this pandas library, on realdata sets on multiple data files, combiningthem together, joining them together, seeingtheir correlation, a lot of stuff. And thispandas really is a very, very fancy and veryhigh 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, butin the next video we will be jumping towardsmatplotlib just we will see some some functionsof matplotlib. And we will see very brieflyhow can we plot How can we analyze data usingvisual graphs or stuff like so. So, that thatsometimes this visualization of differentattributes 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 visualizationtechniques are in a way that you can visualizethe trends in the data, that gives you muchmore much better insight than the numbersor statistical results, but it completelydepends in what situation you can visualizethe data there are situations, high dimensionaldata, for example, is not always visualizable.So, in those cases, the statistical resultsof the numbers may play a more important role.But in more in many cases, visualization givea very good initial insight into the dataand the design process can become very, veryfast if you know something about the data,whether you get that information by visualizationor by other statistics or whatever. So, inthe next video, I will be just explainingsome very few functions of matplotlib. Andthen we will be, then we will be exploringthe 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 playingwith 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 plottinggraphs 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 themost popular module, or the most used moduleis biplot. So we can import matplotlib.piplot as PLT. Another way of writing the samekind of stuff is we can we can write likefrom Matt matplotlibfrom matplotlib import by plot as PLT. Soeither way is fine whether we write this asa documentation or that one that is fine asMP 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 zerotill 10. And let's create 1000 points in between.One way to do that is to use built in functionor a method in NumPy, which is linspace orlinearly spaced points starting from zeroending at 10. And there are 1000 of thosepoints. Let's say this is our x and this isour let's say y which is NP dot sine, thesine function is actually will apply elementby element on this NumPy array. And then thisPLT will plot will actually plot x comma yall the points in front of you. So let's goto Jupyter Notebook and actually see thismatplotlib in running form for the very firsttime, oh, we have seen this matplotlib. Whenwe saw NP dot random, we only plotted a histogram.While this is not the first time we actuallyhave seen this once, once, once before. Soimport mat plot lib.pi plot as PLT. That'syour 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 yourx, y might be your MP dot sine x. That's it.That's your y. And then what you do is yousay okay, PLT dot plot, x comma y point bypoint, and then you press Shift, enter. That'sit. Oh, this plot is there in front of you.That simple. I mean, that simple. Can youimagine? This? Is that simple? Yeah, thisis that simple. So I'm in plotting. This isa line plot. For example, if we want a scatterplot,we can say okay, PLT dot scatter, there isa scatter function that allows us to plotall these endpoints form rather than ratherthan this line form. These are all these alot of points. That's why you you're not seeingthese scatters. So let me let me let me takethis n x s viewer. Let's see. Let's take xas let's just take a few points, let's sayjust just just 30 points. Let's see the corresponding30 points, see, they remember the indexingof NumPy arrays and just using that. So nowuse 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, attemptpoint. And do the same with why, just to justto see a plot in a better way, just samplesome 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 goingto 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 everythingwill become red. Yeah, so that's right, wecan have I mean, we can label it we can xlabel it, we can via label, there are a lotof properties. But but the but the main pointis plotting is that simple plotting is thatquick, using matplotlib. So yeah, this matplotlibis really, really powerful, we have just seena snapshot, just a plot function and a scatterfunction there, there are a lot of propertiesto be said, there are a lot of things to beconsidered. And we will see we will see actuallyone one lanthier good use on this COVID-19file. And we will we will actually analyzethe data trends and the confirmed trends andsome trends that and we will plot them andsee the trends really using matplotlib. SoBut before that, let me let me show you that.If you call for if you call this plot multipletimes, for example, maybe with different colors,then you will be having a lot of curves onthe same on the same plot, for example. Sofor example, let's see PLT dot plot x commay, let's say with with color, let's say colorequals to blue.You can write blue, the whole or you can likewrite just be that's fine PLT dot plot, x,and let's say NP dot cause x and the coloryou are interested in, and let's say the coloris, let's say green. And that's perfectlyokay. And that will give you two plots inthe same figure, sort of, and you can justgood to go. Well, yeah, so that more you can,for example, you can plot with a green, greencolor, and you want the solid line, or youwant, for example, Seon color in a dashedline, or you want a dash and dot black lineor, or maybe you want to completely dottedline in red color. So there are several thingsthat are available in matplotlib. This isjust a very few very simple snapshot. AndI have given you a very quick start in andactually actually the whole point is usingMatlab is that quick, I mean, you can youhave your data, you just plug in their data,you just call the plot function, and you'regood to go for analysis. Okay. In the nextvideo, we are where we will actually walkthrough the we will actually walk throughthe COVID-19 data set. And we'll actuallyanalyze the trends and to add the death ratetransfer each country individually, and thenwe will see the depth confirmed and the recoverytrend of the overall world till the 16th ofMarch till the day till the data data is available.So next video will be actually the viewerwill 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 thatuses matplotlib and pandas to find out thedepths conformations and recovery trends usingusing different plots. So let me import allthe packages that I need. I need a plot byplot function from matplotlib. I need pandassomewhere I need NumPy. And I'm using a simplemburo here for missing values. So let's runthis. Let's run this command. And yes, everythingis imported. Now let's load the data thatI've shown you earlier. The data is availablenow. 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 ofthe data That's the data file, which is COVID-19file. And it has observation day provincecountry, last update, confirm, to date, deathto date and recover to date for each countryand for each province individually. Okay,great. So that's what we have. Now what wecan do is, now let's drop the serial numbersand last update using in place that and renamethe columns that we did already in a previousvideo as well. Let's convert the date intothe pandas built in date, frame. Okay, let'suse the psychic learn in pewter, sk learnin pewter, using the constant strategy, thereare a lot of strategies there, let's use aconstant strategy. And this period or dataframe, in pure dot fit transform that willhelp 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 countryfor each country. And for all the dates, let'ssum all the records that sum all the valuesof records deaths and confirms using this,but now let's first country and then all itstate, then the second country, then all itstates and so on. We have seen that in oneof our previous videos just running that again,just for a double check. So that's what thedata state is. So country one all it statescountry to all it states. So this countryhas a lot of dates, then another country andso on. Next, let's see how many countriesare there. In total, how many unique countriesare there. So what I, what I do is I findthe 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 lengthlength of countries tell me how many uniquecountries are there in this data file?There are 171 countries. So now my goal isfor each country, I want to see what is thetrend of with respect to the date as the datais 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 thedata 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 loopyou remember that. And what I do is let'sfind out the indices where the country islike this, let's find out the index all theindices where the country is like that. Thenwhat do you do I make a scatterplot. That,with starting from this, and that, I justpick 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 getall the recovered cases, then I do anotherscatter plot to get all the depth cases. Andthen the title of the title of my figure becomesthe country name, the x labels the days, dayssince the first suspect, the wire label isthe total number of cases, the legend commandactually will be there that will show whateat that is in. So these kinds of labels thatare rewriting here, they will appear in thefigure, then we force them to show that ineach iteration show the show the fourth. Sothis will show the trends of confirms to coversome deaths for all 171 countries one by one.So if we run this command, we'll be having171 plots in front of us. Let's see all ofthose one by one. So yeah, so this is forthe country. It has just one such thing. Thisis for that this is for Afghanistan. As thesemoves on the confirmed cases that are evenblue, they are moving up. These are the numberof cases. These are the number of days sincethe first day. And the green is the numberof 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 reallyin as dangerous position anyways, that's forAustralia till till the date we have to dothat is for Austria. Yeah, so these are allthe trends for all the countries. You seeI'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. Sothat's what this is for Finland. Oh, Finlandis also in trouble. So France. Okay. So thatis for Germany. And yeah, so all the countriesthat are available in data set, they havethese kind of plots. This is for Hong Kong.And this is for India. And this is for Italy'sor Italy's. Yeah. So that's it. So that isfor each country individually, what if wewant the overall trend, or the overall confirmand the deaths and the recover trend for allthe world together, so what I do is I bigI grew up all the data with date. So I pickthe first date, and add all the records, thenthe second date for all the records for allthe countries and so on. And then I plot thetrend using the scatterplot, again, confirmedrecord. 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'sa recovery trend. And that's a confirmationtrend that is moving on. Although I walkedthrough or this notebook, the notebook willbe available to you. I walk over this notebookvery quickly. But the goal was really to showyou the the I mean, that was a file may notbe that informative, if you see that in Excel,but now it makes much more sense. When yousee these blobs you know what is happeningand you have insight in the data. And lateron, we may we may want to predict we may wantto make predictions. And the next date whatis going to happen, we may want to predictusing this plot or using some Machine LearningLibrary like psychic learn or TensorFlow orsomething like that. Okay, so that's it. Ican 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 learningbasic machine learning. Then there are otherpackages like TensorFlow for deep learningby torch for deep learning. There are a lotof packages with a lot of speciality is indata science and stuff. I just discussed afew of those the most important of those doto manipulate the data to make predictionsto make classification or regressions. Forone, one way is to go to SK learn or psychiclearn. And if the data is huge, and you havea lot of large amount of data, and you havegood expertise or deep learning, then youshould go to either TensorFlow or pytorchthese are the Python packages that are availablefor predictions, classification, regressionand a lot more, but either way, whether youare going to use scikit learn whether you'regoing to use TensorFlow or pytorch eitherway, you have to use pandas NumPy and sometimesmatplotlib to pre process the data and tomake the data ready for for these kind oflibraries to to perform predictions, eithera either in the form of classification orin the form of regression. So so so this wholecourse 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 spendsome time not a lot amount of time sometimeson exploring the data science packages aswell. But, I mean, there is no end we canexplore more, we can talk about the packagesmore we can talk about other features of Pythonmore, a lot of I mean, input formatting, outputformatting, modules, packages, standard templatelibrary, file handling Internet Access database,I mean,this is a whole universe, I have discusseda few things for beginners. But But thesefew things were very carefully selected fordata scientists. The if you have this courseavailable to you as you have gone throughall the course, you now have a very very goodunderstanding and now you can you can movetowards further edit advanced courses towardsdata science and you will be ready to implementthe concepts in Python using using the packagesI have discussed so far. So I thank you alland good luck.\n"