hey guys welcome to great learning python is seeing a huge uptrend right now from the start of this year right now if you've clicked on this video i am sure you're looking forward to learning and understanding some of the most important questions in python that have the highest probability of being asked in your python interviews right since python is a programming language which has a really vast scope it becomes key that you actually spend a good amount of time preparing to tackle even the most challenging interviews that are out there now keeping exactly this in mind we here at great learning have come up with this comprehensively put together python interview questions right we have 100 questions that should help you work towards acing your interviews and of course also help you towards getting to your goal as well now the questions are broken down into three categories beginner advanced and the most important part where we will also be discussing are the tricky questions at the end of the session as well so make sure you guys are watching this from the start all the way to the end to make sure that you are covering all the beginner questions the advanced questions and also the tricky questions right with this guys i know all of you all are super excited to get started with this what are we waiting for my name is anirudh rao let's get started since you're starting this video you are clearly preparing for your dream job so before we get started i have something exciting for you if you are finally a student or a fresh graduate with less than one year of job experience great learning brings you this unique job readiness platform called carrier plus where you can apply to 400 plus corporate hiring companies sounds exciting complete this video and check out our platform carrier plus where you can quickly take a job eligibility test pass it and apply for the relevant jobs if you do not score well don't worry we have your back you can prepare from our specially designed courses and take the test again to improve your score before applying to jobs more than 500 000 students from 2000 plus top colleges chose us and secure jobs paying up to 10 likes per annum so why wait check it out and join for free today if you haven't subscribed to our channel yet i want to request you to hit the subscribe button and turn on the notification bell this is done to make sure you do not miss out on any of the new updates or video releases from great learning and of course guys if you enjoy this video show us some love and do like this video knowledge increases by sharing right so make sure you share this video with your friends colleague and everyone who can make use of it and at the end of it make sure to comment on the video if you have any queries or any suggestions and i'll be more than happy to respond to all of your comments all right guys so to talk to you about what it is that we're gonna cover in this agenda as i just mentioned as well in this top python interview questions 2021 edition we are going to be covering 50 questions meant for beginners again these are basic questions but at the same time these are also tricky and equally important even though you might be an advanced user right once we cover the first 50 questions we're going to be taking a look at 20 more questions this is going to be slightly advanced so if you're preparing for interviews where you have a couple of years of experience this will help you a lot to progress right now regardless of beginners or the experienced users the third section where we are discussing 30 tricky programs right this is where be it you're a beginner or an advanced user you'll have to pay a lot of attention because these tricky programs are the ones where people will stumble uh in a python interview now the end of the goal of this video is to make sure you guys do not stumble on any tough question that might be asked in your interviews that's the reason we present to you this hundred question list and eventually all these questions not only consists of theory but theory practicals and explanation that goes on to tell you about how the code works why it works the way it does as well right so make sure you guys are watching the entire thing all right guys on that note we can get started with the first 50 questions which are uh you know the beginner or the basic fundamental level so what are we waiting for let's go with the beginner questions first all right guys coming on to the first question now we really have to start out this interview questions by talking about the key features of python python is a very powerful programming language and that is something which again the entire world accepts right so understanding what makes python really powerful and popular is something you should know offhand now here are some of the really interesting features that you may or may not know in case if you're preparing for an interview uh regarding python right first of all ladies and gentlemen python is absolutely free of cost right it's completely free to use and of course since it's free to use it has to be open source right it gets contributions from all around the world now take a look at the second line you're saying that it's an object oriented language well of course yes python treats all of its uh entities in the programming language as individual objects classes and so much more so the entirety of support for object oriented programming is there and that is a huge advantage to python right and of course the third point should be attractive to all of you all right now because python is a fantastic language which is super easy to learn it has amazingly clear syntax and really good readability if you have to directly compare it with something like c plus plus or maybe python the syntax is so similar to english language in python compared to c plus plus that you definitely feel like python is the easier option right and of course since we're talking about programming we're talking about coding writing code and fixing errors is going to be a process as well along the way now with respect to debugging you have to be really careful and here again python takes care of you because uh as an interpreted programming language python is super easy to debug and work with right and if you think that's all the advantages are look at the last point python talks to other programming languages like c plus plus java and it can work fantastically well in line with those particular programming languages right so you can have a combination of multiple programming language if you have an application or requirement that asks for that and of course eventually it will work as expected right so this is a very important question right now coming to talk a bit about python ladies and gentlemen the next question states what are keywords in python now keywords are a really important concept these are the reserved words which are used for things such as identifiers such as function names and so much more right now you cannot use these words for your own usage to be very clear in python right now in the version of python 3.7 and as and when the versions go on they might add more and more keyword but the generalized look on this is that we have 33 keywords here now some of these keywords include the word false none true break if else return continue define as in def right so all of these keywords these 33 keywords you really cannot use it maybe for another purpose such as a variable maybe you want to create a list using the name right now i cannot have a name of a list or a tuple and call it true it will absolutely not work because those words are reserved they have a separate meaning of their own separate usage on their own right now guys this is something really really important that you should know about right you have to know that there are 33 keywords and you will have to put out somewhere around three to five examples to showcase that you are familiar with these keywords as well right yes even function names cannot be used now that is one thing i'm sure you would have thought about in your mind right now can i have a variable and call it print well you cannot because print has a completely different meaning maybe then compared to what it is that you are trying to achieve as well right that you have to keep in your mind fantastic coming on to question number three what are literals in python ladies and gentlemen literals again as the name itself suggests refers to all the data that we put in a variable or maybe a constant as well right now in python the interesting fact is that there are four types of literals we have string literals numeric literals boolean religious and of course special literals as well string literals is something as easy as my name for example my name is anirudh rao right if i just put it in a string format well that's a string little on its own take a look at numerical literals right now numerical literal talks about numbers we have integers floating point and complex numbers now integer an example is 1 2 3 4 minus 1 minus 10 anything for a float we need the floating point number so 3.14183263 now that is a floating point number 1.9 that's a floating point number right and of course we have complex numbers of complex numbers will have one real part and an imaginary part the imaginary part is usually denoted with an i i'm sure you might have learned about it in school or your college right and of course boolean has to speak for itself ladies and gentlemen it's either yes or no true or false zero or one it's always a binary outcome and it is never anything apart from this right and special literals now special literals also have a meaning to them because if you take a look at an example the word none right now you cannot just say even though having the word none may or may or may not make sense but in some cases having the word none instead of leaving something empty or leaving something unattended is a hundred times better right now as a special literally trust me none is a fantastic one and always whenever you're stating examples make sure you try to uh you know state examples like this so that they know uh the interviewer understands that you are proficient in all these concepts right fantastic now let's move on to question number four question number four states how can you concatenate two tuples now ladies and gentlemen concatenate basically means to join two tuples right now we already uh should know what a tuple is at this moment of time so i've given an example on your screen right now we have two tuples tuple one and tuple two right now a simple operation of concatenation is to basically add a plus sign in between tuple one plus tuple two will give us an answer where all these star elements from tuple one and tuple two get combined one after the other and get appended right two gets appended to one now since we're talking about code it always adds a ton of value to check all of these out practically right now throughout this entire interview questions sections guys uh we are going to be taking a look at a lot of uh programming concepts as well because at the end of the day since it's a programming language you really need the expertise right now if you have your laptop and if you're sitting in front of an interviewer it always is an advantage to quickly open up a jupyter notebook and type in a small code snippet and show showcase to the interviewer that it works right so let me quickly open up google collab now google collab is basically my choice of python jupyter notebook right now you can have uh you know any other jupyter notebook of your choice and it would still work right fantastic now let me zoom in so that all of you all can see this right ladies and gentlemen this is question number four question number four as we just discussed is how do you concatenate two tuples and as i told you we have two tuples here tuple one and tuple two now printing tuple one plus tuple two will basically have tuple one of the first and tuple two at the end right look at this this is from one and this is from two but what if i want to change the order what if i want tuple two to come first and one to come later right it's a very simple thing all you have to do is just put it in the particular order plus just uses it to append right now let me just make this first one as a quick comment and uh the second one as you can see says tuple two plus one now as soon as i hit run it should basically give me four five six one true well there we go this is how simple it is to concatenate two tuples right you really don't have to break your head with respect to all the other methods or uh you know so many different things that you can think of while uh having a very simple plus operator that does the task for you right fantastic coming on to question number five ladies and gentlemen question number five states what are functions in python now functions in python are really really important because python's popularity comes from the immense amount of libraries functions and these easy to work with tools and techniques that python provides right now to talk about a function in itself function basically is a block of code which is completely organized and it ensures that if we ever need the logic that is present in this block of code we can reuse it any number of times that we want right you can call it in different ways you can send different parameters to it and of course it's just a same piece of code which will work maybe for 10 times if you have written a logic to multiply two numbers right you don't have to do it every single time just have one function and just keep sending in two or three values four values five values well hell if you want to calculate the multiplication uh for thousand numbers you can do it with one click of your mouse button instead of writing and typing it out a thousand times that is the most important thing about python right first of all you're shortening the code and reducing boilerplate after that we are also making sure that we creating modularity in the programs the program is being broken down into smaller understandable chunks now if it's smaller understandable chunks it is always an advantage regardless of the size of the program right so that is something you really have to think about well and another good thing to answer while you're asked this question is to make sure to give one or two examples as well now there are two types of functions in python we have the built-in functions and the user-defined functions give an example for a built-in function right think of print print is a fantastically simple function i'm pretty sure it'll be the first ever function you would have used when you're learning python right because we use that to type hello world right now that's a good example now if you're talking about a user defined function what you can do is you can say hey we're going to use the word def def def to actually define our own functions if required now even though the question says what are functions if you actually given a tiny detail such as this the interviewer is definitely going to be impressed right so guys use this approach throughout as well now coming to question number six ladies and gentlemen question number six states how can you initialize a five cross five numpy array with only zeros now i am sure at this moment of time you would know how to uh initialize a regular five cross five array right the two things you need to prepare for is the addition of maybe random values into it or the latest trick question that is popular around the interviews is how do you fill it with zeros now to do this you can actually do it a manual way and a fantastically easy way by making use of a function that numpy provides called as zeros right zeros is a function that gives the exact fight crossfire output that you see on your screen right now on the right hand side right now that we know this uh in a theoretical fashion i think it's high time we take a look at this practically as well right again taking you back to google collab let me scroll down to question number six which is the one that we are discussing of course since we're using numpy the first thing that we always have to do is make sure that we uh you know import the package in itself right because if i comment this and if i've never imported numpy previously in the jupyter notebook i am actually going to get an error now right look at that it says that hey i cannot understand what it is that you're seeing because the function belongs to numpy now let me change that back and hit play again and now you will see that uh you know we have used np dot zeros and of course five comma five denotes a five cross five matrix right now look at this we have an entire uh numpy array filled with zeros and all we had to do was use this logic that is it right it's as simple as that but the question seems really complex to begin with right fantastic now moving on to question number seven question number seven is 100 going to be asked ladies and gentlemen because libraries such as numpy and pandas are literally the heart of python they are super popular they are used in all of the different domains so even though you might think that hey aren't pandas and numpy extremely popular for data science well yes they are but at the end of the day if you want access to really good two-dimensional data structures pandas and numpy are brilliant so what is pandas well pandas has to be my favorite library in python it is again an open source library which is of course free to use it provides a ton of data structures for any database operations that we have now the two really really important data structures that will help you handle large amounts of files with uh you know a good amount of ease you will never feel like you're handing a large file up that is because we have two data structures here ladies and gentlemen it's called series and it's called data frames now series and data frames are absolutely fantastic in fact if you're solving a data science project uh your data set can be a data frame 99 of the time it's a data frame if you want a single dimensional data base uh you know a place to store your data then you're going to be using pandas series data type right fantastic again when you're asked what is pandas just don't tell them what it is uh you know just showcase that you know a little bit more about pandas by talking about its data structures for a second as well right fantastic now as soon as you answer that question there is a very good chance that the interviewer might ask you a follow-up question and say okay so what are data frames then well now that you're now that you know that the question might arise well here is the answer to that right data frames are basically mutable data types that are present in the pandas library ladies and gentlemen when i see mutable you can change of the data that is present in the same file right and of course if you're talking about data frames you can uh store any sort of heterogeneous data that you want uh in fact you can store multiple types of data and it is super super popular uh in the world of data science as i just mentioned now in data science what we usually use are to import a data set is this one beautiful function called read underscore csv right now this is a pandas function so uh instead of just say hey this is how we would do it let us actually head to google collab and let us take a practical look at it right now uh if i run this i am going to get an error it's like okay where is the csv file that you're trying to access but what i will do is i'm going to upload it right now give me one second here let me just quickly go to uh files data sets i can have any data set that i want ladies and gentlemen i'm just opening one just to showcase for your reference as well right now that that is uploaded as soon as i rerun this tiny piece of code now it gives us an output right let me zoom out a little now look at this this is basically us printing out uh us importing the data set and us printing out the first five rows now we'll have another question where we're talking about head but for now you have to understand that the default parameter for head is basically how many rows well you can go on to guess it because it's actually uh you know five rows as well right so if you want now you might be saying hey i want 12 rows to be printed well past the argument 12 and at the end of it you can see that 12 rows 0 to 11 are printed for you as well right so this is literally as easy as this ladies and gentlemen fantastic now that we're done with data frames let's take a look at pandas series uh this question can be asked in the reverse order as well right if you mention series and data frames uh instead of data frames and series they might just ask in the same order so let's cover basis on these two and let's ensure that we are clear with this concept right now a series is different from a data frame because the series only provides support for one dimensional data structure storage now when this is uh of the type that it's a one-dimensional data only uh there could be a question that says hey isn't it inefficient well it's not the talk about inefficient if your project only requires you to have a data structure unit which would uh support one dimensional data why would you want to complicate things with the data frame right so with again pandas uh series and both data frame supports multiple different operations and it is extremely popular for a single dimensional data so if they ask you a question saying for single dimensional data would you pick series or data frames at the end of the day you can pick both but the most popular one the simple one the hammer on the nail is basically series right so make sure to answer it that way and now of course we have to take a look at series so let me quickly scroll down to this particular part now let me zoom in a little all right now ladies and gentlemen what is the panda series we just check this out uh the first line has to be import because without this you know that we're gonna get an error right now look at this we have a couple of elements here in data one two three and four now two of these are numbers is an integer this is a string this is a string and this is a floating point value right now what are we trying to do here is basically create a series out of this particular data and eventually we're going to print out the series after creating it and to verify that it's been done we're also going to use the type function to print what type it is it's supposed to say series there right now as you can see 0 1 1 2 2 3 3 4. fantastic it works 0 1 2 3 is basically the order it's an index 1 2 3 and 4 is what we require this is a string this is a string these two are uh integers right now take a look at this particular thing it says class core series dot series now what this is telling me is that hey we took data and we basically made a series data structure out of it and yes as you can see this is one dimensional data right fantastic guys now let's quickly take a look at the next question the tenth question that states what is the use of pandas group by function now the group by function in pandas is super super popular because it will give you the functionality of splitting and grouping together an object this is a very common operation that you will be performing a lot if you are working hands-on with a lot of data right similar to like sql mysql beat the entire working of even oracle group by you know mysql is a part of oracle of course so uh how these sql group by statement works right it basically groups the data by its classes and entities which eventually you can use later for any sort of uh convenience that you would want and that is one advantage having the functionality in python to achieve something that sql does in a fantastic way in a structured way is what we are looking after right so let's actually head back and take a look at uh what is the use of pandas here right now ladies and gentlemen i have a data frame in front of you pd dot data frame is the syntax to have a data frame in this data frame we have two entities uh one we've called it as vehicles uh as in uh we have car manufacturing companies and a couple of bikes as well we know kia's famous lamborghini ktm rc 390 is a bike pulsar 200 ns is a bike as well now what type are these vehicles right so uh kia is a car lamborghini is a car and of course ktm and pulsar are the motorcycles right now let me go on to print this using just this clause of where we have given it a type you can see that we have grouped it with respect to uh uh you know the names but have we used the group by function here well we haven't right where did we use it we just created the data frame and created two dimensions in it right now where is it well look at this next line i just wanted to execute it previously to show you the difference as well right now after you execute the group by statement ladies and gentlemen take a look at this right it says hey there are two cars and two motorcycles based on the type right if i ask the question saying hey i want to group by all of these details in my sql table and i wanted to be group by type i want all the bikes on one side i want all the cars on one side now that is literally what we did using uh pandas and in a fantastic way right look at this this is basically one single line of code that does what a complete sql query would do for us that ladies and gentlemen uh is the magic of python right fantastic now coming to the eleventh question the eleventh question states how to create a data frame from lists right uh we know how to create lists we know how to create data frames but can we create a data frame from a list now that could also be the way the question can be framed as well the first answer can you create of course yes we can create okay next is how do we do it well we simply take an empty data frame and we add the lists as individual columns in the data frame and we are done right you're going to require a list you're going to require an empty data frame and eventually you're going to be adding all the elements of the list to the empty data frame in the individual columnar form that is all that it takes two steps right let's check this out practically now as you can see we are creating an empty data frame and of course we have lists here one states bikes bajaj tvs honda kawasaki and bmw and of course we have the cars as well lamborghini maserati ferrari hyundai and ford right these two are the list now here is where all the magic is happening ladies and gentlemen df of cars equal to cars and bikes equal to bikes all we're trying to do here is to take the list put it in the form of columns the name of the columns is going to be cars and bikes and as soon as i go on to print the data frame right now you can see that cars and bikes we have two columns of data and all the cars are on one side all the bikes are on another side right so we took two lists we put it out into two columns and we created a fantastic data frame and the heart of the logic the core of the logic of how to do this is lately in one line right now this is the line that converts it but to do this you're going to need an empty data frame and of course you're going to require all the lists that you're actually going to use right fantastic now let me actually go back and take a look at the 12th question the 12th question is a very interesting one so it's how do you create a data frame from a dictionary now ladies and gentlemen this is going to be a follow-up question if you uh start getting quizzed on data frames a lot right because the interviewers definitely want to understand your proficiency on the matter here now how do you create data frames from a dictionary can also be asked as can you create a data frame from a dictionary now you know the answer to it even before answering this particular question is that yes you can convert data frames and have it converted from a dictionary now how do you actually do this is very simple take the dictionary pass it as an argument to the data frame and you are done you would have created a data frame with all the details from a dictionary right again it's two lines of very simple logic so let's actually check it out uh we have an empty data frame we already saw this we have two lists we also saw this now the magic is happening in these two lines right all we're trying to do is basically take the details from the dictionary now this is the dictionary of us right we have this this is the dictionary but what is our requirement do not give us a dictionary output but convert the dictionary and create a data frame that is what we've done in this particular line of course the last line just is printing the data frame here right again take a look at this we have two lists we have a dictionary and all their data to the dictionary is coming from the list however our final result is what it's a data frame that has all these values right so ladies and gentlemen this is the heart of the logic and whenever you ask these questions in the interview itself you can quickly type up one or two lines of code and say hey instead of me writing it out on a paper here let me demonstrate how it works for you right that in a python interview is super impressive ladies and gentlemen all right fantastic now that we're done with 12 let's come to question number 13. question number 13 states how to combine data frames using the join function now the join function is a friend uh in python because we're going to be using a lot of join functions uh uh you know if we're working on any sort of data science projects you're working on uh even a good amount of web development as well so regardless of what domain it's a popular one so make sure you're paying attention as the name itself suggests basically join functions are nothing but data extraction entities which will help us access multiple different data frames which has uh more than uh one or more columns right basically it can have one column as a common data between two data frames or it can be that five columns are actually identical and you just want to combine them and join them using those columns as a header right just like how we would do it in sql now that is possible but one thing you really have to understand here is that the stacking when the data goes on right it is horizontal it is a horizontal stacking if join function is used and of course with respect to pandas you can do a left join inner join a right join and even an outer join as well right so whenever you're asked how to combine data frames using join make sure you're talking about the process of how it's done talking about that it's a horizontal uh stacking that that's being done and of course what are the types of joints that pandas support us right these three are the foundational points that you guys have to say so i hope you're clear with this but that's fantastic now once you say the word horizontal stacking there's a good chance that the interviewer might be curious to say okay this person knows about stacking so he or she can can know vertical stacking as well so you might be asked a question saying okay so which method works best if we are taking a look at vertical stacking of these data frames right now for vertical stacking instead of the join method we have another fantastic method which will work beautifully well it is the concat method right concat method again will work well when you have data frames which have the same columns and you're trying to concatenate them using these similar fields as well now what kind of stacking did i say we're going to be using for concat well we're trying to use vertical stacking right it takes up multiple data frames vertically stacks it creates one single data frame for us so question number 13 and 14 are actually linked together and they are very important at the same time guys so make sure you answer it that way right fantastic coming on to question number 15. question number 15 states how to merge data frames in pandas now this is very very important because in pandas you might have created multiple different data frames down the line and there will come a time where you might have to combine them you might have to merge them into one right how do you do that well merging depends on a lot of things first of all on the types and the fields right now if you're trying to merge two separate uh data frames it's gonna have data that might not be the native one in each it can be two unique pieces of data that are being merged right so if the fields are actually similar what happens is that the data gets merged in the axis zero of the first axis basically and then if the fields are different well it just moves to another axis and creates uh one more axis there merge along the axis one to ensure that readability exists right we're not trying to merge and sort of randomly mix everything and shake things up no we are trying to find the most structured way of how we can merge these data frames to see uh if all these similar fields can be accessed at once and of course all the fields which are different to each other they'll be merged on a different axis so you have clarity when you're reading about it right fantastic coming on to question number 16 question number 16 is an interesting one because it says hey given the below data frame how do you drop all the roofs that has n a n now any n or it's also called as nan basically stands for not a number right now that is also an important entity that is present in python now if we consider the data frame how would we go on to use it as you might have guessed it at this moment of time there is a function that does exactly this the function is called drop in a as in n a stands for not for some reason it doesn't drop in a n it is drop in a right this is a pandas function so if you ever using it make sure that you are importing the pandas as well right it's a very simple piece of code look at this this is what the input would look like you can see that there is the presence of nan values here this is what the output looks like and there is no n values there absolutely fantastic right we don't have to type in 10 lines of code to do this for us we don't have to type in two lines of code to do this for us all you have to do is import pandas use the function and you're good to go right superb guys coming to question number 17 it states how to access the first five and the last five elements of a data frame now that's a tricky question right they're asking you to access the first five elements and the last five elements as well now do not worry this is a very simple one to do there are again two functions to do this we already checked out one function which is the head function right head function prints the first five rows you can see that head off file you remember when we imported the data set this is exactly what we were doing there okay fantastic we know the head function works but what about the tail function what does it do well tail function basically uh instead of providing all the printing all the star details about your data frame from the first to last uh well the tail function prints it from last to first right so if i say tailor five i'm just getting the last five elements if i say head of file i'm getting the first five elements now let's quickly uh take a look at how this works right again as you can see we're using the same uh csv file that we have previously imported and it should still be uh since we have it should still be there since we haven't disconnected now as soon as i run this header fire will basically give us the first five now you might say how do i know that this is the first file well look at the id column right id again it's starting with zero one two three four five of course it has to be the first one now what are we gonna do next let's take a look at the last five rows using the tail function all the other logic remains the same now look at it now look at this id column ladies and gentlemen here you can see that 751 752 755. now since python starts indexing from zero i can guess that this data set has 756 elements and of course these are the last five that's printed for us now if i want last three just change uh five to three hit that button and you are good to go right look at that we got the last three as well so simple head and tail make sure you're answering it that way as well right super fantastic let's move on to question number 18 now question number 18 says how to access data from a data frame using a value as an index right now we know that with respect to data frames it is index positions as in you can go into a data frame access one particular element that is present in a two-dimensional space change it around and work with it right well of course we can do it uh uh to do this actually to how how we can go on to access the data with respect to using a value as an index is very simple ladies and gentlemen we're going to be using uh one particular function called log right loc now let's actually check take a look at it practically so that you guys understand it right now importing pandas is straightforward having two lists is also straightforward uh dictionary we already checked this out we converted it to a data frame previously as well right now look at this part a equal to 10 20 30 40 50 and up bf dot index equal to a so i'm telling that hey for indexing this particular data frame use all the data that is present here and of course as i told you you have to use lock right now if i say lock of 10 what it's basically trying to do is tell me that hey okay now the indexing is considered from this one what is the first one bajaj and lamborghini now what is the name the index that is associated with these uh first position elements well what is it it's going to be the first one here all right guys now that we're clear with this let's actually get back to take a look at the next question which is the 19th question right now the 19th question states how do you add a single line and multi-line comments in python of course everyone might know at this moment of time how to add single line commands but did you know how to add multi-line commands it is pretty simple and straightforward guys with a single line comment all you have to use is hash if you've ever used instagram and all the other social media tools you would have known the uh hashtag madness right well the hashtag madness in python is a dear helper because a single hash mark denotes that it's going to be a comment right the entire line to the right of the hash is going to be a comment but that's a single line what about multi-line well multi-9 is even more simpler all you have to do is open triple quotes uh as in uh you have to open codes three times right double quotes three times as you can see here one two three and just have any number of lines you want and just close it back again so everything that is enclosed between these triple quotes is nothing but a multi-line command right let's take a look at that now right guys as you can see this is a single line command right now this literally is a comment that you see in green color right now this line python will not execute because it knows that it's a comment now uh what if i just use hash and type in something like anirudra here right is that a comment absolutely not right look at that i haven't even done anything and it's giving me a warning out there now what i'm going to do is basically uh run this particular command now you can see that this is not a comment but still it has a hash there what's going on as i told you everything to the right of that hash on the same line is a comment but everything to the left of it necessarily need not be a comment look at this this is a multi-line command triple quote open triple quote close so everything that is present in between this this is a multi-line comment right now as soon as i print it it should say hey this is not a comment because we're trying to print this and at the last line it says it's that simple well ladies and gentlemen it really is that simple as you can take a look at it right fantastic let's discuss question number 20 what is the most memory efficient way to add elements to a tuple well what is the most memory efficient way now you might be thinking about two or three different ways but do not fall for the question because this is a trick question ladies and gentlemen tuples in python are absolutely immutable when i say immutable you cannot add data to an existing tuple if you want to add new data what do you do it's simple and straightforward create a new tuple for it if you already have a tuple and if someone asks you how do you add how do you modify or something like that understand that it's a trick question right be very careful with questions like this they get thrown right in the middle of the conversation and they'll try to catch you off guard now if you were to answer these then then the interviewer is going to be confusing hey does this person know python to a good amount of detail right be very very very careful and uh you know i have a lot of trick questions that we're gonna be covering but this is an important one and uh talking to a lot of professionals this is a question which again is super popular in the year 2021 it's moving around the interviews a lot right fantastic now coming on to question number 21. question number 21 states what is a dictionary in python okay so what is a dictionary in python we've already used dictionaries right dictionary is a fantastic data type in python where we can have collections of items without having any sort of order so it's an unordered collection of items that is literally what a dictionary means but uh when you're answering the question make sure to give a little more details about it for example you're going to be using curly braces and there's going to be two elements for a dictionary right one is going to be the key value and the other one will be the value itself now the value gets mapped on to each different key so there's multiple keys for multiple values out there one key one value another key another value right that you have to answer and of course uh it is always efficient if you guys give one example as well right now if you don't have an access to a laptop while you're giving your interview or anything as such take a piece of paper and just write down an example such as this right now here you can see the key values are specifically right we have two keys and we have two values key value key value it is as simple and as straightforward as this guys don't just say it's a collection of unordered element make sure you're breaking it modularly down into these three or four important points and mention that as well all right coming to question number 22. question number 22 states find out the measures of central tendency for this numpy array and you have a sample array on your screen measures of central tendency well we have heard it somewhere in our school or colleges and it might be a little hard to recollect in the heat of an interview but understand that central tendency is nothing but mean median and mode right it is as straightforward as that in fact when you are asked this particular question you can give the give a bonus answer to the interviewer itself saying hey i can give you the mean median and let me also give you a stand the standard deviation as well right standard deviation talks about how individual values varies from the mean of that particular data right that is standard deviation you don't have to implement anything manually because as functions for everything mean as a function median as a function standard deviation also has a function right again a quick demo so let's take a look at this let me scroll down to question 22 and as you can see we're using numpy so i don't have to do this all the time but since you guys might be learning this and if i skip this there's a very good chance you might get stuck on an error in the heat of the moment right so i'm making sure i'm importing multiple times you don't have to do it however right now look at this we have taken the numpy array that's been given right now they've given one more array here we have another simple array as well right if you want the exact same one well we can actually go on to have this as well done right now as you can see np dot mean np dot median np dot std which is the standard deviation and all we're trying to do is pass the array as a parameter and we're going to get all the values of that right look at that this is the mean value of this entire array now the median value is 5 and the standard deviation is 34 right now this is an important thing as you saw it is again simple one line of code it's not even 10 characters ladies and gentlemen python lets you do so much for so little this is the magic of python right i hope we are clear with this let's get back to the next question uh which states what is the use of a classifier now again this is a question that will eventually see itself asked uh you know randomly or while you're thinking about something else the interviewer might just throw this in and ask you this particular question right now what is a classifier the question uh uh you know is pretty simple here and the answer even remains in the question itself with a classifier classifies something so what are we trying to classify here we're trying to predict the class of any particular data point that we have at hand right classifiers can be considered as special hypotheses basically which are used to assign class labels uh and where are we assigning these class labels right we want certain data points to bring class labels data points together that is why we require a classifier but classifiers are popularly also uh you know used in the case of training the data in the machine learning application where you're trying to even understand the relationship that exists between a class of variables and the individual variables themselves so instead of just saying a classifier is used to classify special hypothesis make sure you're paying attention to the third point and make sure you state that because classifiers are exactly used for that purpose and if you state the purpose it's again a hammer on the nail a perfect answer right fantastic guys let's take a look at question number 24 now question number 24 states how do you convert a string into lowercase using python how do we convert a string into lowercase do you have to manually do it again the answer is no you have a function to do it for you this time we have a string function the function is called dot lower string dot lower where you can have any string there right look at the example on your screen we have a string uh which which is completely in caps which has great learning all in caps and as soon as i print another statement of course this can be in the next line as well print string dot lower right and all it's going to do is any character which is not in lower case it will compulsorily bring it to lower case but you might ask a question saying but what if it is already lower case if it is already lower case it is ignored but if it is not it is forcefully converted into lowercase right fantastic guys let's take a look at question number 25. question number 25 states how do you get a list of all the keys that are present in a dictionary now remember when we spoke about a dictionary we spoke about keys we spoke about values for those keys now the question that's being asked is can you create a list of just all the keys that are present in a sample dictionary first of all it might be a question that is asking can you do it now the answer to can you do it is yes if you say yes the next question is going to be how do you do it that's what we're taking a look at right here again we can get a list of keys there's a simple simple function called dot keys big dot key is basically where it will give you all the keys right this method will return every single key that is available in that particular dictionary now i know it's going to add a lot of value if i show this to you guys practically so let's take a look at it again it's two lines of code look at this we have one dictionary where we have the keys and the values associated with it and i just run the dot keys function on on this particular dictionary that's why it says uh dick dot keys right now dick dot keys basically is going to give us an output one two three now one two three are what this is the key uh one is the key two is the key three is the key but a is the value associated with one b is the value associated with key two c is the value associated with 3 right pretty simple and pretty straightforward fantastic ladies and gentlemen let's go to question number 26 now question number 26 states how can you capitalize the first letter of a string how do you capitalize just the first letter of a string right now we saw that we can take the entire thing to upper case and maybe the entire thing to lower case as well it works both ways there are two functions right now to just capitalize the first word the answer lies in the question itself capital lies there is a function in python called capitalize which will just take the first character of a string and just make it into uppercase right but again a question that might be asked you at this moment of time is okay so what if it is already a capital letter to begin with if it is already a capital letter to begin with you have reduced python's job and it will just ignore it and say okay so this is already capital let me move on right that is it let's take the take a look at this practically and again it's a simple two-liner uh piece of code here right now n equal to great learning as you can see uh i have a lower case for g here but as soon as i run this piece of code n dot capitalize now capitalize is the method i was talking about look at this right the first character of the entire string has been made into caps of course this will work for anything ladies and gentlemen you can have for example let's do this let's just say that there is a typo right uh the first name has is not in caps now as soon as i run this it will be the perfect form a is going to be in caps and of course uh take a look at this now the r capitalize has also inverted right now i want you guys to head to the comment section and tell me why this particular thing happened right capitalize basically does uh the other thing as well now okay so now that you might be asking about it let me do this now what happens if i do that well if i do that it's going to be a standard result but if i add a space there the first character of that string is going to change now at this moment of time is going to remain the same thing as well right now that is a little a tricky question for you guys now i want you to enter the comment section and tell me why that happened right fantastic let's move on to question number 27 where the question states how can you insert an element at a given index in python well it's a very simple question it's a straightforward question yet it seems like it's such a complex one but of course when you're in the interview uh when you ask the question such as this it is very easy to get confused right that is the entire point of this now how can we go on to add an element at any given index well it's as simple as using another function this time the name of the function to do this job is called as the insert function right it can be used to insert any element that you want at any particular index location of your choice now to just state this out might not give you complete clarity so of course we're going to take a look at this practically as well look at this can you insert an element at at the given index right now this is the list 0 1 2 3 all the way up to 7. now what i want to do is i'm going to use the insert function now if i just say insert 10 the question that's going to be asked is insert 10 where right now i have to give the index position at which i have to insert a value now all that this is stating is insert the value at the sixth index the question is okay what is the value well the value is 10 right sixth index put the value 10 there and as soon as we go on to print it you will see that it's pretty simple right now look at this particular gap here we have 5 6 and here we have 5 comma 10 comma 6. so 10 was inserted at the sixth index position right 0 1 2 3 4 5 6. python came here and it was like okay i have to add it here but there's already six so six moves to the right and it gets wedged in between five and six that's the reason we have 5 10 and 6. now what if i want to uh have it as 15 right now let me just change the comment as well so that you guys don't get confused as soon as i run this well the value 15 gets added to the sixth index location pretty simple right superb coming on to question number 28 question number 28 states how do we remove duplicate elements from a list do we have a function do we have a method in fact there's multiple different ways of how you can remove duplicate elements right the easiest way in my opinion is to take a list and convert it into a set by of course using the set function and eventually using the list function to convert it back to a list if and if it's required right now you might be wondering hey we are trying to remove duplicate elements why do we have to convert it to a set how does a set work a set literally states it is a collection of unique elements there is no repeated elements in a set so if you have any repeat elements you need to get a read or get rid of convert it to a set set will automatically throw out all the extra values for you and you can convert it back to a list and eventually you are done how simple is this let me show it to you again it's two or three lines of code right okay first of all i'm going to be deleting the list here because we've been using lists of the concept multiple times so you can ignore this line as of now your heart of the logic the one line you should be concerned about is this one first of all we have a list the next thing is we're taking a list and converting it into a a dictionary or a set or anything that works and in this particular case you can also use from keys from keys also works fantastically well as soon as i run this uh now what are the duplicate element that we have here x y z z and s so z is the repeated guy we need to get rid of and as you can see once we run dictionary dot from keys or eventually you can use multiple ways to do this as i told you now i want you guys to head to the comment section and tell me another way i told you one way to do it and i showed you uh using another way as well right now how do you convert it to a set and convert it back guys head to the comment section and give me the logic for this right superb now let's get back uh to our deck where we're going to discuss question number 29 question number 29 is a very important one because here we're talking about a concept called as recursion and recursion seems to be the most famous concept the most uh asked concept in an interview right b data structures of python so what is recursion well recursion is nothing but a function calling itself to have multiple functionalities over the same piece of code if you have a function that calls itself uh you can actually pass any different value that you want and get the function to have its behavior but use different attributes to give you different results right but one thing you have to mention if the talk is about recursion is please don't fail to mention that you really have to terminate a recursion statement by either giving a condition or manually terminating it now if you do not terminate a recursion it's like the function calling itself calling itself it just keeps going back and forth back and forth back and forth and how long is it going to go for it's going to go on for in finite times it's going to create an infinite loop if you're not very careful about this so if you're asked about recursion make sure you're specifically mentioning about its usage and its termination as well because it's very easy to use recursions and it is very easy to miss the termination and send your entire program into an infinite loop right fantastic coming on to question number 30. question number 30 states explain python list comprehension what is list comprehension in python right we know lists but what is comprehension that we're talking about well list comprehension basically talks about the operations of how we can convert one list into another basically instead of convert the better word to be used here is transform right elements that are basically uh that you can conditionally transform are present in the new list and each of these statements that you want to pick right there are ten statements you want eight to be transferred into another list or you want this to be transformed and create another list just from a substring just from an element that is present here is it possible will be the first question the answer to which is yes the second question is how and here is how right look at this we have a list here but instead of me manually specifying one two thousand elements one comma two comma three comma four all the way to thousand i just ran a for loop there and as soon as i hit print it's basically going to actually print thousand elements 0 to 999 right i'm scrolling left to right look at this it did all of that but this is comprehension we're transforming a list right now if i have to do this manually again 1 comma 2 all the way to 1000 would be the way to go but we are intelligent programmers and we make sure we understand comprehension as well right fantastic guys now let's move on to question number 31 what is the use of the bytes function in python now what would be the use of bytes function in python right well it's very straightforward ladies and gentlemen the byte function the bytes function sorry in python uh just returns a simple byte object right if you have any object that needs to be converted into a byte object or let's just say you want to create an empty byte object of the specified size that you want you would just go on to use this function right it's extremely straightforward it is simple so when you ask this question make sure you are uh your answer is straight as an arrow here right this is a very important question right coming to question number 32 question number 32 states what are the different types of operators in python now this question can be asked earlier as well and especially if you guys are freshers uh just out of college looking out for your first python job this is a question that will be asked so ladies and gentlemen whenever you ask this particular question just make sure that you're talking about the arithmetic operators which is basically addition subtraction multiplication division and the modulus operation the percentage symbol there right the modulus operation returns the reminder uh right now that's a very important thing and it's a it's a very different output compared to a regular division as well don't forget that and of course you have the relational operators right less than greater than less than equal to greater than equal to uh of course equal to equal to and of course not equal to right now i said equal to equal to but you just see it as equal to once next we have the assignment operator assignment operator is equal to uh plus equal to minus equal to right you might have seen something such as a equal to uh a plus 2 instead of that you just say a plus equal to 2 a plus equal to 2 literally is the same as a equal to a plus 2 we just shortened it down to an even further degree right now of course this is done in multiple programming languages but since python also offers support for this i love it right fantastic next uh take a look at the logical operator ladies and gentlemen there are three logical operators and or not and basically we give you a true value if both the values are true else it's false or it's a different game if one of the two values is true any of the two values is true you will have a true output not is a fantastic uh way of approaching a logical solution if you provide a true it's gonna reverse it and give you a false if you provide false it's gonna reverse and give you a true right but of course there are other types of operators you guys have to talk about as well we have identity operators we have a bit wise operators now there's bitwise operations as a bitwise and bitwise or right there's a difference between bitwise and logical operations and i want you guys to tell me what it is right fantastic guys so if you ask the different types of operators make sure you're talking about these right okay now to come to question number 33 question number 33 states what is which statement used for in python the with statement right what is it used for well which statements is super super popular for one very important application in python which is exception handling ladies and gentlemen exceptions will you will come across exceptions even though you want it or not so to handle these exceptions we have multiple methodologies in python and the which statement is at the heart of that as well right now a file can be opened and closed whenever you're trying to execute a code block which has the which statement in it right if you open a file you have to close the file as well but if you are opening it with respect to exception handling mode and we're trying to use the keyword with there you really can get away with it without using the close function for the file as well right now look i use the conceptual example to denote the logic the working the application and to talk about where it is used and the level of difficulty as well we are making it way more easier to read uh reducing the code and eventually we know it works well in exception handling as well so this is an important point that you really have to think about right fantastic coming on to question number 34 question number 34 states what is a map function in python map function have we ever used a map function well the map function basically is used for applying functions to an element which has a specific iterable in its case now you might be a person here right now saying hey what are you talking about i've never used the map function i don't know what element you put in i don't know the syntax i don't know what an iterable is right well let me tell you this map function is a very simple function that you try to apply uh you know function on not just one element but all the elements now there are certain parameters you have to pass to this there are two parameters one is the function itself and of course the iterable that talks to the function right let's quickly take a look at this practically so you have better understanding of what it is that i am saying right now right look at this first of all you can ignore this line again we're trying to delete the list there we have a function here now what the function is doing is basically try to no matter what input you give a numerical input is going to multiply it by three and give give it back to us right look at this we have one two three four five six your result equal to map look at this map function and i said function comma iterable this is the function that i want applied on every single element of the iterable get it now the logic what's gonna happen is uh in the first place we're gonna get 1 into 3 second place 2 into 3 third place 3 into 3 4 into 3 5 into 3 6 into 3 and at the end we're just converting it back to a list and printing the result of it which just states this right we gave one two three four five six but we got three six nine twelve fifteen and eighteen what's the logic the logic is here we multiplied it with three but did we just do it for one element no we're trying to apply a function across all limits or an iterable what is the iterable it's tuple well what are we doing here we have six elements multiply each with three and you're good to go right fantastic guys now let's take a look at the next question which is question number 35 question number 35 is another extremely popular candidate which says what is the init method in python now the init method is basically a reserved method in python you cannot use this for anything else just like the reserved keywords that we talked about right now since python is an object-oriented programming language it's an oop language this here in the case of an op language this method init method is basically nothing but a constructor right when you create an object uh basically when you create an object the object belongs to a particular class the init methodology basically is used and it is eventually called to actually access the class attributes that we have for that particular class wherein we're talking about the object right so init is nothing but a constructor in a in the constructor this methodology is used to call the access of the particular class attributes right it's a simple straightforward answer but don't just say that it's a reserved method or don't just say that it's a constructor have one more go one more step ahead and give out the third point as well right that's a very important point fantastic now let's take a look at question number 36 question number 36 states what are the tools present to perform static analysis so static analysis is basically how we can go on to find the bugs in python ladies and gentlemen now the tools that are present in python to actually go on to do this uh we have two tools one is the pie checker and the other one is the pylon right now i am sure you guys might have used one of these things to detect uh maybe bugs in your source code or even to warn about the usage of variables style the complexity and all of that as well now that whatever i just mentioned is the forte of pi checker but what is pylint doing pylint will basically check if your particular module matches up to a set coding standard or not now there's multiple coding standards that one has to adhere to when working with this pilot is a fantastic tool that will help you answer the question saying hey is this coding standard being met or not if you have a question such as that pilot is the basic tool that you will be using to give an answer to it right either be a yes or a no and if it's a no it's going to tell you why it's different as well right fantastic now coming on to question number 37 question number 37 is an interesting one because it says what is the difference between a tuple and a dictionary well tuple ander dictionary right now the major difference between a tuple and a dictionary that you just have to you have to say it as the first point is that tuple is immutable while a dictionary is mutable as in you can add values to the same dictionary as you choose for any number of values that you want to add it is possible but in the case of tuple you cannot once it's created those values are fixed for that tuple if you want to add new values to a new tuple you create a new tuple there right the content in the dictionary can be changed the content in the uh tuple cannot be changed unless the identity of it has changed right now look how i nicely put out the answer uh that eventually gets across the point as well and eventually gives you details about its identity about the values about its mutability and of course to talk about what a tuple can do and uh what it actually can do that tuple can't do right super coming on to question number 38 question number 38 says what is pass in python what does pass is it a function is it a module what are we talking about well it's not any of these because pass is basically a statement which will eventually do nothing when passed you remember how when you're playing games you say hey i pass it's literally that in python now you would say why is that required well it is a null statement right now you cannot say we don't have use for null uh zeros uh zeros in fact are entities on their own none is something which is super important null null null is also super important right so uh you might think saying hey will it just be skipped by the interpreter like how the python interpreter skips all the comments no this is not skipped by the interpreter but whatever you try to pass will eventually not be executed it's like the turn of that particular statement is passed on right like you move on without executing that particular one that is pass now it is used when you actually do not want to have any sort of commands to execute but you don't have commands to execute rather you have a statement that is required there right now if this is the exact case talk about what it does talk about why it's doing that talk about how it's being done and give one more example to state another condition which you might also face right look at the four points it is exactly aligned towards what i just said right this is how you should also uh you know formulate your answers when you're giving it out to the interviewer guys okay fantastic coming on to question number 39 question number 39 states how can an object be copied in python now even though you look at the particular uh even though you don't look at the answer you just say saying hey we have an operator that that does exactly that right we have the equal to operator that can go on to copy any sort of object you want to again any sort of variable that you want look at the example that's on your screen var equal to copy dot copy of object all we are trying to do here is we're trying to uh you know copy an object to a variable but now i just said that you can copy any object that you want to any variable that you want there is a certain catch phrase here not all objects can actually be converted in python of course 99 of them can be done now there are certain objects that cannot be copied and python right now while you're watching this video take a second to pause it uh find out which is the uh object that cannot be copied and python head to the comment section and let me know i'll be more than happy to take a look at your comments right fantastic coming on to question number 40 it states how can a number be converted to a string well we already saw numbers in the form of a string but literally there is another inbuilt function called spr as in string that is used to convert what a number into a string right again as always we have to check this out practically to understand this now let me quickly scroll down here yes you can see n equal to 10 we have a number right number is 10 as soon as we print n this is still gonna say it's a number it's an integer but look at this the next time we're using it we're calling a string function and passing the value to it so the type of the new string that's generated what is it going to be let's take a look at it right first one this type this number says it's an integer it's a number correct next one as soon as we run it after this logic has run it says that it is a string right now this 10 is not numerical anymore but it is considered as a string if you have to start out with a string all you do is this but my logic states do this right now that's an important thing you guys have to know about right fantastic guys now let's just move on to the next question which is question number 41 question number 41 states what are modules and packages in python modules and packages we've been using a lot of modules and packages as of now right numpy pandas and all of that now that that is one side of the thing now the other side of the thing you have to understand is that with respect to modules why are modules used and what are they modules basically try to split your program and give it some meaning on its own it tries to add structure to an existing program right you might have multiple python programs which is basically used for one different application or one single application i'm sorry now when that is the particular case you're gonna have to import other attributes you're gonna have to import other objects and you're gonna have to import multiple files to get the functionality of all these objects right that is exactly why this is used for as well now if there is a folder where a program is present it is nothing but a package that is consisting of multiple modules i think now you would have definitely got the full picture of what modules are right but one important thing you really have to think about is that a package can only have modules or subfolders right you cannot have anything else apart from modules or subfolders in a package of course uh you might be saying can we have programs of course we are having programs in the case of modules in fact many programs are possible but apart from this is there anything that's possible the answer is no so ladies and gentlemen when you ask this question talk about what it is where it is used how it is done and what is it that you should not do as well for example if you're talking about top will say that it's immutable right because that is its characteristics whenever you're talking about modules and by modules and packages this is the characteristic you have to talk about right fantastic now let's move on to question number 42. question number 42 states what is the difference between numpy and scipy well what an interesting question right because numpy stands for numerical python while scipy stands for scientific python numpy is a fantastic library which is used to perform complex numerical operation on the lines of defining arrays solving mathematical problems and a lot more we saw a lot of numpy with these questions already right of course going ahead we're going to check out more as well but then when you're talking about scipy sci-fi stands for more scientific applications on the lines of statistics on the lines of applied mathematics think about things like uh integration think about differentiation think about all the data points that are required in terms of statistics for machine learning as well right when that is the case scipy is super popular for that of course if even for machine learning you're going to require numpy to handle data for you but uh it's not that without numpy you cannot do it right there are manual ways of how you can do it as well it's not numpy that's uh providing functionality for machine learning but once you figure out how these algorithms work you're going to understand the importance of scipy as well right so you can actually brief the interviewer regarding the answer in this way too right fantastic now let's take a look at question number 43 question number 43 is a rather straightforward one that states what does the lend function do l e n len now the len function is short name for length len gth right length so what can you find the length of well you can find the length of a string an array a list anything that you can count you can find the length of it right so let's actually take a look at it practically now this is again a very very very simple uh example here right we have a string here the string is called great learning of course welcome to great learning do take a second to subscribe if you are loving this video right fantastic now what are we trying to do next we're trying to uh uh instead of just printing out the string which is again no point we're trying to print the length of the string here now as soon as i hit uh play here it's going to basically say 14 but great learning is not 14 characters right r e a t l e a r n i n g well it's 13 where did 14 come from you see this beautiful white space that is sitting in the middle let me select the space that is also considered with length but now if i hit backspace and if i make it one word the answer is now going to be 13 instead of 14 right so when you are talking about the length function given example specifically say hey i know that if you use a white space that is also counted as well that way of approaching and attacking the problem is impressive right again very simple straightforward question straightforward answer right let's go to question number 44. question number 44 is diving right into the heart of object-oriented programming it states define encapsulation in python encapsulation is capsulating something putting something into a capsule locking it away now right why do we want encapsulation encapsulation ensures that you're actually bringing a tiny piece of code together you're bringing the code and the data together in a way where access to that particular variable there the scope and the lifetime of the variable is basically meant for that particular class right again encapsulation is a very important part of oops as well in fact you use encapsulation in your real life just open your wardrobe or your cupboard right if you open your water over your cupboard your clothes are all on the inside and you close it and you lock it away right it's not like you display every single one in your room every day no i don't do that and i'm sure you guys don't do that as well now when that is the case you're actually encapsulating all your clothes when you want it you're going to use it but when you don't want it it is stored away and you can also lock the cupboard in a way where you can have access you can have access but someone else can't you can do that in python as well and a fantastic example to go on to do this is nothing but a python class because a class makes sure that there are object inside it and once you have a class and objects associated with that class uh there is the concept of lifetime and scope which will eventually protect the entire class right that is encapsulation now let's take a look at the next question which says what is the use of the type function in python type function don't you think we already use this multiple times now ladies and gentlemen well type function is nothing but a built-in function that will give you the type of an object that we are trying to work with right it'll also uh here's the catch uh look at it look at second point guys it also returns a new type object based on the arguments passed of course whenever uh you're passing your arguments you might be changing the functionality of what's going on there so you might be passing an integer you might be passing a floating value you might be passing a character string we already took a look at the set question number 40 right so if you uh just skip through equations make sure you head back to 40 to understand the functionality of type as well right fantastic with this we'll take a look at question number 46. question number 46 states what is the split function used for split function well what does the name suggest split as in take something split it right it is literally that guys we're going to be splitting a string into shorter strings by making use of this particular function it can be done in a random way it can be done in a very structured way as in you can tell where to split what in terms of which data structure as well right so the amount of breaking that you can do to bring something to its most simple level is magic right let's take a look at this practically now this is the question that we were discussing right what a split function look uh we have letters equal to abc now this is one entity this is one element right it's not like i have double quotes for all uh each of these entities now what i'm going to do is i'm going to split and i'm going to split it by having a comma there as soon as i run the dot split function look at this these are three individual elements instead of just abc being one individual elements and i'm splitting it by right now ask a question when you don't understand the syntax if you want to split something the next question is going to be okay split it where or split it using what the what is basically this particular comma that we're using right we use that to say hey after you find every comma create a separate object and split it for us right fantastic guys that is 46. let's move to 47 which states what is dog string in python ladies and gentlemen what is doc string right now a dog string is something which is super important for python programming language to work because when you're talking about all these string literals right whenever you put anything in triple quotes uh that appear uh uh you know when you're using the function there's triple quotes and there is something related to either the definition of the function the method it can also appear in a class of course you can also use it for your module as well right so it's literally string literals uh let me rephrase that it is string literals that is enclosed in triple quotes that you would find appear to the right of the definition of beta function be it a method class or even a module right generally when we try to describe the functionality of any particular uh function method class or module we try to use the docs string the docs thing literally answers the question saying okay so how if you're defining something uh you know how does it work right so to understand the functionality the doc string is very much important now the interviewer might ask a question saying okay so where am i going to find this doc string you already said that it is found right uh to the right side of the definition of a function but all of these doctrines are present in one particular attribute which is the underscore underscore doc again another underscore is called like very similar to init the uh the syntax is very similar to init underscore underscore init underscore underscore but instead of that we have double underscore doc double underscore to end it as well this is question number 47 well coming on to question number 48 the most popular function to ever exist uh you know to be asked for interviews which is again the lambda function so what is the lambda function how does one go to use it a lambda function is us trying to create a simple temporary function which again does not have any names no definition no return type specifier which is us having to specifically mention all of these it's all uh you know an intricate dance that happens in the back end at the front end all i want is to use one logic and i want a function that does it really quick if that exactly is the requirement all i would use is a lambda function right mostly lambda functions are never used as standalone functions they'll be used as an argument to another function to another higher order function so you're talking about what lambda function is make sure you're also talking about where lambda functions are used right now as always to give you more clarity i want you guys to take a look at this practically guys now look at this i have a function here called triple now triple says lambda x such that now this particular colon that you see here is read as such that right it's i would read this as a lambda function such that x such that x multiplied with 3 so any value that i pass as an argument i'll get the output of it being multiplied by 3 if i send 5 what is 5 into 3 15 what if i send 100 100 multiplied by 3 is 300 so that literally is the answer that i'm going to get right pretty simple this is a pure working function that would uh that would just give you the entire functionality instead of me typing def triple uh return x such that uh you know return x into three and eventually call the function pass the value print it out instead of using seven lines we just broke it down into one line right it's literally that a short temporary function which we would want to use right superb now coming on to a question which is super popular it says how do you find the factorial of a number you have multiple math functions of you how you can do it right it's literally passing a value as an attribute you have the answer python will give everything to you in the shortest way possible but read the entire question it says how do you do it using recursion right now you have to manually implement the logic as we have already discussed recursion is a situation where the function calls itself it can be same attributes or different attributes but one important thing is that we have to set a stop condition so that it doesn't go on doing the same thing again and again and cause what an infinite loop fantastic guys let's take a look at question number 49 here right now i have a very simple function here called as factorial i've defined a function i have one attribute now what is one factorial ladies and gentlemen it's one right uh if it is anything apart from one we eventually are going to have to uh you know work on the factorial right now what is 2 factorial it's not just 2 it's 2 multiplied with 1 what is 3 factorial it's 3 into 2 into 1 what's 4 factorial 4 into 3 into 2 into 1 what is x factorial x into x minus 1 x minus 2 so on so on so on we've read it in school right we have to forcefully specify it for 1 because there is no logic if you do not specify this as 1 1 factorial will be 0 is 1 factorial 0 i don't think so right now what do we want let's let's have five factorial right five factorial is a fantastic number so as soon as i go on to run this logic uh it's gonna say five factorial is 120. now how did i get 120 five into four into three into two into one but hey where is all that going on where is the uh recursion going on look at this we are returning a value and eventually multiplying the returned value by calling a function and reducing that so with this if it is 5 it will basically say 5 into what 5 into a minus 1 is 4 and eventually it's going to run again 5 into 4 okay it's going to say 5 into 4 into 3 it's going to run again 5 into 4 into 3 into 2. now it becomes 1 it's like oh okay if it is 1 it doesn't run this logic if it is one it will just state one right five into four into three into two is executed all the way here but that last one is defined here and executed right you can have the factorial of anything right let's have a really big number what is the factorial of 200 now there's going to be a huge number right look at this this is the factorial of 200. look at the size of this number ladies and gentlemen let's have let's have something simple 3 factorial right the answer is 6. let's take a look at that there we go the factorial of 3 is 6. fantastic right that's the 49th question now let's take a look at the 50th question which says how do you denote the working of the bool function with examples of my suggestion ladies and gentlemen whenever you're walking into a python interview please carry your laptops have your jupyter notebook up and running so that when you ask questions such as this you can just open up your laptop and start typing in your code right because the working of the bull function is very simple yet very confusing for a beginner right of course we already know that the bull function can only give yes or no zero or one true or false but for what conditions does this behave as true for what conditions does this behave as false that is exactly what we are going to check out in question number 50 here right take a look at this uh here basically i have equal to hello this is a simple string b equal to 15 this is a non-zero integer number and c equal to zero and i have a sample list but i have not given any uh values in the list right this is an empty list now as soon as i run this i'm supposed to get true true false false right boolean of a why is that the case well boolean functions functionality is fantastic it will provide the output true as default unless it sees none unless it sees null unless it sees zero and unless it sees empty elements such as empty list empty set empty dictionary or something like that right when it's empty none zero or null you're gonna get false everything else apart from that you're gonna get true that is the most simplest way you can just use one two-liner example to showcase quickly type it out and hit enter in the interview and you can just show it of course now now that all the interviews are going on uh in a virtual way you'll be on a zoom call or you'll be in a google meet or whatever it is just quickly start sharing your screen open up a notebook ask if you can type the code and show it practically i don't think no interviewer would say no to that right so you have to do it quickly though you cannot take your time to do this but then now that you know how to go about working with the bull function i am confident that you guys will answer this right fantastic enough coming to a section where we'll actually be taking a look at some really important interview questions but for experienced users right now there's variable levels of expertise wherein when you're applying for a job you might be a fresher uh you know you might still be in college looking out for applications or you're a person who has one or two years of experience in the domain itself but you're still looking forward to understanding what are some of these advanced questions write these uh questions which are not as simplistic as the ones that have been asked if you were refresher right now we're going to cover all of those in that and of course after this in the next part of this uh video as well right we're going to be taking a look at some really really important tricky questions guys so make sure you're paying attention right fantastic now to come to the first question it says how to create a new column in pandas by using values from other columns right so we already have a data frame in pandas and what we want to try to do is we want to create a new column but we won't already use uh existing values from another column right now of course we've already seen how we can work with a data frame in the beginner's question so if you do not know how to work with data frames guys i highly suggest uh you just step back and take a look at the previous questions and eventually move forward to your right uh with that to answer the question of course the pandas columns all these numerical values that are there we can operate on it based on any requirement that we have right there are operators data frame supports the operation and eventually we can get go with not a lot of code right let's take a look at this practically to ensure that you guys have complete understanding right now let me quickly zoom in so that all of you all can see right superb here is the first question now how to create a new column in partners by using values from the other columns right first of all we're going to be importing the pandas library next we have uh you know two lists out here we have a dictionary definition column one of a column two is the value for b we're creating a data frame out of it and once we create the data frame out of it this is where the logic is happening guys so what we're trying to do is we're trying to sum up both the columns into a data frame and eventually uh you know you can also do the difference operation as well as you can see we have some operation we have difference operation and all we're trying to do is a direct plus or minus operation there right now let me actually hit run on this piece of code uh you will see this right column one column two now what are the sum of column one and two you can see it in the sum tab if you want the difference of column one minus column two uh eventually it'll be there right now if you're thinking about hey this is a negative number why am i saying negative numbers that's because the data in column one is less than the data that's present in column two uh you can definitely change this uh if you just want a new difference all you have to do is column two minus column one now this would again depend on the application that's been asked so if you're usually asked to actually pick up columns and just use values from other columns as well you can do that right uh now c1 plus c2 this is the sum c2 minus c1 is the different set here right so i hope we are clear with question number one fantastic let's move on to question number two in question number two they're asking what are the different functions that can be used by group by uh in pandas right now again if you haven't taken a look at group by we've actually used this previously as well so make sure to take a look at that now one thing all of you all should understand is that group by is a fantastic function that's provided in pandas wherein we can go on to work with multiple aggregation functions right now when i say aggregation uh you might have definitely used all of these in excel think about the average function the sum function uh think about min think about max think about mean sum count standard deviation all of these are called aggregate functions or aggregation functions right so what we usually do uh here is that with all of these functions they have their own purpose the sum function will eventually add up all the values the mean function will eventually just give you the uh mean of the data that you have passed with this now again if you have already noticed that from the previous section we have used the sum function we have used the mean function we have also used the standard deviation function right so we have used it previously right so if you haven't had a chance to take a look at it again guys i highly suggest you do right fantastic with that let's take a look at question number three question a bit three seems to be a really big question but trust me it's a fantastic uh it's a very easy question to answer right so it says how to select columns and pandas and add them to a new data frame and that's not the end of the question uh of course uh if it is asked in a manner saying can you add new columns into a new data frame of course the answer is yes so once you say yes to that they'll ask you how once you answer how there's a very good chance that the interviewer might also say okay so what if i have two columns with the exact same name what do you do then right now we are covering three uh big answers in one of uh this particular question itself right of course if df is basically data frames and pandas df.columns will give you what a list of all the columns we've already seen this right so if you want to go on to create new columns uh well what do you want what's the new column that you want you'll have to select it right now when you go on to create these new columns all you have to do is select it if they have both the names i mean if if both these columns have the same names then eventually they get copied on to the new data frame right so the question asks how do you select it and add them into a new data frame and what if they are common if they're common it's well and good directly add them in and they will uh the data will get it will get added on to the new data frame pretty simple right but then when you take a look at the question it definitely is overwhelming and this is a very common question that has asked for experience users as well okay coming to question number four question number four asks how to delete a column of column or group of columns in pandas given the below data frame please drop column one right now let's take a look at the data frame here it's a very very simple data frame there's two columns column one and column two now what they want to ask you uh to do is basically drop every single value that's present in uh column number one they might also phrase another question like uh drop uh you know instead of just saying drop the entire column they might say drop the data that is present in the column as well and of course guys we already know this if we have to work with columns if we have to delete anything the drop function in pandas is absolutely beautiful for working with data frames right so you can see the input what you see here that i'm moving with my mouse this is the input what we want is column one removed so as soon as column one is removed this will be our final output data frame right so let's take a look at this uh and understand it practically so this is the question we were discussing question number four how do you delete a column or a group of columns right now uh we have the columns that we have put out here we have column one with data one two three column two with data abc now as you can see we are creating a data frame of the data that we have and this is where all the magic happens right uh df.drop of column one will eventually remove uh everything that's present there now as soon as i run this you will see that even though we input one two three four column one that is pretty pretty much absent right that is the magic in fact question number five uh is sort of an add-on to this particular question it says hey given the data frame why uh you know why don't you remove uh everywhere you know remove all the rows where the column value is a right now let's take a look at this which row has a well it's column two but row zero right so we want to remove everything with row zero and column 2 which is basically a now how do we go about doing this the drop function will drop the column but the drop in a function is used to drop these individual values that we can work with right you can take a look at the input and the output here in the input you can see that it's a 0 1 a but in the output this entire row is completely deleted and it starts from this row right that is all that we're trying to achieve wherever there is a just cut it out right it's pretty simple now let's take a look at the code as you can see pretty much all these lines are as simple as this right as soon as i go on to hit play here we will have the input data frame now this is what we have but the logic comes into picture here ladies and gentlemen i made it into a comment so that we can take a look at the original one uh before actually having to take a look at the modified output right look at this instead of using just drop we're using drop any and of course right wherever column one is not equal to 1 we are trying to drop those columns now as soon as i hit enter here you can see that this is the input this is the output you see that 0 1 he has vanished from the output and all it took pretty much was just one simple line of code simple right but but at the same time when you're in an interview all of these can be pretty tricky to actually think about and provide a solution anyway let's take a look at the sixth question now this again is a huge question right given the below data set find the highest paid player in each college in each team now what are they asking for they want the highest paid player so where are we talking about money there we go we're talking about the salary right now once you understand the salary they just want to find out who's the highest paid player uh right and you have to uh split it out college wise now you might be thinking taking a look at this data set saying hey under uh this is going to be a very long problem uh you know we're going to have multiple python steps to do this right well the answer is absolutely no it can be done in one very simple line by making use of the group by a function as you can see here what do we want first of all we want the maximum salary of these players so what are we trying to do here right take a look at this we're trying to find uh we're running an aggregation function on the columns salary but we're trying to group them by the team and the college right again as i told you it's one simple piece of uh one simple line of code that can do a lot and eventually answer a very long question uh with a tiny answer right the code in fact are smaller than the question itself that is the magic of python right superb coming to the seventh question the seventh question states what is re-indexing in pandas we know that uh every single data frame or series that we use in pandas have indices right that is the location that we use to actually uh work with the objects that are present there the entities that are present in the list in a data frame whatever it is now when we're trying to re-index all we're trying to do is we're trying to reassign the index right re-index is basically a short form of reassigning the entire index that's about it guys uh to actually add on to more uh instead of you just saying hey reindexing is just realigning uh the index i want to make sure you guys uh give a comprehensive answer let's quickly take a look at one simple example right let me zoom out a little fantastic what is reindexing okay so what are we doing ladies and gentlemen we importing pandas the library of course we have a couple of bikes in the list we have a couple of cars in a list and all we are trying to create is a two-dimensional uh data frame with that but if you take a look at this these three lines is where all the magic happens right first of all we are trying to create the data frame without the data frame you cannot do anything and once you have the data frame we need new indices value right new index values that we need to put so we'll have to create a list and use this list the data that is present in this list will become the new index right how do we do that df.index we have the dot index a helper that will eventually get us to do this and all we have to do is assign it to the values that are present here now let me quickly go on to run this piece of code instead of this saying 0 1 2 3 and 4 it's saying 10 20 30 40 and 50. that's because i have told it hey i want my own index values not what you provide so please use this attached as an index how cool is this guys there's not a lot of code that you can actually have but then the output is pretty impressive all the time right fantastic now coming to one very important concept as we already discussed in the beginner section the lambda function is usually asked a lot because people tend to stumble upon either writing the logic or not answering it fine right so let's take a look at question number eight question number eight says create a lambda function which will print the sum of all the elements that are present in this list guys take a look at it on your screen uh there is a list given there are a couple of elements right there somewhere around six elements in this list now we already know how lambda function works it's basically a temporary function that we use it's a nameless function that we can work with right now all we have to do is take in or any and all the elements that are present in a particular list add it up give out the sum right again this is a very simple example but it can get really confusing so let me uh break it down into simple terms right now this is a short program i can zoom in a little first of all we are trying to uh you know use this logic guys basically we have one fantastic library called as function tool so it's also called as func tools from there we are trying to use this uh we're trying to bring in the reduced methodology and all we're trying to do right the lambda function logic it lies here for every single element lambda x x of y such that x plus y all we're trying to say is hey all the elements that you see here just add them one by one in the order and eventually just store it all in a variable called sum and print us the sum value right so you can see that there are sequences 5 8 10 20 50 right now as soon as i hit run all it is trying to do is add all these elements 100 plus 50 is 150 170 180 188 193 right now you can have uh you know any number of elements that you want guys so maybe let's just say i want another 100 right now the output i should have is 293 instead of 193 let me just go back on this so that you guys uh you know will make sense of the our question as well as the answer right 193 absolutely fantastic guys now we're going to be discussing another uh you know pretty important question it's called as the v-stack now we stack headstack basically stands for vertical stacking and horizontal stacking these are really important questions that have really high probability of being asked right so please pay attention here the question states what is we stack in numpy can you please give an example for the same right now numpy is a super popular uh uh for as a library itself now its popularity comes from functions such as vstack right whenever we have you know all this data that's present where we have to align it uh via we have to align all these rows vertically that is when we're going to be using v stack literally the answer uh to the question lies in the name itself we stacking talks about you guys vertically stacking these values but then hey it's very important to know that all these rows that you're trying to stack they must have the same number of elements to make sure that nothing gets skewed right as always even though it's a theoretical question that you that they have asked you the interviewer might have asked you do take a second to maybe either write down uh you know one line of logic basically all you have to write is this line of logic right now look at this we have a one numpy array with a couple of values we have another numpy array with another couple of values right but one thing you have to take notice it says 10 20 30 40 50. the next one is starting with 50 as well right now let's take a look at the output first to understand what's going on take a look at this it says 10 20 30 40 50 and eventually again it's 50 you have to be very careful uh every time you might try to do this you're like hey there's 52 times there's a good chance that this might not be there but no if we are not dealing with a set we are trying to deal with areas right ladies and gentlemen it can get confusing even though it seems simple but then the entire logic the heart of the logic stands uh it's your np dot v stack of n one comma n two n one is the first array and two is the second array right fantastic that's question number nine let's take a look at question number ten question number 10 states how is python code interpreted right now of course if you are at this level if you're at this point of time when you're watching this particular video this particular question you should know that python is an interpreted programming language and not a compiled programming language like c or c plus plus right so whenever you go on to write a piece of python code let's just assume that it's 10 lines of code this entire thing gets converted into its source code from its source code basically to something called as il il stands for intermediate language intermediate language is something that these uh you know intermediate language is something where it's not operating system dependent python works well on windows python works well on linux python works well on raspberry pi python works well regardless of the operating system that is because it's its code basically gets converted into intermediate language which is understood in fact pass through with all of these other operating systems as well once we have the intermediate language later it gets converted into that particular machines uh uh programming language right machines like machine language again you will know the code machines don't understand anything apart from zero and one right now this would be the answer to this particular question but as we always do let's just take one more step ahead you can definitely go on to say that uh you know having the ability to uh use an interpreted language will definitely give you a lot of advantages in terms of how you can go on to uh you know work with the core because it every single line of code is executed one after the other one after the other and eventually if there is a error on line number seven everything until line number six will work absolutely fine it's only at seven that it gets stuck right so this is something you guys need to know about right fantastic now coming on to question number 11. question number 11 states how to remove spaces from a string in python well it seems like a very simple question but you'll have to be very careful about the functions that you might use right now as you can see from the answer spaces can be removed by making use of two functions the strip function and the replace function now the strip function is basically used to remove the leading and the trailing white spaces right the white spaces that are ahead and the white spaces that are behind but if you try to use the replace function the replace function will eventually go on to remove all the white spaces so the question you must ask yourself or in fact ask the interviewer saying hey okay i can i know how to remove spaces from a string but do you also want to remove the leading in the trailing white spaces or do you want to remove every single white space that are present right now let's just get back to our notebook so that we can understand it right it's just one simple line of code the entire logic is only this much and of course you can write this down to explain it to the interviewer right so we have one string string one equal to great learning great space learning right now as soon as i run this piece of code all we are trying to do is we're replacing space with what with nothing so eventually it just comes close now you can actually replace it with anything that you choose if i just put a here instead of the space it will just put great a learning of course it doesn't make sense the question says replace it and remove the spaces right now let me quickly do undo this run this again and you'll see that we have removed the white space it's a very simple thing to remember you have to replace space with nothing so that's that's the syntax right pretty pretty simple and at the same time pretty effective as well superb coming to question number 12 it states explain the file processing modes that python supports now this is fantastic right because with respect to file handling in python whenever you ask any questions in an interview eighty percent of the time they usually try to expect a theoretical answer from you because you'll have to create a file manually you have to work on the logic you have to build the file open it read it write it close it you'll have to do all of these and there's a good chance that you won't have time to do all this in an actual interview right so it's usually the theoretical questions that are asked so the question asks how many explain the modes that are present first of all you have to understand that there are four processing modes in python right you can either uh work with the file in only a read-only mode as in you can only read it not write anything then of course there's only something called write only write only mode uh will only work if you actually have the files already created you will open it and eventually start writing the read write mode will eventually create a file even though you might not have and uh you know it's going to work on it will help you read it will help you write and perform the operations as well but the last one a stands for append append basically means to attach at the end of something so if you have one file and if you're trying to open another file and move all the contents of this file to the end of file one all you have to do is say append off one or two right because everything at the end of one will basically be the start of everything number two that's uh that's append in its most simple terms but below that there's a thing that says there are certain binary flags that you might have to follow whenever you're working with file operations or whenever you're working with file processing it becomes super important for you to understand that uh you know there are certain binary flags which will help you understand what is going on with the file you can set these flags and you can work with them as well right so again it adds a good amount of value to talk about the modes as well and say hey we have the same names in the case of binary flags as well superb with this we can come to question number 13. it states what is pickling and unpickling this is going to be a question that has to be asked because this is considered super important right now what is pickling pickling is basically the process of us converting a python object in its entire hierarchy right the object hierarchy that is present into a byte stream now why would you want to convert an object hierarchy into a byte stream well to actually store it into a database right this operation if you guys know how to work with data analysis and sql it's actually called as serialization now we know what pickling is but what is unpickling as the name itself suggests unpickling is literally the reverse of pickling where we convert the byte stream back into its object hierarchy and we're done object hierarchy into a byte stream is pickling but a bike stream into uh object hierarchy converting back is nothing but unpickling right so make sure you're talking about serialization as well there's another name for it i think it's going to add a good amount of value if you see that hey pickling is also called serialization that would uh impress the interviewer as well okay fantastic coming to question number 14. question number 14 states how is memory managed in python well there's a question about memory management right now you have to understand that in python most of the data is stored in private heaps right it contains all the data structures that are needed to work with it contains all the objects that we're going to be working with as well now if there is a heap where you can do all of this who is managing the heap well the heap is actually managed by the interpreter itself and in fact if you have a curiosity saying hey can we look at this heap access it and mess with it the answer is no the programmer will not get access to the private heap where memory is managed in the case of python right and it's a good thing you don't have to worry about any of these because python the memory manager that is present in python does all the memory allocation de-allocation automatically as well and of course python also has a garbage collector which eventually frees any sort of memory if it requires uh more space in the heap right so automatic allocation there is a garbage collector to remove it as well so you have nothing to break your head about in terms of memory management in python python will do all of it for you but if you're asked this particular question you have to talk about the heap you have to talk about who manages the heap does the user have access to the heap what does the python memory manager do and also talk about how everything from the data being input all the weight of the data being output as in thrown out or deleted is handled by python right super now 15th question states what is unit test in python ladies and gentlemen there's two ways you can be asked this question this is unit test in a single word and there is another unit test in two words right now unit test unit space test is basically a methodology of how you can go on to test uh your piece of code or your application but unit test as a single word is nothing but a very simple again you guessed it a unit testing framework in python right you can go on to talk about how you'll be sharing the startup of your code how will be how you'll be shutdowning the code maybe in terms of tests in terms of actually talking about how you can automate these tests and eventually have independence from these tests and the entire reporting framework right so this unit test basically splits out the entire part of unit testing and brings it to python in a very easy way it's a fantastic framework if you are looking for software development jobs in the line of uh you know by using python this is something you'll have to know and uh there are definitely multiple tools out there that will help you debug but understanding that there is a framework which will do this for us is hugely advantageous guys all right let's move on to the next question coming on to question number 16 it states how do you delete a file in python right now usually when you ask the file processing modes or anything related to files uh you'll have to talk about the mode you'll have to talk about how you'll have to open the files close the files and all of that but once you not just talk about working with these files there's a good chance the interviewer might say okay now that you're working with the file i don't want the file anymore so how do you delete it well there is another fantastic library in python called as the os right i mean eventually when you're working with all file ready file related operations you are going to be using that so there's more than one way of how you can delete a file in python take a look at the syntax here os dot remove a file name or os dot unlink a file name right now eventually in a perspective of a user in the perspective of an application builder both of these on the back end work in a pretty similar way so whenever you ask this question you can eventually uh give out a technical answer saying hey i can use this or i can use this right so instead of just saying uh to delete it i want to use os.remove try to think of something else try to think of more than one way of how you can attack the problem and solve it at the same time fantastic with this let's move on to the 17th question the 17th question states how do you create an empty class in python why would you want to create an empty class will be the first question that might come into your head as soon as you read this particular question right basically it's simple guys uh to go on to create an empty class we'll have to use the pass command right there's a command called pass now whenever we we define an object whenever whenever we define a class object uh if you don't want to use it just just have the pass command there and none of that will be used right so a pass command is nothing but a statement whenever you say pass even in real life when you say pass it's similar like it's like i don't want to do something i pass it on similarly you're telling python hey pass on this piece of code don't execute it just move on from there now that is one thing that you'll have to understand is that we already check this out in fact even practically as well again if you're at this point of time where you do not know how to create an empty class or if you do not know how to work with the pass statement i suggest you head back and take a look at the beginner section once right superb coming on to question number 18. question number 18 states what are python decorators interesting what are decorators are they used to decorate well i'm just messing with you right in fact they are but what you have to answer it uh answer when the interviewer asks you this you see that decorators are nothing but functions which will take in another function as an argument right so you have the first function and you're sending in a second function as an argument but all we're trying to do is we're trying to just send it as an argument rather than change the entire functionality of the first function that you eventually sent it to right so this is where you can go on to use a function bring in values from other functions and dynamically start working with it without breaking your head or without you having to change the base function itself right now i understand that this can get a little confusing so let's actually quickly take a look at this practically right now i'll have to zoom out a little bit here now you can see uh we have a function here it's called as smart divide but with respect to smart divide you can see that we are sending in a function as a parameter right now here all we are trying to do is uh have a function which will basically give us how we can go on to uh you know divide some values guys here is the entire logic for divide of course to divide two numbers you have to pass two parameters a comma b and all we are trying to do is we are printing a divided by b right now as soon as i go to run this piece of code uh we have called the particular function here we have called this uh function here right now we're saying divide one comma zero it says hey make make sure the denominator is not 0 right this entire value got passed into this function and this is the statement that is being printed even though the code lies in another function you can see that we've passed it to this particular function to have this output right take a second to take a look at the code and eventually it's a very simple piece of code that you'll understand right we have we're trying to return the function of a comma b and we're trying to return the inner aspect of it because this is the entire function that we are this is the thing that will give us the answer right superb guys now with this we can take a look at the 19th question the 19th question states what does early binding mean that's interesting what is the meaning of early binding right now if you guys have been very familiar working with object oriented programming structures oops as it's called you'll have to know that early binding is used there a lot right early binding is as the name itself suggests even before we are trying to work on executing the program even before it gets compiled or worked on uh the entire uh value assignment for example if you say a equal to three in python when you run it and when the interpreter runs through it is only when it gets executed but what if i want the value of a to be three even before my code is executed that is where early binding comes into the picture it will finish all these assignments so that you will save a ton of time with respect to the program efficiency with respect to you having to run that cma equal to three piece of code maybe a lot of times in the entire project right so guys this is an important question whenever the again the answer lies in the question itself so whenever you ask this particular question talk a little bit about oops talk about what early binding is talk about why you would want to use it talk about where you want to use it all these basic w questions what where why and eventually even how as well right so depending on what the interviewer is expecting i would suggest you guys take an approach as this to answer them all right fantastic now guys let's talk about the 20th question the 20th question is very interesting even though it might seem it's uh seem to be uncommon you have to understand uh that if you go go to a python interview there's a good chance that the interviewer might ask you if you're an experienced professional saying have you worked with any other programming language or to what level of proficiency you have in python right now there's a good chance you might have learned more than one programming language for example i can work with c c plus plus c sharp and python right so uh so if i if i've ever been asked this question saying hey what is supported in python but not in java if they're asking about one very specific difference that makes python what it is and of course the answer to this is multiple inheritance multiple inheritance is supported in python but multiple inheritance does not work in java right uh now why would you even want multiple inheritance and how does it work in uh python that doesn't that it doesn't work in java well the logic because it's implemented how the language is built right python is built to make sure that it can help you in a lot of different ways and of course with respect to multiple inheritance this feature itself will give you the ability to maximize any sort of efficiency you are trying to understand with respect to a program right so the simple answer is multiple inheritance and if you're at this point of time and if you do not know the answer to this question or if you do not know what interf inheritance means as well guys please take a second to actually take a look at a couple of previous questions and also make sure that you are very thorough with these concepts right now these 20 questions that we have gone on to discuss are some of the most uh important questions with respect to how you can uh work with if you are an experienced professional right now uh even though we checked out 50 questions for beginners 20 questions completely made for experienced people you do have to understand that even for beginners and advanced users and eventually experienced professional everyone every time you step into a python interview there are certain tricky questions that get asked right now it's very fair to think about questions such as pattern printing think about think about the question when the question is very simple to know but when you as soon as you take a look at the answer uh you'll be stunned to understand that it requires so much of thinking and logic to solve it right and all these questions are usually asked when you're in the interview itself like hey i'll give you five minutes time can you do this now uh this is a very very important section guys we'll be covering 30 questions three zero 30 questions here and each one of them are slightly different to each other and some of them are completely fundamentally different so regardless of you guys being beginners or regardless of you guys being experienced professional i highly suggest you take a look at this because there are so so so many chances that these questions can be asked across a broad spectrum of not just python but even if you're trying to look into jobs like data science with python or be it data analysis with python if they want to understand your approach to python uh you know they can ask you all these questions it's not just data science or data analysis even web development and a lot more right now instead of us having to jump back and forth since all of these are programs all we'll do is actually uh head to google collab and we're going to stay here for the next 30 questions right now let me minimize the uh experienced users section out here now guys is one very important thing as you already know you will have access to this jupiter notebook as well so you can sit and work with it parallely as you watch this video so make sure you guys are doing that right now let me zoom out a little bit so that we can see the entire code right in fact let's zoom in it's just the import statements that are taking up a good amount of space now let's go on to save some space here now so we can scroll down see the entire logic fantastic all right guys look at the question the question states how do you implement a probability plot using numpy and matplotlib now this is a very specific question if you have mentioned that you have worked with numpy i am confident that all of you all have uh there's a good chunk you might have not worked on matplotlib but they want to test your ability of how well you can graph something out right now probability plot is basically using random functions to eventually print one a plot when every time you execute it since the data that you're providing it to be random it will of course create random probability values and map it on a probability curve right now this is what the curve looks like as in when i run it once now all of this is random because what we're trying to do is we're trying to use random values in itself right if you had data to create this plot fantastic in this case it was a random question that was asked so eventually we will have to create our own data now now that you've taken a look at this output let me run it again now as soon as i run it again you see that entire pattern got shifted why because every single value was randomized it got changed and we have new probability values that are present here right so guys you have to be careful if you ask questions like this now here is the code again uh all we're trying to do is import numpy there's a fantastic library called pylab and of course guys you you have to know about sci-fi and matplotlib right is you it's called scientific python it's a fantastic library to work with and eventually we have matplotlib wherein we're trying to import pi plot now matplotlib pi plot c bar all of these are super important data visualization libraries in python all right fantastic let's move on to question number two question number two states given the sample dictionary how would you update the value of apple from 10 to 100 well given the sample dictionary how would you go on to update the value of apple right now the apple value is 10 apple 10 orange 20 banana 30 guava 40. now what they want to do is straight take out this 10 and input 100 right it's a very simple thing all you have to do is this but no you already have an input that you have to work with right it's pretty simple guys it's very straightforward at this moment of time they will try to confuse you by maybe giving you a lot of these values or maybe changing the structure of how they have denoted this as well right it's only to make sure that uh you know you get trigged and you don't know the logic you cannot figure out the logic but fret not all you have to do is fruit of apple what's the rule what's the column that you're trying to access the data off it's 10 we don't want 10 what do we want we want 100 right just one line of code will eventually go on to change that now as soon as i run this you can see that even though input is apple of 10 the output is apple of 100 this seems like a very easy question but there are n number of chances where either you're a beginner who can mess up the logic and not understand okay how can we do this uh because again if you just wanted it in real time all you would do is change the input itself but the input is fixed the output is changing so make sure you guys are paying attention there right fantastic coming on to the third tricky question it states how do you find the common elements that are present in two given sets okay we're talking about sets what is the most important thing that you have to understand about a set every single element is basically unique right now if i give one two three four five six and if i have another six s1 is a set which just has six unique values even though you see seven right now it doesn't care about any repeated values you can have any number of repeated values they're all ignored right so we have two sets one two three four five six uh we have a second set five six seven eight nine take special attention here it says five six these are already repeated here right now as soon as you go on to intersect uh using the s1 dot intersection what are we trying to find out the common elements that are present here the common elements that are present here what five six and five six do not get confused of how a set works uh because that's what i just mentioned here but the question is asking the common elements in two sets not not a single set right in that case the intersection function works beautifully well and you will see the common elements i'm sure we would have learned all of this back in our school or in our college right intersection union all of these functions all right guys superb coming on to the fourth question now the fourth question states implement the logic to check if a number is a palindrome or not now guys if you are a fresher or if you have somewhere around one or less than two years of experience this question has to be the question that that usually get asked in fact we have multiple questions all the 30 questions that we're going to discuss right now are super important for both beginners and experienced people well how do you know that a number is a palindrome or not now let me just hit enter because i want to actually type in a bit of comments for you guys right now uh now is 10 a palindrome well 10 is not a palindrome because if you reverse 10 you get 0 and 1 0 and 1 is not the same as 10 but what about 121 121 even though you write it backwards is still 121 right that is basically what a palindrome is guys when you reverse it it has to remain the same now this entire reverse logic again is super common super popular if you're at this point of time you guys should know this logic if you do not know pay attention all we're trying to do is assign a value of n to temp we have rev equal to zero rev talk about reverse and we are running a while loop while n is greater than zero first of all find the modulus of the number with respect to 10 we're trying to cut out the unit digits and we're trying to remove the place value now when i write 121 it's not just 1 to 1 it's 121 right to make sure that we remove all of these place values and to make sure that uh you know we have the reverse of it first of all this entire thing guys is nothing but reversing the number what you do after reversing is check it with respect to the original you have the original you have reversed it compare if it's the same done it's a palindrome if it's not same it's not a palindrome that is literally the logic guys four or five lines of logic but a fantastic program uh let's just enter 10 is going to say 10 is not a palindrome of course it's not let me run it again now uh let's try a really complex number one triple three one or uh yeah let's have this number right two one triple three one two as soon as i go on to run this this number is a palindrome why no matter what side you write it from it's going to be the exact same value right first of all we're removing the place values we're reversing it and we're comparing a reverse operation to the original one and we are done superb guys now coming on to the fifth question now for a couple of questions from now we'll be discussing a pattern questions guys pattern questions are absolutely asked i don't want to say that there is a high probability of being asked i know for sure that these questions get asked in most of these places right so beat uh beat startups beat multinational corporations these are very common standard questions that they're gonna ask so if you know how to tackle this well you're in good hands to land a fantastic job look at the pattern what is the pattern trying to say uh if you take a look at it in the column aspect it says one two three four five the next one there is absolutely nothing we're starting from two three four five again one reduced three four five another dimensional reduce four five another one which just prints out five hmm now how can we go on to think about the logic well we have two loops here one is to control the range of the data the other one is to control the movement of the data in itself right so you can see that input in range of 6. now why are we taking this to b6 well all we are trying to do is understand from the range from 1 to 5 right we want 1 all the way to 5. for i in range of input number well basically it's the input number here all you're trying to do is print it give out one space in the middle and once you do this once you will have one next you'll move on to the next line you'll print 2 2 once you move on to the next line 333 so program is executing this in a row wise manner one two two three three three four four four five five similarly uh let's go on to run this program and you will find this same output right the execution is happening row wise but you can go on to understand it column wise as well and again with these tricky questions uh you might be asked for more than one way to actually solve the same problem right so make sure you're paying attention there as well now this was fun uh all we had to do was print the numbers but what instead of numbers is a simpler question maybe for a beginner that says hey i have a couple of hashtags that i wanted printed with this left justified triangle right so it's always one two three four five six seven elements in each and every row that i just mentioned right all you have to do is uh you know create a function called as pattern print first of all we're going to be starting from zero because the first time we want a count and a print we just want one hashtag there what are we doing if we printed this once have a tracker or a flag there to ensure that you're telling python hey this was printed once add one to it and print it that many times if this was printed two add one to it and print it these many times such as one python knows it's printed at one time next is like hey i have to print it two times next python is i have to print it three times and that is it right of course they've asked you for one two three four five rows that's the reason we'll be sending the value of n to b five now let me go on to run this piece of code and you can see that it is that but what if you want maybe six rows instead of uh or five well big d just send the value of six to the function and it will go on to print it using the same logic right all right let me just turn this back to five so that you guys have the correct notebook with respect to the question superb we have five rows we have printed the hashtag this one is actually a bit simpler compared to uh you know changing numbers or moving with respect to digits ascii values all of that all you're trying to do is print a hash eventually we don't have any spaces here because the input does not have any spaces in fact if you want spaces just put a space here go on to hit print and you have beautiful looking white spaces in between as well simple right well let's jump back to take a look at more numbers this is this uh time we're not taking a look at one two two three three three four four four we are trying to have all the columns as zero next columns as one the next columns has two next columns as three four but we're trying to reduce one dimension every single time we go on to do this right so take a look at the pattern write down the pattern and see if you can build all the logic on your own guys any of these tricky questions that we are trying to discuss i want you guys to pause the video wherever uh you find it fair uh pause it try to write the logic on your own and later compare it with what i'm teaching you guys or in fact if you find another method to achieve the same thing you can do it there are many methods of how you can solve this particular problem right but it's very important that you think of it first rather than just taking a look at the output and saying ah i got it right it can get very confusing during the interview as well now here again we'll be considering two loops uh we have the outer loop here this outer loop completely handles the number of rows that we have to print right how do you know that you're going to print we can understand it as humans in a columnar fashion but python looks at it as rows so how many rows do we need one two three four five so basically the number that we are going to have to input here is five right that is the outer loop that discusses the number of rows now we need to print the actual numbers after we understand how many numbers we have to print that is where this comes into the picture the inner loop talks about the logic wherein you just find a number add one to it and just print it out if it's zero in the first row you just jumping directly to the next one the next line as soon as you see zero you'll have to add one to it and print that element again jump zero plus uh zero one and again two uh right as you g you're basically jumping one one line and just attaching one more element there you'll have to do it in order and this simple loop is going to do this right now let me uh remove a couple of spaces here so that you guys can look at this better this is the entire logic guys now that i've just hit the play button on this piece of code it says how many rows do you want in your pattern now how many roses are they expecting one two three four five rows all i'm going to say is hey give me five rows and as soon as i hit enter and scroll you'll see this right zero zero one zero one two zero one two three zero one two three four right guys i hope we are clear with these three pattern questions that we discussed because the next pattern question that we are about to discuss talks about the pascals triangle pattern pascal's pattern factorial or reversing a number all of these are really really common questions that get asked so you have to prep for this and you have to know this by heart right well what is the pascal's triangle the pascal's triangle basically gives you an output that looks like this guys uh you can see the comment that has been made uh here right so uh you have to understand how the uh variation in terms of permutation and combination works because here for a pascal triangle the values are 0 c 0 and 1 c 0 1 c 1 we jump to the next line 2 c 0 to c 1 to c 2 jump to the next line 3 c 0 3 c 1 3 c 2 3 c 3 jump to the next line 4 c 0 1 2 3 4 again for 5 it's 5 c 0 5 c 1 phi c 2 5 c 3 phi c 4 5 c 5 and so on right this is the pattern that we want to print but instead of printing 1 c 1 we have a formula for ncr right it's n factorial by n minus r factorial into r factorial this is a very important formula for understanding the combinations aspect when you're learning permutation and combination it's a very simple thing guys we're trying to import the math function we're from the math function we're trying to import factorial because uh all of these things instead of manually finding the factorial we have a function that will do it for us easily right in our case uh x is basically n uh y is basically r uh you know it's basically uh n factorial by n minus r factorial into r factorial right let me go on to run this piece of code and as you can see it's going to give you an output which looks like an actual triangle this is what this is 0c0 what is this 1c0 what is this 1c1 2c0 2cc anything n c 0 is always 1 right that's the reason all the first uh columns is going to be the same but all the last values is also the same what's with that well 0 c 0 is 0 1 c 1 is well zero c zero is one one c one is one uh two c two is one three c two is one now how am i saying all of these well i know the concept by heart and if you if you just run the values by calculating the factorial this is the exact output that you're gonna get right so printing the pattern should not be of any confusion but the logic that you put inside the pattern is happening in one particular line guys again the outer loop talks about how you're traversing around the triangle but the inner loop talks about what exactly it is that you are putting in this particular loop right so this is a very important question guys make sure you are using this when you are asked now with that coming to the next question the ninth question here we don't have hashtags here we don't have numbers uh we don't have anything else we have a b c d now abcd are these characters of course you already know this uh now how do you go on to print the character and make python understand how to print capital a capital b capital c well python understands characters and so in terms of a value called as the ascii value right so all we have to do is find out the ascii value for this keep incrementing it everywhere and just like the number solution zero one one two two two three three three four three three three four four four four it's the same logic there but instead of passing a number we are trying to just pass the ascii value and once the ascu equivalent is printed it's nothing but a now the capital a the ascii value for capital a is 65 capital b is 66 capital c is 67 so on right there's an entire list that you can have so all you're trying to do is ask for four rows and again the outer loop always handles how many total rows that you want this this number is the magic number the input loop however basically talks about how many columns that you want here now how many columns are we expecting here again of course and this is the left justified triangle if you have five rows you'll have five columns as well right and here is where the magic in terms of having the ascii equivalent happens you input one you input two you input 3 or you give any sort of character to it you will have the ascii value so you have to convert the given character into ascii convert the ascii back into the number just print it out we want 4 rows of abcd here so as soon as i go on to uh you know you know print this piece of code it says enter number four so let's just put in four as soon as i hit four uh it should go on to print a bbcc dddd right uh this lines eventually uh you'll have to increment it because you want to understand that there are more rows right we're talking about the inner loop where we're trying to move around the triangle so whenever you guys are executing this alongside me take second to understand how not only the flow of the for loop works but how the inner loop also talks with the outer loop right guys that's a very very important thing fantastic we have printed this pattern now there's a very good chance if they're asking you a lot of pattern questions and characters they're going to say hey okay so why don't you print us the entire alphabet in this particular order a b c d e f uh g h i j so basically for every row there is one increment in terms of how many numbers can go first row one second row two digits third row three digits or three characters fourth row four characters fifth row fifth character five characters and so on right now this makes our job very easy we're doing the same thing we're converting uh the number equal to 65 because this is the ascii value later we are sending it to the program to say hey whatever is the value or whatever is the digit or the character that has ascii 65 print that for us similarly the outer loop talks about the number of rows the inner loop talks about how you can how the values actually change into these particular asciis right this is where uh we can doing the ascii uh value conversions and uh this is where the ascii value conversion is happening sorry and this is where we are trying to implement a jumping and increment every single time now how many rows have they asked guys one two three four five six let me go on to print uh let me go to run this and let me just type in six we will have the output to our particular answer but since we are running ascii values you have to understand that uh you know what happens if i input 10 now there won't be so many abcds to put there right look at this uh z ended pretty much even before it came to a point where it could end it in the triangle itself but after that whatever is the ascii value of capital z the next ascii values or left bracket all these operations that are there you have to understand that capital is ascii value is extremely different from the lower case ascii value that's how the computer understands the difference between a capital a and a lower a right so even if you have to do it for 10 all you have to do is input 10 and finish it guys now let me go on to input 6 again and we will have the required output now guys make sure you're taking it slow pause the video watch out for how uh you know i'm explaining in terms of what each of these loops does and work along with it side by side as well all right super enough coming on to the 11th question the 11th question says if you have a dictionary like this they have already given you the dictionary this is k1 of 10 k2 is 20 k3 is 30. okay this is a dictionary what do i do with the dictionary ah the question is how would you increment the values of all the keys we're not trying to use the replace function to replace one value nor can we use the replace function a hundred times to do this manually so how do we increment all of these right so it's a very simple thing uh just take the same dictionary make sure you are running the loop because a looping operation since it's a common operations and going for all the uh values that we're trying to increment now what are we trying to increment they're asking increment the values of the keys right of the keys we want to make sure our key value will go up once all i'm trying to do is i'm trying to take d1 dot keys in a function for every i that is present there just add one more now as soon as i go on to print d1 dot values you'll see that it should say 11 21 and 31 instead of 10 20 and 30 what if i want to add a 10 to it instead of one it's a simple change of logic there uh just run it again and you can see 10 got added right instead of 10 it's 20 instead of 20 it's 30 instead of 40 uh instead of 30 it is 40 right simple guys it's so it's a very simple piece of code but whenever you ask this in the interview at that moment of time uh there's a good chance you might stumble upon something in this logic is not right you're not able to figure out how to print it or you're not figuring out how to work with the uh looping uh statement as well right now i'm sure this will give you a good amount of clarity to go about doing that all right guys coming to the 12th question the 12th question states print random numbers using the random library well you can do two ways one you can just print any number that you want from the library using this tiny tiny piece of code but they can also say ask you a question saying hey i want to uh print random numbers but in a specified range so let's just say that they want to print all random numbers between 10 and 20 right now you can go on to hit play as you can see here any number of times and every time i do it the first number is going to be a value between 0.0 and 1 and the second value will be using the random function we have the range that gets specified here so everything from 10 uh to 20 including 20 that's 10 11 12 13 14 15 16 17 18 19 20 all of these will be printed in a random order there is no order to this every time i go on to run this it'll just print out one random value as you can see right fantastic guys now moving on to the 13th question uh the 13 question says denote the usage of args and kw arguments in python hmm rx it usually is a it usually starts with the star star arcs and double star kwrs right like just like this the function arguments here now what does ours give us that kw arguments does not give us well first of all you have to understand that if you have any unnamed arguments uh your args is going to pick it up if you want any any named argument your k-w-a-r-g s is gonna pick it up right take a look at this i have passed in four pa three parameters to this particular function called func one and uh first of all we have two values which don't have any sort of names associated with that but third one has my name my name is right now this is gonna go and be picked up by kw arcs while these two will be picked with arguments if i'm just printing the unnamed arguments i'm gonna have an output of one comma hello but if i also want the named arguments it's gonna of course print and erode as well simple straightforward yet you can be pretty much confused if you do not know that you have to pass a named argument for kw arcs to work right now if you miss this particular thing this particular line uh you will still get the output correct for rx this will just be put into rs and you'll be breaking your head about why it's not kw it's not kwr it's because there is no name associated with it make sure you're compulsory giving a name there as well right superb now coming on to the 14th question the 14th question talks about a beautiful copy operation in python which can get very very very confusing it's called as the shallow copy in python for the people would not know there are two types of copying that you can do in python there's something called shallow copy there's something called deep copy deep copy basically allocates completely new memory copies it from one place keeps it in the second one and the first one remains untouched right that is you just taking one uh banana eventually making two more bananas out of it and not touching the main banana the one banana is gonna still remain there right now here we have one list the first list with five elements one two three four five and all i'm trying to do is second list equal to first list so i'm copying everything that's present in the first list to the second list uh but then i'm doing one more operation here i'm trying to append uh e to just the second list right so as of the output uh the output should now that we're printing first list and second list the output should be one two three four five next line one two three four five six because we are adding six to the second list will that be the output absolutely not we're not doing a deep copy we're doing a shallow copy since the second one is referring to the same address of where first underscore list is the second you change the second one the second list the first lists value also gets changed there are many advantages of why you would want to do this but mostly it's tiny bit of disadvantages which can get eventually confusing will be breaking your head about why this is happening i haven't attached six to the first list it is happening because it's not your fault the memory allocator in python is basically taking the second list instead of creating a new memory allocation unless you want it it will be using the same one and eventually uh it will attach it to the first one because regardless of you printing second list regardless of you printing first list the changes happen in both because both of them are in the same memory location guys it's as simple as that right superb now coming on to the 15th question guys the 15th question states what will be the output of the following piece of code now let me zoom in a little so that you guys can see this better now ladies and gentlemen even before i hit execute and i'm very sure even before you hit execute on your notebook try to guess try to see what they're asking about a of minus one af minus one says hey start indexing everything from the last the next one the uh hyphen minus four states move four positions back okay moving four positions back i am at the six the next one which also says minus one is basically saying take out take single steps to move right instead of going from nine to seven to five instead of jumping two at a time just jump one at a time in the reverse order now as soon as i run this the output that i'm supposed to have should be nine eight and seven right because this is minus one we're trying to go to the last one print the last one jump one step behind print the second last jump one print the third last and you're done you you might be a person who's saying hey it's minus four should we not have six also to be printed see it's minus one minus 2 minus 3 minus 4 but when we're using a range function uh everything between this and excluding this is printed right if you also want uh you know 6 to be printed all you have to do is change this to minus 5 as soon as uh you hit minus 5 everything until 6 is printed uh but it traverses through 5 but 5 is not printed right so this is a you know very important question guys so it can be something as simple as this uh if you just hit minus two you'll basically get nine and seven as the output you're just skipping it twice right so you can ah you can be asked any sort of questions around this so make sure you're very very confident with even the most simplest questions such as this alright guys now to talk about the 16th question the 16th question states how do you print the ascii values of a given character now we already discussed uh the section where we're taking a look at a lot of ascii characters when we are printing the patterns out but you have to understand that they're just saying hey i'm going to give you a value just print me the ascii for it right now there are two functions chr basically converts an integer to uh back to its character but the ord function basically takes uh uh you know the character and converts it uh eventually to a number right as soon as i hit play it will just print me the ascii value of small a which is 97. now what was the uh ascii value for capital a that we just discussed right it is 65 right as soon as i go on to print it it says 65 now it can be anything they can ask you the ascii value maybe for capital z well of course any value that you pass on is pretty simple you can also implement the logic where you just start putting in this entire thing in an infinite loop and just saying hey input a value i'll print out the ascii so as in when you start punching in the ascii values the output is straight up uh as in when you start punching in the character sorry the output is ascii values right 16 is very straightforward all the logic just lies with this the entire working the answer to this entire question is only here but to just make it a little beautiful to look at which is doing this right fantastic guys now the next question the 17th question states what is the easiest way to shuffle a list hmm shuffling a list why would you want to shuffle a list well uh it might always be a case where you want to quickly randomize all the elements that are present in your list instead of you importing the random function using uh you know the random dot random creating your random values or in fact using the values that already present we'll still be using uh the shuffle part of the random function but here we have one list it says you'll never walk alone this is basically the slogan of my favorite football club uh if you do not know the snow slogan for the football club it's basically liverpool right so now as soon as we hit shuffle off this particular list it will give me one random output every time see alone never walk you'll it's it basically uh reverse the entire thing now it's not done on purpose it's random as soon as i run this again it says walk alone never you'll right let me run this again it'll say you'll walk never alone right you can see that it's shifting around and moving it so if ever you think that there is some sort of bias in the data that's present and if you can jumble it around and still work with the logic you can remove that random bias it's called as a random bias guys so you can remove that to work with it so the simple again the logic is just one line of code but when you're an interview uh you really should know this as well right superb coming on to the 18th question the 18 question states how does floor division work in python absolutely fantastic guys now i want all of you all to pick up your calculators because we're going to be doing some uh calculation here right you can in fact do all of this manually as well uh what if what i'll ask you math questions don't look at the syntax there what is 5 divided by 2 2.5 what is minus 7 divided by 2 minus 3.5 what is 7 by 2 3.5 what is minus 7 by 2 again minus 3.5 right fantastic now all of this is good but there is a difference between just division and floor division floor division basically just removes the floating point number and just crashes the entire value to the next lowest value right now as soon as i run this the output should be 2 minus 4 3 and minus 4 yes now why is this this you would have understood right 5 by 2 is 2.5 just throw the 0.5 away you get 5 you get 2 right superb that's great now take a look at 7.0 by 2 this is also great right 7 by 2 is basically 3.5 take the 0.5 kick it out you get 3 and eventually you print the since it's a floating input you have a floating output python is very intelligent to understand since it's a strongly typed programming language right fantastic but these two lines where i'm putting in a hashtag right now the comment this is where something is missing minus seven by two should give me minus three point five if i check out the point five my answer should be minus three and not minus five correct this is a question that the interviewer is going to ask you to trick you the answer is no because if you take a look at the number line and if you have minus 3.5 what is the lower value compared to minus 3.5 it is a value which is still lower than minus 3 which is what minus 4 it cannot be a value higher we are trying to use what division floor division we are trying to floor it to the lowest values right that is the reason why this gives you minus four instead of minus three be very very careful of this the interviewers are gonna try to trick you to save as soon as you you know you say that hey minus seven by two gives me minus three point five they'll be like are you sure now the next thing you might say is okay it might give me minus four then also they'll be like no don't you think it's minus three they can confuse you a lot guys so be very careful with the 18th question but now that you know how to tackle it i am confident that you guys will handle it well right take a look at question number 19. question number 19 states denote the usage of pass by value and pass by reference it's also called as call by value or call by reference it's a simple concept guys whenever you're trying to change the scope of a variable wherever you want to pass the scope of a variable you just want the changes to happen in the new memory allocation rather than the old one right just like shallow copy and deep copy if you call something by its value the memory address remains the same so all you're gonna get is the value that you asked for if you pass it by reference what python is doing in the back end does it sending the memory address of where the data is stored so if you make any sort of changes to the memory uh uh you know the memory address there the data that is stored in the memory address it will change everywhere regardless of the scope of the variable so call by value will only change it in that scope call by references where you're just sending in the address saying you do whatever you want with this address you can copy delete move change in that case the changes will be reflected everywhere right let's take a look at this we have one we have a very simple array three elements one two three and if i just go on to print it out it's it's called by value right call by value is the same it will still give me one two three but when we run call by reference i am trying to uh take it to this particular function and then putting the array value there and appending one more element four now you have to understand that we uh we just uh you know uh passed the memory location to four and eventually it understood that saying hey there is one two three already let me just attach on to the same thing it figured out that there is one two three not by the value themselves or the array itself but by the memory location where the elements of this array is stored right again call by value call by reference are really basic stuff that you must know at this moment of time guys if you do not know it's okay pause the video uh you know many many articles where and you can figure out what call by value are called by references but as i just mentioned it is literally that so even if you are asked a theoretical question you can literally state the answer that i just stated right fantastic now this has to be a question that get that gets asked every single time ladies and gentlemen it says hello world uh double colon of minus one double colon of single colon of minus one will basically give you the output of the last character but uh you look at this right we're just moving on to the last one and just printing uh everything there now what if there is a double colon here that says double corner of minus one this is a very simple shortcut to take a string reverse the entire string and print it out look at this hello world became completely reversed as you can see right so basically minus one c is saying traverse everything from the last instead of the first right if you start put writing everything from the from the last to the first of course it's gonna reverse itself and that is the output that we see if you are a beginner python user attending a python interview there is a very good chance you will be asked these indices tricky questions right as we discussed previously as well we took a look at multiple questions there make sure you are understanding the heart of the logic here right superb guys let's discuss the last 10 questions that i have for you today now 21st question states what is the output of this operation or a list list multiplied by two now this is a super tricky question this is where a lot of people go wrong that i have seen personally as well now i have a list with five elements one two three four five as soon as i multiply it with two what do you think is going to happen 1 becomes 2 2 becomes 4 3 becomes 6 4 becomes what 8 5 becomes 10 correct answer is absolutely not because the asterisk operation will copy the element into another so instead of you guys getting uh 2 4 6 8 10 you're gonna get one two three four five but twice this time right now this is a very very very confusing uh you know output even to someone who has worked with python previously at the heat of the moment if you are asked this question you will just want to say that all the elements will get doubled if it is into three you there is a very good chance you can say hey we are just tripling it right because this is a multiplication operation that we usually use but do not be confused guys if you use this uh operation with respect to a list all you're trying to do is replicate the elements once again so if it is one two three instead of one two three four five what do you think is going to be the output it's gonna be one two three one two three right look at that fantastic right it's very simple very confusing a fantastic a chance for the interviewers to trick you okay coming on to the 22nd question 22nd question states write the logic to check if the given number is an armstrong number or not ladies and gentlemen this is a question that has to be asked because uh they want to understand the interviewer wants to understand if you know what an armstrong number is the second thing they want to know if you of course can work with the logic if you can work with the syntax and all of that right now an armstrong number is pretty simple guys uh basically what we're trying to find out is the cube of every single digit now if i input 153 and if i want to find out if this is an arm strong number or not what is 5 cubed five five 25 fisa 125 correct simple what is 3 cube 3 3 3 into 3 is 9 9 into 3 is what 27 right [Music] now all i did was take this digit find its cube take the second digit find the cube take the third digit find the cube as soon as i did this uh just add all these values 125 plus 1 is 126. 126 plus 27 is 153 so no matter what number you provide if all of those cubes add up to this number it's called as the armstrong number guys uh now if i just put in 10 right uh this logic is wonderful uh what if we discussed not an arm strong number not an arm stock number let's just take 10 right if 10 is your input the first digit is what cube cube of 1 is what 1 into 1 into 1 equal to 1 what is uh cube of 0 0 of cube is 0 right now is 1 plus 0 equal to 10 no 1 plus 0 even though 1 cube plus zero cube is not equal to ten it's only equal to one hence ten is not an armstrong number similarly for four four zero seven four cubed plus zero cube plus seven cube is eventually going to give you an answer four zero three right now that we understood what an armstrong number is this is the entire logic guys this is the pretty much the logic all we are trying to do is take the input from the user the user can input any number he or she wants while they input a positive number right you have to make sure that it's a positive number while the input a positive number all you're trying to do is try to find the cube uh as i told you here also we are taking the place value right this is not 153 this is 153 so we are removing the place values creating individual numbers out of there cubing it and finding one sum if your input a number is equal to the sum of the cubes of all the individual digits it is an armstrong number else it's not right it's very very simple but but if you do not know what an armstrong number is you cannot attack this problem right first of all let's input 10 10 is not an arm strong number now as soon as i run this it says 10 is not an armstrong number fantastic let's run it again this time let's push the values four zero seven four zero seven is an armstrong number as soon as i run this and i come down it says 407 is an armstrong number right we understood what an armstrong number is uh we understood the logic that goes on to working with an armstrong number and we also figure out a way to print if it's given number is an armstrong number or not right if you were a person who just said okay so armstrong number is done which number next well the next number that you'll have to take a look at is a perfect number now what is a perfect number we know what an armstrong number is but what is a perfect number a perfect number is basically sum of the individual divisors of all of these values right to find out if 6 is a perfect number uh what are all these digits that you can divide 6 with right 1 into 6 is 6 2 into 3 is 6 3 into 2 is 6 as well so 1 plus 2 plus 3 gives you 6. the logic is simple guys so all you have to find out uh if this is a perfect number or not is take all the divisors out of it every number that gets divided just add it on you will get it right now if now that we've said that even 28 and 8 1 to 8 are also perfect numbers let's let's actually find out why 28 uh is our perfect number right now for 28 what is the logic that you are you think you should follow find out all the digits where uh 28 is divisible it goes with one it goes with two uh it doesn't go with three uh it goes with four it doesn't go with five six doesn't go guys six table are you is calculating six fours are twenty four it will not go right so seven seven the uh threes are uh twenty one seven fours are twenty eight right yes seven also works now seven is done uh does it work with eight i don't think so does it work with nine no ten of course no eleven no twelve now is stop twelve twos is what 24 so no does 13 work no what is the next one that works well it's 14 everything in excluding the number itself right now of course even 20 28 into 1 is still 28 but the logic of a perfect number is to consider everything apart from this number right now let's add this 14 15 16 17 18 19 20 21 21 plus 7 is 28 right so the individual sum of all of the digit if you get the input digit back simple it's a perfect number right the logic again is very simple just break the number down remove all its place values consider each angle each individual digit sum it up if your sum is equal to the input tada it's a perfect square right all you have to do is find the divisors look at this look at the logic here it says number mod i equal to 0 if it divides the number perfectly without any reminder find all those ones uh and make sure that you're just printing it out at the end of the day right so let's just put in 6 and 28 now as soon as i put in six it should say six uh hang on i have an error here now uh let's just actually go on to track why this error is there okay my bad it doesn't know what capital number is right because this is this doesn't stand for capital number this stands for number input right as soon as i hit run again it should work fine now guys let me go to it six as soon as i hit six it says six is a perfect number let me run it again let's take a look at 28 now 28 we already saw how it works perfectly and we know that it's a perfect number okay we checked out the logic for a perfect number but let's understand maybe a non uh perfect number right i'll just put in 3. now 3 is not a perfect number again you can guess why right 3 is divisible by only 1 and 3 if you exclude 3 you only get 1 1 is not equal to 3 hence it's not a perfect number again the heart of the logic is just these lines guys you're using an iterator you're trying to find it out by you're trying to find out all the numbers whether it divides it perfectly just add it up compare it with respect to the input if it's the same it's perfect if it's not it is not perfect right we took a look at armstrong number we took a look at perfect number the next thing we're going to take a look at is a strong number now a strong number is similar to these other numbers that we just discussed but here we're going to be considering factorials the sum of factorials of every single number if it is equal to your input it is strong numbers right the sum of the factorials of individual inputs that is what makes a strong number let's take an example in fact i have an example already on your screen here guys if we go on to put uh the input as 145 uh just split it into separate digits one four and five just just find out 1 factorial 4 factorial 5 factorial add all these up if it is equal to 145 it's a strong number else it's not right all we're trying to do is take an input copy to a temporary variable we have a while loop here in fact we have two while loops one is to check out the structure break it into individual digits the next while loop is basically the entire heart of the logic where uh we're not just trying to break the number but we are also trying to find out if the factorials add up to the sum and once we have the sum at hand we are trying to see if this sum is equal to the input look at this if sum equal to temp why temp because we have assigned the input number uh to be 10th right we're just copying it and placing it there now that we understood this let me run it let me go on to find out 145 first to see if the logic works it says the given number is a strong number so let's go on to type a number which is not a strong number maybe 12 as soon as i go on to type 12 what is 1 factorial 1 what is 2 factorial 2 what is 1 plus 2 is 3 it is not 12 that's the reason why this is not a strong number i hope this is clear with all of you all right guys superb i know we are discussing a lot of patterns a lot of number printing one after the other you have to understand even in an interview situation there is a very good chance you can be asked one after the other with respect to different logic so you have to be prepared on any front uh to attack and solve the problem right so that's the reason we are trying to give you guys all these top questions when you can easily use this and go on to asu or interviews right fantastic coming on to the last five questions in fact the sixth question here uh it says the 25th question states write a program to find out the large second largest number in the list absolutely fantastic if you have ever given an sql interview or a data based interview there's a very good chance this will be asked there is a very easy way to find the maximum value just use the aggregation function max it's going to give you the last value but what they want here is not the max value but the second largest value not the largest the second largest hasn't one previous from that so if i have an input let me just go on to type this out for you guys uh if i have an input 1 comma 2 comma 3 now what is the largest number here 2 what is the second largest number here sorry what is the largest number three what is the second largest number two in fact let me take a different example four five six seven one thousand right what is the largest number one thousand but what is the number that is less than a thousand but greater than six it has to be seven right so this is how we try to find out the second uh uh largest one now quickly taking a look at the logic first of all we have a for loop we're trying to find the range from one to the digit including the last digit as well here we're trying to get an input from the user all we're trying to do is attach whatever input we got to our list and sort it out once you attach the number that you get in the list and start sorting it out from the last element and just print the last but one element this again is where all your logic is happening right so you're inputting the element you're attaching whatever it is that you just inputted into the list as well and not just that you're also basically printing it out while printing out the logic uh of the list is where the magic lies now as soon as i run this it'll say how many elements do you want well i just want to input four elements let's just say um so i want to input 10 i'm going to input 20 i'm going to input 4 000 i'm going to input like 6 lakhs or 60 lakhs or whatever that is 60 lakhs right now 60 lakhs is the most maximum one one before 60 lakhs is four thousand so i have four thousand very simple logic it's very easy to print the last one but you're gonna have to work on printing this last but one element right guys it's very straightforward at the same time it is very vital that all of you all know about this right superb coming on to the 26th question it says what is the logic to quickly swap the first and the last element in the list okay wonderful we know how to work with the list we know how to reverse the list we know how to find out the index of the last element which is minus one we know the index of the first position which is again zero python index is from zero but what they are asking for is saying find the first one find the last one change it out right so this is where the swap logic the heart of the swap logic is first of all we try to create a temporary list and just put the original list there uh so it's the simple logic guys a equal to b b equal to c c equal to a right you're eventually swapping the first and last values but the name here is just instead of the characters that i just said it's the list as soon as i go on to print it uh you'll see that this is our input list our sample list right the input is 11 20 30 40 50 but the output is 50 and 11. you can see that these first digit and the last digit got swapped right in fact doesn't mean uh there's a sticker on whatsapp with rj there's someone doing this right so that's what i can think of as soon as i saw this okay guys again all you have to do is input a sample list write the logic to copy it equal to b b equal to c c equal to a and you are good to go but here what we want to find out is to find out the maximum size and one minus that instead of size why are we doing size minus one is the question you're supposed to be asking right now the answer to that is python indexes everything from zero instead of one so if you have a programming language which indexes from which indexes from one rather than zero you will just say uh temp equal to sample list of zero zero equal to size size equal to temp we are seeing size minus one because we are starting from zero with respect to the index right it's all simple straightforward questions as soon as you look at the answer but as soon as the answer is hidden and just the question is shown to you you can be you can stumble upon it and you know take some time to think as well right so make sure that you guys are figuring this out easily as well fantastic now that we know how to swap the first and the last element let's take a look at the 27th program which states write a program to count the number of vowels present in an input string first of all what is the input string the input string since we're talking about verbals in consonant it has to be characters right now aniruddha is my name this is the input string but to make python understand what the vowels are we have to specify it right capital a to capital e a e i o u should be in the lower case should also be in the upper case right because if you just put it in caps uh python will python is of course treating lower cases very much differently to upper cases because you saw the ascu values are fundamentally different so when i say that check for these i am giving both the lower case and the upper case as well right and eventually we are just sending uh these both functions in fact this has to be input underscore string right which is sending the string value we're sending the vowel list into this to go on to compare and see if it works or not as soon as i hit enter all the output that i should get is first of all it should tell me the length of number of levels so it's giving me the number of vowels that are present in aniruddha right so it's a one two three four five correct five different wells now what are the vowels that it got a from the capital i uh a capital a i u a o a o is from rao and a i u is from anira right and again uh the again the heart of the logic is uh this one particular line just to traverse with each and every single element and you just being very careful about giving both lower case and uppercase it's just passing these values to a function having it in a structured modular way to print it out right guys it's fairly simple at the same time fairly easy to get confused as well so make sure you're paying a lot of attention there superb coming on to the 28th question the 28th question states how do you break a list into n chunks using python now n can be any number that i want if i want to break this list into 10 chunks i can do it if i want to break it into five chunks i can do it now when i say chunks let's see the output first and then work on the logic you can see that this is the input right 1 to 13. now i want to break it into how many pieces in this basically that how many pieces that i want to break it into i want to break it into four pieces you can see this one piece second third fourth even though it does not have enough elements to do the complete the last one it still breaks it right now let's uh make python a little happy let's just put in 13 14 15 and 16 as well right now of course if i'm breaking this into four lists it's going to be equal elements in every single entity look at this one two three four five six seven eight nine ten eleven twelve is one thirteen fourteen fifteen sixteen is one as well right again the logic the logic is basically this guy's all we're trying to do is find the input list now now now what is this particular logic right we already learned this take a second to remember what this is once we create a simple uh nameless function for our logic all we are trying to do is use the for loop and just traverse from zero to the length of the input list and eventually break it down into what into n pieces for us right pretty simple guys it's just a simple list operation that will tell you what is supposed to be done what's the input how many pieces do you want to break it how do you break it print the broken output that is it right four lines four four different things that these lines do fantastic guys now coming on to the 29th and the 30th question we're going to be discussing a bit of exception handling right exception handling is again an exceptionally important part of python as well there are a lot of things with respect to the keywords that you'll be using uh in the exception handling part try is basically used to uh just put in all the code where you're trying to experiment to see if there's an exception that will occur and accept block stands for exception if there is an exception everything under this code segment will execute and if your exception is not caught as in the logic that you put here is completely correct this will not be executed but else will be executed right let me repeat that again in your try block if there is no exception this entire block is skipped if there is no exception this is skipped and this is printed compulsorily but if you uh do have an exception it will come here it will figure out there's an exception quickly it'll jump here to say that there is an exception let's in fact try it out it's saying enter the first number my first number is 10. it is saying enter the second number now i am a very intelligent boy i'll put it to 0 10 by 0 is not done so as soon as it sees 10 by 0 it just came here asked me for input came here asked me for input figured out the logic and it says the output is z but instead of it actually being able to print there is an exception that is there inside the try block that will quickly jump to except block and print this message you see if except is printed else is not printed if else is printed it means your logic is correct and there's no exception let's do it again into the first number 10 i want to divide 10 by 2 is it possible mathematically of course it is possible so this entire block is not at all executed but this is executed right just take a look at this command this command will basically tell you everything you need to know about what is executed what is not executed right fantastic guys coming on to the last question now the last question states how does the finally block work in python try accept else finally right we already know try if you have to experiment something just throw it in the try block and catch if there is an exception we understood this we understood the else as well but the finally keyword something you really supposed to know about this is the fact that no matter what either your exception is caught your exception is uncaught because it's not present no matter what unlike the l slope the else will only work if your exception is not if this part of the code is not executed else will run if this is executed else will not run finally is a good boy finally doesn't do all that no matter what you try no matter what exception you get god bless it will run finally right as soon as i go on to click this it uh we are basically dividing five by zero floor division of five by zero it says hey sorry i cannot divide it so try block got executed except block got executed finally block always gets executed right look at the comment it says executed regardless of exception occurrence either your exception is caught or uncaught no matter what this piece of code will always be executed right so guys these are these important questions that we discussed now of course let me zoom out a little we discussed 50 very important questions for beginners we discussed somewhere around 20 very important questions for experienced users and for both beginners and experience we discussed 30 different programs that brings us to a total of 100 python questions right now all these hundred questions have the highest probability to be asked in this particular year and going ahead as well guys so make sure you guys are paying attention on that all right guys now that was a lot of important questions that we had to cover here right now these questions as i mentioned throughout this particular video are really really important going ahead for your python interviews now we've taken a lot of time to research all these questions to a very good amount of depth to a good amount of detail to make sure that at the end you guys have one video that you can refer for your python interviews right so i hope uh you guys had fun watching this particular video i really hope that you guys took a lot of learning away from this and you're going to use this to ace your python interviews and land your dream jobs right superb on that note guys my name is anirudh rao thank you so much for watching have a fantastic day ahead and good luck for all your interviews ahead right i want to welcome all of you all watching this particular video with open arms into the python developer community right guys okay so bob thank you so much for watching see you if you haven't subscribed to our channel yet i want to request you to hit the subscribe button and turn on the notification bell this is done to make sure you do not miss out on any of the new updates or video releases from great learning and of course guys if you enjoy this video show us some love and do like this video knowledge increases by sharing right so make sure you share this video with your friends colleague and everyone who can make use of it and at the end of it make sure to comment on the video if you have any queries or any suggestions and i'll be more than happy to respond to all of your comments you