Python Zero to Hero | Day 2 | LetsUpgrade

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] [Music] [Music] hi hi everyone hi good evening good evening guys hi so um let's see who all right okay see that is okay hi hi good evening guys i hope you all are doing fine and kicking off and yeah so i'm very really very sorry the last two days we could not actually do the class okay because something uh very uh urgent and important came up and which we could not control like that was beyond our hand so so very sorry for that but right now i'm back here guys so let's do this python zero to hero let's resume from the point where we left actually okay so we'll be doing uh day two of python zero to hero so i welcome every one of you guys to day two of python zero to error i hope uh all of you those who are present over here right now today in this session have already was the day one video if you have not guys okay after this session just directly go there and watch that session also i would like all of you to put attendance for that day also day one because as you know everyone um this time we are having two kinds of certificate right one is um like participation certificate and other is completion certificate so if you uh put only the attendance for all these three days also one more day for career and placement guidance session then you'll be eligible for participation certificate and if you submit assignments and projects whatever would be given in this throughout the course along with whatever like along with putting attendance then you would be getting completion certificate okay right so this is day two guys i welcome once again i welcome every one of you to day two of python zero to hero let's start our session let's start discussing the concepts so where we were basically guys uh we were discussing list data okay we had jumped or we have we have actually stepped into the advanced data types or advanced data structure of python okay and we were started our discussion already on uh list so let me open the same google collab and we would get to the same point where we left just give me a moment guys i'll just quickly share that screen where google pull up would be seen to you all okay fine great so i hope you already like all all of you had fetched the assignment for the day one it was like taking two input okay and storing uh two variables x and y respectively and find x to the power y that was the assignment actually for day one let me just share you all please let me confirm like let me know guys in the comment section if it is like when it is visible actually okay let me know if it is visible guys i have already shared a screen that is the google collab which we were working on already please confirm me in the comment section is it visible to you all akash you can check there is an assignment submission form link in the video description okay you can check out that link everything has been guided there how you can submit your assignment and all and also i'll be also putting here the assign sorry the attendance link if at all if anyone uh has not yet fetched it or if if at all anyone is not able to find so i'm putting the assignment so the attendance form link here okay better if i pin it so that anyway like anyone comes and would look for the assignment so attendance link would can it can be found in the pinned chat okay also the the assignment submission form link do check guys in the description okay it is there assignment submission link also there are some other useful links also like registration link if you have not registered for the course anyone you can register okay do check the community group link okay so assignment and materials are posted there right so just check out those links right just join the community group also uh no not every day just you have to register for this particular uh batch for this particular python zero to hero batch okay so yeah uh i hope the screen is purely visible those who are complaining about the display thing please check what is your video quality setting right now okay at what quality you are watching the video please change it we change it to maybe 720 at least okay or maybe 480 if you are watching on a mobile or cell phone right and it will be clearly visible as people can you please confirm everyone is it clearly visible to you is my screen visible clearly please i should check the assignment from our submission form link everything is guided there you you would find a video actually in that form uh the video guides you how to submit assignment how to create github and all repository and how you can submit yes right okay great so uh just to break the boredom guys let's uh like enrich the the level of enthusiasm and excitement i would just ask you all to just spam the comment section with your favorite emojis guys and then we would start with the band okay just break your boredom uh spam the youtube comment your youtube chat box here just spam it spam ideas put your favorite emojis and you would like we would be starting with the uh list data type which we were talking about do spam it i'm asking like no one asked you to spam the chat box i'm asking you just spam it okay how to save the code google collab offering okay it's very simple you can just go to this file and there would be a download option where is that yeah see download dot you can store it in ipynb file or dot ui file as per your requirement you can uh download okay fine let me see yeah i now i see like yeah people have really like put up their favorite emojis that's great that's great i think i should also post something like in the chat uh what should i post here maybe the youtube logos i would just post yeah okay now it feels uh colorful and uh now it feels like yes everyone is excited and full of enthusiasm to start this session day two okay fine let's let's get started guys so where we were we were discussing actually the immutability feature of string and mutability of list we discussed that list is actually mutable okay i mean to say you can change the content of the list like here it was one and later i replaced that one with 10 and that was possible because list is immutable but the same thing if i try on a string this is a string s equal to welcome and i try to store or i try to replace this w by p but it gave me an error it says assignment string object does not support item assignment so string here is immutable but list is mutable that's what we got to know from that example guys let's now uh see some other functionalities of list there are many functionalities guys that's uh not everything would be decide like discussing but yes the most important ones let's discuss that so let's take a list okay yeah so li li fine and then i have uh let's say three six the name of the list is i have taken as a li maybe here i take one here i will take seven then five and maybe i can take here two okay how to sort a list okay how to sort a list so guys if you want to sort a list there are many inbuilt method actually not many list has an inbuilt method of sort so let's use that to sort this list okay it's very simple you just write li dot sort uh you might be asking what is this like what i'm saying about built-in function or method or something don't get confused guys i hope you have some idea about function okay anyway will be like discussing function uh yeah we'll be discussing something about function later but right now just understand that this sort is already there it is defined already in list class so uh why i am calling this method is uh just know this guys when a function is defined inside a class then it is called as a method so we already have seen whenever you check the type of a data type it says class in or class list or class tuple or class stf so all those actually go data type whatever we have seen those are actually classes and this sort is a function defined in that class that's why i am calling it as method okay list method sort is a method of list class so i am using it guys okay so list dot li dot sort and then if you print the list okay so let's see let's just let's just wait for it yeah see our list is sorted okay list is sorted so sort is a built-in method through which you can actually sort the list guys okay what would be the disadvantages uh you can say speed matters like python is actually slower as compared to c c execution time is less in c compared to python okay so let's see see here guys there is one more way through which you can sort the list let me tell you that so i'll be taking the same list that would also note the difference between the two ways to sort there is a built-in function now i am saying function because it is not present in the list class it is a independent function it is predefined but independent it is not within any class thats why i am saying it is a built in function so there is a built-in function called sorted okay so if you apply sorted over a light and if you directly print whatever this sorted function returns if you directly print it guys you will get a sorted version of the list okay mark my word i am saying you will get a sorted version of the list the list would not be sorted let's see okay let's clarify let's check it out let's cross check whether the original list has been sorted or not let me execute it you know all right how to execute you can click on that play kind of button or you can press shift plus enter and we see here the original list is still the same no changes okay absolutely no changes in the original list but the sorted function built in function is returning me a sorted version of the list okay understood guys the difference between this sort method and sorted sort method when you apply on a list original list is sorted the original list the actual list has been changed it is now sorted but when you apply this built-in function software over list it doesn't change the actual list it just returns a sorted version of the list i hope this is very much clear to everyone yeah ascending order yes uh shiloh you can check your video uh quality setting okay in which you are watching right now please check it okay at least make it to 480 and it should be fine i think if not please increase it further you have mcs exactly sort wood sort the list in ascending order by default when i sort it is ascending order when uh when you want to say uh descending order then you say reverse short guys okay whenever you want to say sort the list in descending order you just say reverse sort that is what it means same thing right okay so now i hope everyone is unlike very clear with the difference between sort the built-in method sort of list class and the built-in function sorted okay right now as you all like i was going to discuss that but yes anyway some like one of the one c i think one c has raised this question so um [Music] how to sort a list in descending order or how to reverse sort it it's very simple guys let me take the same list okay i'll take the same list i want to reverse sort or i want to sort the list in descending order it's very easy just apply the sort method there is an attribute called reverse and you just set it to true p capital guys remember true and false p capital and in false f capital in python just set this attribute reverse as true and then you will get the original list then you will get the list as a reverse sorted p is 7 5 3 2 1. same thing goes for sorted okay if you want to check it out let's check it out just a moment i'll just copy the entire code here and here i'll just say reverse equal to reverse equal to 2 right let's execute it and let's see for ourselves here oh it gave me an error the reason behind this is this should be comma here and not full stop my bad guys okay now let's execute this okay we got a reverse sorted version of the original list the actual list is unchanged guys because sorted built-in function sorted doesn't change the actual list so that's what the difference between uh like sorted uh like that's what the difference between sorted building function and the sort method of list class okay right so we are we have reverse sorted and we have sorted so when i say reverse sorted it's actually sorting in descending order i hope everyone is with me on this part and no one is left around i want everyone to be on the same page guys please let me know in the comment section if everything is fine till this point so that i will proceed further i'll come to that uh rakshita right yeah reverse that is a different thing i'll come to that right now yes okay great thank you for the confirmations guys let's now discuss whatever rakshita has mentioned here mentioned here rakshita has mentioned actually on another built-in method of list that is reversed so let's see what reverse does okay and someone has actually put another question i remember like if we have uh multiple data types and all if if in a list we have string we have integer we have float or maybe we have yeah string maybe we have complex number can we sort that ah so guys obviously how we sort by comparing values right can you compare a string with integer can you compare a like complex number with the string no right obviously uh there would be a problem like we cannot really sort that list okay but you can try it out just take a list with integer and float and try to sort it like try to apply sort function there and let like you see whether it is getting sorted or not that would be that would be a task for you uh just to explore the thing okay fine so now we are discussing about the reverse method built in method reverse so it's quite obvious by the name if you apply the reverse method on the list it would just reverse the list okay so reverse sort is different reversing the list is different so it will just reverse the given list guys so three one seven five two the list now it is two five seven one three so the list is getting reversed that's it because the task of reverse is that simple uh there are some other methods also important methods also like um okay let me take a list example maybe we can work it out with the same list guys for this question maybe for the next question i would be using a different list so see this there is something called index okay there is something called index method what index method does here index method returns index of the particular element that you are searching for so this is you can say you are searching for an element index method searches the element for you and returns the index of the element if it is present in the list obviously okay see this so if i write here 5 it should return me the index of 5 that's what i am trying to say here t i am getting 3 and so index 0 index 1 index 2 and index 3 5 is present at index 3 that's what this index method is giving me back okay so index method would search the element for you whatever you mention whatever you give in the argument and could return you the index of that element right what happens if we give an element which is not there which is not present in the list so let's execute it execute the code let's see it's giving me an error guys it says value error 8 is not in the list so it is not able to give the index for obvious reasons okay right so i hope even like all of you understood this index method what index method is doing index method will give you the index of an element that you are searching for okay right okay got it everyone so if you given a element which is uh not present so obviously it will give you value error but if you give a element which is present then it would return you index of that element like here i am getting 2 because this element 7 is present at index 2. that's how this index works guys okay what if what if i'll take the same set of values but i'll modify them what if i have here maybe one again okay um maybe um five again one again and then seven again but yeah that's it let's let it be these are the elements in the list so as it is like it is very clear here some elements are getting repeated here okay some elements are getting repeated i'll come to this question the they were here of yours so we'll discuss that don't worry about it so we have this list now if i apply the index thing li dot index of same element let's say five i'm searching i'm so trying to search the element five and yep five is present but the thing is here five is present two s okay two times or it is present uh twice so which index it should return that's what we need to check let's execute and see for ourselves so it's giving me three okay that means it is giving me index of the first occurrence of the element okay right it is giving me index of first element uh sorry first occurrence of the element in the list i hope every everyone is clear with this no white spaces no white spaces uh is not calculated yeah uh they are just like i mentioned the spaces to separate two elements from each other that's it even if you don't give space like doesn't matter like no error actually but yes or present for making it presentable i give i have given spaces that's it so i hope everyone is clear with this so whenever there are multiple occurrences of an element and if you are applying index method for that element it would give you index of first occurrence of that element okay right understood everyone okay now uh see this now there is one more method which i would like discuss here that is li another method which i want to discuss is count let's say one so what count method will do here count method guys will return you the number of times the number of times this element is present and you see here it is giving me 3 because 1 is present 3 times here here and here that's how uh like that's how like it works and this is so simple okay understood guys everyone like index method count method clear everyone should i proceed further you just let me know guys in the comments okay rashida okay i got it so it's here great um can we reverse the character or words uh yes of course we can do that but you are asking about something in string you can do that with the will okay you can do that yes of course that's a question of string and you can do that if you want to reverse the characters of a string let's say ht is a string and let me let me take directly a string well from and you are saying you just want to reverse this string do we have a reverse function here first of all that's what we need to check so if i print let's see let's check for ourselves it says there is no attribute reverse so that means we are not able to reverse the string by using any built-in method reverse so there is no built-in method guys reverse or string class so certainly we cannot apply reverse or string in just to reverse the string how we can do it so when we cannot do this way we can do that in like in a different way right so that's what i am going to do here so i am not able to do it in the straight way here by using this reverse method so i will like use another way another path to solve this query and the simplest way right now which what is getting into my mind right now is i'll take a list okay and i will convert this entire string into list okay if you want to see the list content after it let me show you okay for just uh uh for your user or for your reference this is my list now i have converted that string welcome into a list so this list contains each character of the string w-e-l-c-o-m-e so now i have a list guys and i can surely apply reverse third and then you can check out the list again obviously it would be reverse e-m-o-c-l-e-w but it is still a list we i needed to uh like convert it into string again so it's simple very simple again so what you can do is just apply str off just apply a str function over a li it will be converted back into string okay oh i forgot to print this new string that is st see for yourself guys here oh we didn't get here e m o c l e w why it didn't converted back into this list was not converted into string type okay i think i need to check why this happened okay my back my back my back got it so it was converted into list but the thing is uh but the thing is uh the entire list is stored as a string whole like this whole thing is a string now okay so there are other ways guys through which we can actually do this like um i don't want to get into that stuff but i would seriously give you this way you can search for your own there is something called join okay there is something called join and if you apply over this list okay right you would get the answer here respective answer you'll get it here okay so if i apply it you'll see it's still oh the my problem my bad my batman okay the the problem uh okay my bad i should not give your lie can i keep this thing after i discuss iteration guys because i remember i haven't yet discussed iteration so that is the problem here because i have to use your iteration then only i can do it uh do we have like have we discussed iteration of list let me check beforehand can anyone confirm also like did we yeah we have done we have done yes yes we have done guys like i remember yeah here we have already seen how to iterate over a list so let's uh do this here guys let's iterate over the list and do this joint operation again okay those who are saying that slicing operation colon colon minus one i would say the difference guys just wait for a moment let me finish this up and i would like i will tell you the solution just to make sure first i am printing the li i just want to make sure what l is containing okay fine li is containing emo cl ew now i want to like uh convert this into a whole string so if i apply str function over it the entire thing would be a like a string and that thing would be a string but the thing is when you print it you will get in this format only okay this entire thing would be a string if you directly convert apply str on a li so we what we have to do here we have to take each element of the list and concatenate with the concatenate together or join them together to make that string that's what i'll do so very simple we know how to iterate over the list just iterate over the list we already have done this guys please do check out uh the previous session if you are getting confused here how to iterate over a list and for each of the element of the list okay first time i would be e second time i would be m third time i would be o so on for each value of i what i want to do here is i want to apply here this join what join does is join will take this element i and it will just join them together okay understood and finally guys here if you print st you'll get your answer okay so right now i'm not getting the answer because i think st is holding the previous changes whatever we have done the thing is we should be here assigned okay we should assign here and now we are not getting here emo q rather we are getting w okay my bad so what we are missing out here can i never think of it what actually we are missing out here why it is not working why it is not working just tell me guys why it is not working okay everyone can anyone mention why it is actually not working what is the problem what might be the problem here yeah tell me guys okay yep say i'm waiting for your responses guys include print in loop is that the i want to like convert the whole thing into a string if i if you want me to keep the print statement inside the loop what would happen even i can print each element of the list then in that sense why i need to apply join and all if i have to keep the print function inside the loop i want that whatever i do i would do a process and at the end of the process my string should be changed my string which was uh welcome it should be emo q now and i should print that updated string at once that's what we are trying to do here okay so tell me guys no one no one okay let me tell you this let me tell you how join works is i think i should given another example to you and then you can understand okay so maybe i will take this h h e l okay certainly why i'm talking uh typing uh so slow i'm not sure okay let's say this is a list guys uh maybe uh yeah l let's call it l this is my list so if you want to convert into a string you just want to print hello let's see how actually how actually you should do so you just do is let's say i'm writing this statement let's just figure it out i'm writing this character or a string i'm taking this ad grid symbol i'm writing here dot join right and i'm taking this l okay now let's see and whatever this would return me i'll be storing this in a variable let's say s that's what i am trying to do here now if i print as what is the result just see here guys what happened here it took element of the list it took h it took e in between them there is an address symbol so whatever you mentioned here that would be uh uh placed in between two element of the list so h at the red e and the red l at the red l at the right o that's what or that's how join works is there any doubt on how join works then i'll solve that question okay is it clear how join works guys please let me know and then i will move on to solve i'll move on to that question i'll solve it but first let me know is it clear how join works how join works how joining works is it clear so to place a string here some string it's not actually only this address even if you go for dollar okay let's say i'll write your address dollar and you apply join so what would happen between each element of this list there will be this address symbol everywhere this is how join works so that's the mistake which we were doing here so what i need here i need this emo clue together okay i don't need anything in between them so i'll just give a null string here because i need null string between each element so that i'll get e m no nothing between e and m nothing but an m and o so null string dot uh we don't need this loop guys okay so because automatically it will pick up element of the list okay fine now see and guess we are getting emo q we have successfully reversed the string so what we did first we did the string we have taken the string welcome we converted into a list right it's very simple just apply list function over string then we use this join method of string class this is string class method guide join so join uh we already know now how join works and that's what we applied here so we apply we mentioned here null string because i don't want anything between the elements of this list so that's how it works and that's how we reverse the string i hope it's very clear to all of you okay just let me know guys if anyone could not understand i want everyone to be on the same page i would be also answering uh those who are mentioning that slicing operation actually okay yeah i'll talk about that omg um i'll talk about that i'll discuss that but first let me like let me get confirmation from you all if this is fine if this is understood by you all um then i would proceed further next i'll be answering the question which like some people were mentioning this slicing or a thing so let me just tell you this uh some people were saying if i have a string maybe s i'll take if i have a string here hello can i not use the slicing operation which we already had this first uh had we discussed slicing operation guys i'm not sure that we had discussed sizing operation yeah the thing is we have not discussed flashing operation so don't get confused guys let me first cover the slicing operation of list and it is actually same for list and string so when i cover the slicing operation for list you'll under you also on unstable it for uh string you'll also understand it for string so for that let me take a dummy list actually first of all or if you want me to explain that uh using a string i can also do that so let's proceed with the string what do you want to take maybe i'll just go with the welcome string only so guys as a list string is also like indexing is also possible in string okay let me show you this for if i print here print sp of 0 so it should give me the first element w why it is possible because indexing is possible here indexing is done that's why it is possible so if i want the third element let's say i want the fourth element so i'll mention index has three because we know index as from zero zero one two three will give me this three st of three will give me the fourth element of the string that's nothing but c yep okay so indexing is available indexing is done both on list and also on a string not only that it is also done on couple guys okay we'll be discussing couple very soon within one or two two minutes but um indexing is there or like done on or applied on list applied on string also applied on tuple so indexing is everywhere here list string tuple indexing we have we have the option of indexing right now so what we would like to discuss here is we know that indexing is possible fine let's understand some other concept also indexing is fine we know it already we have studied in c or might have started in c plus or might have started in java but what is this thing now i am saying here one colon uh four okay see this this is something different this is what i'm using called as slicing operation guys okay let's see the output and let's figure it out how it works or how what it is doing exactly so st 1 column 4 it is actually slicing out a piece of the string guys okay so basically it means it is giving me the value from index 1 till value of at index three guys okay just to like please uh keep in your mind so this is the start index okay this is the start index start index and then let me write index and then your end index so whenever you mention an end index it will go till n index minus 1 just remember this thing okay how it works it will start from the start index it will go till end index minus one so here one is the start index so it is starting from one index one e then this index two then this is index three this is where it will stop it will print e l c it will not print o because o is present at index 4 and you have mentioned 4 as n index so it cannot touch an index will stop at n index minus 1 this is slicing guys slicing out a piece of it okay very much literal meaning it has so we are just slicing out a piece of it understood guys what slicing is is it clear everyone let me know yes no yes no no yes please let me know guys in the comments i am waiting for your responses so yeah so this is one uh column four this is slicing operation let's see some more slicing operation just to make clear things out or just to give you all hang of the slicing operation okay so if i give you a zero okay fine let me just not give anything but maybe i'll just give you a zero here you are saying that start printing things from index 0 and n index is 4 so obviously it will give me the first element second element third element and fourth element okay index 0 element index one element index two element index three element it will stop at three it will not go till four four is end index it will stop at end index minus one that's what we need to understand what this will give me print st if i'm leaving it blank for the start index i'm not mentioning anything guys i'm not mentioning anything in the start index but i have mentioned four in the end index so what it will give me let's execute and see for ourself see it is giving me the same output w e l c so remember this guys whenever you don't give the start index it will automatically start from the beginning it will automatically start from index 0 not only that and you don't give and you don't give the end index it will automatically print till the end of the string it will start from the start index whatever you have mentioned and if you have not mentioned anything in the end index part then it will print till the end from the start index okay please remember this so that leads to this conclusion that if i don't mention the start index if i don't mention the end index if i don't mention both of the stat index and n index definitely it will start from the beginning and it will print till the end so it is as good as not writing anything no no it is as good as actually don't uh not to use the slicing operation we can just get this out same output just by printing st i will get the whole output same thing okay so whenever you don't mention the start index it will start from the beginning whenever whenever you don't mention the end index it will print till the end so when you don't mention both of them so it will start from like it will in short i should say it will print the entire string that's it okay so is it as like it is as good as not using the slicing operation but for this cause so i hope i am clear with this this part everyone i would also like to discuss i'll take the same thing serious guys python also allows negative indexing let me show you what this will give you st of minus 1 it is giving me e what is e e is the last character of the string okay so you can say um it is printing the first character from right side minus one it the minus sign gives you the right hand direction the it gives you the direction from end or from right side okay minus one it will give you it will print first character from right uh innovative flow it is not the right uh time not the right movement not the right platform to discuss multi processing because this is python like a beginner level course essential course three-day course i cannot certainly discuss multi-processing of python here okay i hope you understand and everyone else so do so okay fine so minus one the negative index um um yeah so negative minus one and i write it would give me first character from right side if i use your minus two it would give me second character from right side from end okay i think we should also print the string so just to uh for a reference that's it so st is welcome when i have written st of minus 2 i am getting the second element from the right side or the end so this is how this negative index works guys please have this your mind now i would again go back to the slicing operation okay i want to discuss something like st might it might be zero or you may not when it is zero you can also leave that it is optional when you if you start like if you want to start from the beginning you can write 0 as a start index you may not write anything it means the same thing now see maybe 6 so this we already know what this will give me output so i'm getting welcome w-e-l-c-o-n i'm getting it okay i'm i'll be changing here something guys i'll be giving you one more thing what is this we had just discussed art index we had discussed end index what is this third thing third thing is known as step okay this is step step value what is this step what this will do see for yourself let me execute it so it is not actually giving any uh difference guys so when you are giving step as one basically it doesn't change anything you are getting the same output when you didn't mention when you don't mention one okay let me execute this code and it it would be very clear to you see both the statement even if i mention here one other step they're all like both the statement are giving me same output when would be the difference if i now instead of 1 if i give you a 2 now see the difference in the output what we are getting we are getting wl oh what exactly is this what exactly is this so see guys 2 is step this means to start from index 0 fine because you have mentioned start index is 0 it will stop before 6 it will stop at 5 but now the step is 2 so it will first print w it will take 2 steps one step two step it will print l then one step two step it will print o and uh after it will go beyond the end index whatever mentioned here that's why it will print w l o this is the work of step it would increase like when you give step as 2 it will give you alternate element okay right let me also show you one more example here print if i write your [Music] two so this will print me alternate characters of the string guys so you have not mentioned start index so to start from zero from the beginning you have not mentioned n index which will go till the end but here step you have mentioned as two so what it will do it will skip one one element in between because it will start from this w it will print w one step two step you print l one step two step it will print o one step two step it will print e then it will go beyond the the range of the boundary okay so i hope you understood guys everyone what step is doing it okay what step is doing here i hope everyone is getting under like getting it i hope okay so step here is two so it is actually taking two two steps so it is starting from zero index as we have not mentioned any start index because obviously it will start from zero index then it is to taking two steps because you have mentioned step as two one step two step it will print l then one step two step it will print o then one step two step it will print e after that nothing left you would be out of the range okay right thank you i hope now you could understand because i just explained it once again for you okay here okay now see this what i'm uh trying to do now print st you already know the negative index thing now i'm giving minus 1 as the step we just discuss step as positive now i'm giving minus 1 as the step okay see guys minus 1 step is nothing but it will just print all the characters from the right side from the right direction okay to start from the right hand the right end it will print e then minus one m then o then c then e then w that's how it would print so that's what some of you were mentioning in the comment when we were when i was talking about reversing a string so one thing i just want to say here guys this slicing operation won't change the original string if you print now sp st would still be welcome and not um okay so slicing operation is just actually giving you a version whatever you are saying as for that it is just giving you a version of the string after applying those operation the original string is still same original string is immutable no change in the string you are just printing a reversed version of the string you are printing the string in reverse way okay but the actual string has not been reversed everyone or not understood here okay that's great so this is a difference between that reverse operation what we did and this slicing operation okay that's great someone where you was asking about append of list okay fine let's take one two three three and four i have this now you see guys this is my list and now you want to add another element to the list how can we do it you want to add an element at the end of the list append means adding an element to the end so it's very simple you just go for li dot append and mention the element you want to append now if you print the list original list might have been not my target it would be changed and type is added to the list this is how you add an element to a list guys by using this append method of this okay clear great then i think uh even this append is also clear i think someone was asking about append so this is it guys up and this is what append does for you append method it just adds an element to the end of the list okay so right great now there are many method guys like there is pop what pop will do pop will delete the first element here if you just write pop it will delete the first element actually the list is now one two oh sorry my bad uh it will just remove the last element not first element sorry guys my bad my mistake so when you just use pop it will remove the last element five has been removed again see here okay but technically pop method is used to delete an element from a particular index it is not used to delete an other element on the top so push and pop you might have heard in uh stack concept okay the element which was inserted added recently that would be removed so we had actually inserted five recently the last element is five so when we use pop it would remove the last element that is five okay but uh pop is majorly used to remove an element from a particular location guys or particular index like i want to remove the element which is present at index two so this is how we write okay just my mention the argument as uh two through the past two as an argument to this pop method and that would remove the element present at index two remember guys this is index two and not the element okay this is index 2 got it if you want to remove something if you want to remove an element particular element then you use remove method let's say i want to remove 4 so i'll write i'll use remove and pass 4 so it will search 4 and it will remove that element from the list if you see here see 4 has been deleted so this is the basic difference between pop and remove pop deletes an element present at the particular index as passed by you in the argument remove will delete the particular element that is actually uh passed by you as an argument so pop works with index remove works with the element itself okay right understood great now let's let's uh so we have discussed so many things about the list okay and ohm is again asking about this delete command this is dl nothing but delete command if you want to delete the entire list just write d e l l i uh and it will delete the entire list if you try to print li after this execute it and it will say you this li is not defined li is deleted already there is no such thing called life now because del command actually deleted the entire li guys okay that's what about more or less about list and string guys on string i would like to discuss something okay see this it's very important and also one more thing i would like to discuss you see guys whenever i'm operating whenever i'm applying some uh methods on list i'm just writing li dot append li dot pop uh li dot remove and the changes are actually happening to the original list because we already know that list is mutable so these methods of list whatever if you use these or these methods would affect directly the list the content of the list would get changed but this is not the case uh when you are using string okay so if you are using any methods of string like we are already discussing join or maybe uh maybe there is something called i i want to discuss a script okay so this split when you apply it will not change the original uh string let me just show you here okay split will just return something for the timing just assume that it will return something whether it would change the content of the original string that's what we need to figure it out so that is why after split operation i am again printing the same string as t and c for yourself as i have not actually there is no change in the original string st because thing is mutable okay because string is immutable that is why there will be no change here there will be no change here on the uh string so i see to be very honest there are other methods also of a string and list you can explore it uh it's not not much of a rocket science okay um we are pretty much good with the things which are very which are required and very important okay right you can rest of the things you can explore by your own you can check out the documentation of python okay you can check go to the python website and check the documentation a small small things guys are like most of the things the important thing we have already discussed this is split is very important that's why i picked it let's understand it let's understand this let's understand how it actually works what we do with split but right now we discuss that when you apply any method on string this way the string doesn't get affected okay right but when you apply an e method on list it actually changes the original list because list is mutable so list is getting changed but string is not getting changed that's what i wanted to make up like that's what i wanted to make a point here guys just remember that keep that in mind original string would not be changed whenever you apply any method now let's understand what split is doing i'll give a space here actually now i don't want to print this thing you guys what it is doing it's still giving me hello okay even if i'm mentioning something here so let's don't let's not mention anything let's not maintain anything let's try to understand what it is doing if let's say i have certain values uh him maybe welcome to python program i've written this now let's apply this split let's see what it is doing as you can see here guys it is giving me a list containing each word of the string that's what this split does okay that's what this split does so split splits the entire string at spaces so it splits here welcome is separated two python program is separated okay then again it's splitted here at this space so two is separated program python forum separated then it splits here so python is separated and program is separated so this plate actually splits the entire string into a list of elements and it splits at spaces guys okay it splits our spaces by default it would split at space but you can also mention that what you want to uh uh split like let's say instead of this i have dollars in between inter space i have dollars in between so you would like to split at dollars right you would like to split all the dollars so here you can mention dollar i want to split at dollar so let's split like uh just pass the argument as dollar and see you are getting the same output so it will split at every dollar here got it guys so this is split for you this is split and this is what split does but don't think that the original list is getting changed guys original list is still the same no change absolutely no change in the original string not list string it's still same welcome to python program with that dollars symbol okay right we'll do that later mari this is not the right class we'll do that in the next class okay don't worry about it get it got it so okay i hope everyone understood what split is doing because i'll be using this split next for a particular use case is it clear this is the is the use of split clear to everyone please mention me guys please mention me because i'll be using this uh uh split in use case mari next class is tomorrow same time okay great great then so let's use it i will be discussing here how to take multiple input right now and that's where i'll be using this bit and all so it's very simple let's see a variable is x i want to take multiple input here so we all know how input method works so i'll just write your enter the values okay and here let's say i'll just write print x because i'm storing input in x let's prove it so it would obviously ask me to enter the values let me take 10 20 and 30 and 40 and 50 for example if i hit enter i'm getting 10 20 30 40 i'm getting fine okay so i'm able to take multiple input here but actually if you check the data type of the variable x it will give me string okay so let me take these values 10 20 30 40 50. and see here it is actually string type we have not got i have not taken uh five integers rather this whole thing is a string entirely this entire thing is taken as an input as a string guide but what was our intention our intention was to take five integer input type multiple input so let's see uh let's see actually uh how to do it let's see uh how to take multiple input here see so this input now we know that this input is taking this entire thing as a string so this is a string guys so on this string i'll apply split so what it will do if anyone want to check uh there is already this print text let's check it out what this will now what is x let's uh let's understand here 20 and 30 and 40 and 50. now it is a list guys containing string 10 20 30 40 50 as element so we already know how split works okay the same thing here here we have applied split on the input string we have taken so now we have uh different element but yet we don't have those individual element as integers rather we have those as what is that string we need to convert convert each of those element of the list into integer that's what we have to do right okay vikram the next class would be tomorrow same time 8 pm now see what i'll do here now what i would like to do is i will iterate over that list x okay i'll iterate over the list x and for each of the element i want to convert that in uh convert each of this element i into integer also i would be storing that in a list that's what i would do so for that i'll let me let me take an empty list okay let me take an empty list and here i will always append the element i'll be getting by converting i into integer yes yeah so for i in x what is x we already have seen what is x so x is nothing but the string input which we have taken this may be this 10 20 30 40 50 this entire string we applied split over there so when we applied split now x is containing this list okay 10 string 10 string 20 string 30 string for testing 50 individual element now what i am doing is i am iterating over x that means i am iterating over this list first i is 10 then i is 20 then i is 30 then i is 40 then i is 50. for each value of i i am converting this string element into integer and i am then adding that to a list so after the whole process if you print the list you will see all those elements which we have taken input as string i that would be stored in the list as individually as integers okay see we have integer 10 we have integer 20 we have integer 30 units of 14 inches of 50. so we have successfully taken multiple integer input okay so we have successfully taken multiple integer input guys um but yes let me show you python way of doing this i won't be writing this many lines or taking multiple input i'll combine all these lines into a single line and how it is actually let me write so first of all this input whatever we had okay that is fine enter the values and i'll be applying here split through it so after applying spit this entire thing is uh this entire thing would become a list so on that list i would iterate and for each of i i want to convert that i into integer okay and finally everything as store within a list and now if i if you print x you would get the same result guys that we done in the previous code okay so all those stuff whatever we did okay up to this all this all this part all this stuff we did what we did that is being done in this same line single line okay right so this is a more of a pythonic way of taking multiple input okay but we have done the same thing whatever we did this before we had done the same thing only thing is we have just combined everything and written the same line can anyone say what is this called as this operation or this way of doing it can anyone say what operation i had actually done here can you mention here what operation that is called as this particular thing guys this particular thing which i have done we understood what it is doing we understand what it is doing but what this operation is called as can anyone mention in the comments lambda is saying this is lambda not not definitely not this is not lambda yeah yes uh yeah uh fallen gaming uh yes exactly this is list comprehension this is comprehension and we have applied comprehension on list okay so this is list combination guys exactly correct very good this is list comprehension so this is very powerful this comprehension list combination is used in many places guys even if you go for your data analytics or something this compression is heavily used and you should be uh you should have an idea about comprehensions this is an example of list comprehension this is how it is used fine okay so now we know how to take multiple input now we can do some other problems based on this okay so if you want to do problem let's also uh discuss somewhat uh about uh other data types quickly and move forward to the control structure like loops and all and we'll be will be solving one problem for that regarding that okay so quickly let's uh discuss what is tuple apple is very similar to string uh sorry very similar to list guys apple is also collection of some elements separated by comma and enclosed within this uh parenthesis actually okay so you can print the tuple same way you can also check the data type of this tuple same way it will give you a dive as class couple okay yes this is tuple 10 20 30 40. got it guys understood so list and tuple very much similar you do the same thing you enclose within square bracket that is a list you enclose within parenthesis that is a tuple okay also guys make sure also keep this in mind even if you don't give any parenthesis this would be considered as couple okay by default even if you don't mention the parenthesis it would be considered as tuple not list please make sure so please be sure uh while using it uh okay so when you don't mention any square bracket or parentheses this should be considered as couple got it so same thing guys even tuple has that indexing thing so if you want to print element at index 2 so you can write of the name of the tuple and mention the index yes i'm getting 30 30 is present at index 2 index 0 index 1 and index 2 right ok but you cannot change the content of tuple just like string list we are able to change but tuple we cannot change let's say i want to store your 100 at the first place like i want to replace 10 with 100 can we do it let's print also it will be change and we should also see the updated tuple right that's what i am doing here and it is giving me error it says tuple object does not support item assignment just like what we were getting in string okay right so tuple is also immutable guys list is mutable string is immutable so whatever we have discussed already till this point list is mutable integer string tuple these are new table okay got it so that's what about apple and if you ask me about methods of tuple there are not much method in tuple actually we just have two method one is this count and one is this index which you already have seen in list which we all this we already have seen and this works same guys count method will give you the count to the number of occurrences of an element index method will give you the index of occurrence of that element that's it same same way it will work okay if you just want an example i can surely give you here let's say couple i have some elements here okay okay this is too much this is fine so i want to give a take a double here uh maybe 2 5 1 3 5 2 okay maybe this and i want to hear count so print triple dot i want to count the number of occurrences of two here okay something happened okay now so i want to see the count the number of occurrences of two here that's what i have done um okay and let's say i want also i i want also to print the index of some element cube dot index of maybe three or maybe yeah three that will be three okay it works similar to whatever we have discussed guys in the previous like in the list okay it works similar count will give me the number of occurrences of the element that is how many times two is present in the tuple okay and index would give me where three is present at which index so 3 is present at index 3 and 2 is present two times in this tuple given tuple so this these are the two method which we have in tuple okay right so one built-in function i want to discuss you guys that is length it is an universal function like built-in function which you can apply on list or tuple or anything so what this would give you is it would give you the number of elements in the top length of the not only tuples if you apply on less it would give you the length of list if you apply on tuple it will give you length of tuple okay basically the number of elements in the tuple but here i am not getting it i think i have used wrong uh that should be alien not length my bad guys alien so if you use len function building function len it will give you the length of the tuple how many elements are there in the tuple so as you see here there are seven elements here in total that's why we are getting seven as the output okay right understood so this is how you can check length how many elements in the list how many elements in a couple so this is about uh tuple guys we know tuple is immutable double indexing can pos is possible in tuple so there is only two method count and index and we discuss about length built-in function also fine pretty much good let's now discuss about other data type uh that is set i'll quickly discuss what is set it is nothing but its same thing like we have some elements some some elements separated by comma but enclosed within uh curly braces okay i don't name it as the scp reset is the data type let me just take s okay also i would like to print the data type just to make sure whether this is set or not and see for yourself guys yes this is class set this belongs to class set this is a set data type and these are the elements 40 uh like 10 20 30 40 50 i have stored you might notice here one thing when i printed this set i am getting 40 10 50 20 30 but when i had created i had mentioned 10 20 30 40 50. okay so the reason here is the reason here is set stores elements randomly okay set your store randomly in the it store element randomly guys so there will be no particular order in which the element would be stored randomly it stores so when it stores randomly also indexing is not possible okay that is quite understandable right so when it doesn't maintain any order of the elements obviously indexing also not possible so in set index not possible elements are stored randomly also one more point see here be the output of the set how many elements i had stored seven how many elements it is showing me 50 uh sorry five five element is showing so the reason behind this is set does not allow duplicate values it will store only unique values guys please make sure this like even you remember this okay please remember this please remember this so set does not allow duplicate values it allows only one like unique values okay so it doesn't maintain any order it stores randomly so there is no indexing possible secondly um only unique values are allowed no duplicacy allowed in list tuple we can store duplicate values but inside we cannot store okay so set is a collection of unique values separated by commas and enclosed within this curly braces that's that's what this set is okay this is more or less more like more or less what you have studied in your mathematics guys said same thing here we will shortly see some operations offset but i would answer one question i think someone had asked me how to create how to store one element in a tuple so yeah that's a good very good question thank you for raising it also so guys you might think that i'm just like i'm not going jumping here and there i just saw that question so i'm answering it so that everyone would be knowing it and not get confused so when you want to store one element in the tuple or let's say if you want to create a list with one element so it is not a big deal you just write 25 and enclose within a square bracket but when you want to store one element in a tuple okay and you see here if you print the data type of the tuple not get couple actually you will get you'll get integer rather because this is not the correct way to uh store one element in tuple remember this guys whenever you want to store one element in the tuple you have to give a comma okay just mention a comma after that now this would become a couple otherwise it would become an integer please just be aware of that stuff here everyone i hope uh like i've answered this whoever asked om if you know something then don't just uh ask and waste time okay you are you are questioning also you are answering so that doesn't like go well with the class or it will just waste our time yeah just something important you take up that's fine okay great so yeah i was talking about set guys yup set is very similar to whatever you have discussed already in your classes you know mathematics classes so i'll take two examples here like two sets here so maybe one two and three okay maybe i'll take four and five also and then i have another set which contains three or maybe uh not three four five six seven okay see this instead we have studied in mathematics this union operation intersection operation the subset superset superset thing let's also do those stuff here guys how to do union it's pretty much straightforward it's very easy just use this pipe symbol the or symbol or operator and you uh apply it s1 or s2 it would give you the union of this to set i hope everyone knows what union operation is on set okay so this will give you in a union operation right it will combine both the set obviously it will not have duplicate values it will just have unique values what about intersection intersection is just use this and operation operator and it will give you the intersection of those two set and intersection means the common element yes we have common element as 4 and 5 that's what we are getting and then we also know set difference operation so if i write s 1 minus s 2 guys if you don't know this operation please brush up your like this mathematics thing a bit okay i won't get into the mathematics part so i'm just showing you how you can do that operation here in python so s1 minus s2 it would give you the result of set difference okay right from s1 whatever we have common in s2 that would be removed so four five are common so that will be removed so you would be left out with one two three so this is set difference so we have discussed set union we have discussed that intersection we have discussed that difference okay fine great now uh i was also talking about uh super saiyan and subset right okay fine so what is super set 20 super set what is subset i think you all know what superset means what subset means okay if i say s1 is subset of s2 please mark my what if i say s1 is subset of s2 then all the element of s1 is present in s2 okay got it guys if s1 is subset of s2 then all the element of s1 is present in s2 or in other sense i can say s2 is superset of s1 got it if s if i say s2 is superset of s1 then s2 contains all the elements of s1 and s1 is superset not over mari it could be discussed tomorrow got it so i'm just taking some random s one here um one maybe two maybe three okay then i am taking s2 i'll take one two three five six i want to check whether s1 is subset of s2 how can i check here just use this and this will give you true or false guys this means s1 when you are checking s1 less than s2 you are basically checking whether s1 is subset of s2 and yes it is true all the element of s1 is present in s2 that means s1 is subset of s2 okay so if this holds true obviously if this holds true then obviously s2 is super set of s1 so how to check for superset example you can check s2 greater than s1 like you can use this greater than symbol and it will give you true yes s2 is superset of s1 but if you check s2 is subset of s1 then obviously it could give you false s2 is not subset of x1 s1 is subset of s2 because all the element of s2 is not present in s1 got it so this is these are the set operation guys which um um like which which are important in this uh set topic okay i'll be doing one uh problem a good problem here just to uh tell you the use cases of this uh set whatever we have discussed so let's now do a problem guys a very good problem that is input a string like take input or string take a string input take a string input and check whether okay so whether it is uh anagram i hope everyone knows what i'm gonna miss can anyone say what pan gram is have you ever seen a pan gram guys take a string input and check whether it is a pan gram okay that will be posted there don't worry if i don't tell in within the session then that would be surely posted in the community don't worry about that just answer me this one uh i haven't heard paragraph have you ever seen pandra you might have seen if you have worked with the font okay in microsoft word or maybe um power presentation or something you might have seen the font when you choose there is some statement shown there and that statement is nothing but this should be the statement you might have seen uh okay that statement is a quick brown box jumps over the lazy dog this is an example of pangolin advice so what basically panda means a string which contains all the alphabet from a to z that is a pan graph okay so pangram is a string which contains all the alphabet from a to z that's what is a pangram so what you have to do is you have to take a string input and check whether the given string is a paragram or not okay right understood fine how to solve this question first of all let's take the input guys it's maybe s so input enter the string okay right then let it check whether the string contains all the alphabets or not i am writing something here don't worry about it i'll explain it let me just finish writing i'll explain each one of them okay anyway in the next class also we'll be discussing in detail this thing there is a built-in module guys okay called string there's a built-in model what module is so models are predefined uh programs you can say where many functions are written or so many things are already given to you so python contains so many of models and libraries already defined there so you can just use it in your program in order to use it you have to write this input so there is a module called string the name of the module is string it is a predefined model guys and you want to import it here because you want to use the features or the properties or the things mentioned defined in the string module okay what are the things i want to use here okay i want to use something called so ascii letters right let me check it out let me print this alpha and we will get to know anyway it will first ask me to take the input actually because that is what we have done so maybe just take it and as you can see here see what we are getting guys abcd up to z and uh abcd of the capital so when i say here string dot ascii letters it is giving me all the alphabet letter but do we need all the like all the uppercase and lowercase see guys doesn't require that all the alphabet both in uppercase and lowercase would be present no all the alphabet should be present doesn't matter if it is present in uppercase or it is present in lowercase okay not palindrome pan gram i'm talking about pan gram not palindrome so we don't need really this uppercase and lowercase so what we will do is we will just take lowercase you can check this string module guys there are many uh thing available so i'm just taking the lower case alphabet from string module i don't want to take input or write a b c d e f g h so instead of that i'm just importing the string model and using the lower ascii lower case property there okay just to have all the letters abcd up to z stored in this alpha okay so what i want to do is the string which i have taken i want to convert that into set the string which i got here like basically the alphabets i want to convert that into i also want to convert that into set okay right so let me print both the string and the like alpha after conversions then only you would get to know what i am trying to do here okay you see whatever we have studied at this moment up to this moment i'm using all of them actually so yeah let me take your welcome and see guys okay so that string converted into set and this letters alphabet from a to z this is this is also converted into set so now we have two set okay one is containing all the characters of the string we have taken and one set this alpha is containing all the alphabet so we just need to compare this to set and comparing two set is very easy we just have discussed we just have discussed guys will say if s is a sub okay not subset if alpha is subset of s that means if all the elements of alpha is is present in s that means all the alphabets a to z if it is present in s then s is a and gram otherwise it is not that simple is it okay else print not with this guys also see the syntax of writing effects in python let me execute it once okay let's see it first whether this is correct or not so yeah welcome it is giving me not panel of course welcome is not pan-gun because welcome doesn't contain all the alphabet from a to z let me execute it again and let me take that uh string actually a quick brown fox jumps over the lazy dog will this work okay will this work that is my question what do you say will this work guys if i hit enter so uh it is giving me pangram okay yes it is give me paragraph because this string this contains all the alphabet from a to z so basically this is subset alpha is now subset of this string s all the elements of alpha is present in s that means all the alphabet a to z is present in s that's what we needed to check if s contains all the alphabet from a to z and here it contains so that is a panel that's how uh like it is to check whether a string is panning or not in python guys you can use the feature of set here and solve the question it's a very good question actually and we have here used type conversion we have used the property of set we have also used here the decision making or the if else okay conditional statement guys so this is how you write infills you don't you can if you want you can mention here the parentheses but it is not required in python you can just leave it please do remember please note here you have to mention a column there is no curly braces to open a block or close to block close a block you have to mention a column okay just to open a block and maintain this identity uh so with the indentation if you write here then it is wrong if you write here then this print panoram is not part of the if okay it is not within if it is outside it so put proper indentation now this print panoram statement is within if guys okay then this is else you put again a column so now a new block open and this print not pangram is within else so this is if this is how you write effects clear great understood everyone okay please confirm so basically we are done for the date i'll not extend the session anymore we would again meet tomorrow we'll discuss about this functions okay death function as per you so we'll discuss that we'll also discuss some more things guys in python tomorrow in the next class okay tomorrow it would be a very good session it would be like more interesting stuff so there are all those who are asking about where to upload the assignment please check the description of this video there is an assignment submission form link you click on that open that form all the instructions are also mentioned there how to uh submit the link you have to anyway you have to submit the assignment in the same form but there is a video please watch it once okay got it you can uh write guys you can just google open a google collab write the code and uh submit the link for the google pull up that's also that that will also work assignment i would post it in the community guys please check it after some time maybe after half an hour one hour please check the community i'll be posting in the community okay right you can upload you can give collab link google collab link as an assignment submission guys okay that's fine completely fine okay so so we are done with this session let's call this a day let's stop here and we'll again meet guys tomorrow at same time 8 p.m and we'll discuss like some advanced concept like generators and all we'll also cover decorators that's very important anyway we'll cover this quickly i'll finish off like we'll discuss modules and we will discuss function we will discuss some advanced concept like decorators and generators tomorrow so don't miss out tomorrow's class it's very important and i would also be doing a mini project tomorrow that would be the final assignment submission from your side guys tomorrow that's what i'll be done i'll be doing that please do not miss tomorrow's class tomorrow class would be very interesting so thank you everyone for uh joining in thank you today's assignment i'll be posting in the community do check out after some time maybe half an hour or one hour i'll be posting it anyway you have deadline guys you have deadline till uh 24th okay 24th yeah 24th 11 59 pm before 25th you have to uh mention okay you have to upload the assignment you have time don't worry about it i'll be posting the assignment in the community tonight within half an hour or maybe one hour okay so uh today's session link you're already in the youtube uh uh it's the same video you can check back you can store this uh link okay same same okay fine then great guys thank you everyone for joining in let's again meet tomorrow tata bye take care guys keep learning keep learning
Info
Channel: LetsUpgrade
Views: 3,112
Rating: undefined out of 5
Keywords: Certification, Essentials, Batch 1, LetsUpgrade, Certification program, E- learning, career, course, Technology, upgradeskills, Python, May2021, developer, batch1, Django, Project, Doubtclearing, django, python project, python project tutorial, python project for beginners, py, Python for beginners, Python from scratch, learn python basics, Python basics
Id: qA6cgi671iI
Channel Id: undefined
Length: 97min 35sec (5855 seconds)
Published: Fri Aug 20 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.