Top Software Development Interview Questions and Answers For 2022 | Simplilearn
Ringkasan
TLDRThe video by Simply Learn is designed to help viewers prepare for a software developer job interview with a strong focus on coding questions. It covers essential programming concepts like data structures, algorithms, Java and Python interview questions, and various other relevant topics in software development. The video also delves into specific Java interview questions, such as multi-threading, the absence of pointers in Java, JDK/JVM/JRE differences, and more. Additionally, it explores Python interview topics pertinent to data science. Through the video, viewers can expect to learn about various programming paradigms, coding patterns, and syntax required to ace technical interviews. Each section provides insights into answering commonly asked interview questions in detail, with practical coding examples to help reinforce learning. There are discussions around core concepts, such as binary trees, stacks, queues, sorting algorithms, and inheritance that aim to enhance a candidate's understanding and readiness for interviews in the tech industry.
Takeaways
- π― Understand common coding interview questions for software developers.
- 𧩠Learn about data structures like arrays and linked lists.
- π» Gain insights into Java interview questions, including OOP concepts.
- π Explore Python interview preparation, especially for data science roles.
- π Master multi-threading concepts relevant to interviews.
- π¦ Get familiar with packages and imports in programming.
- 𧡠Learn practical differences between shallow and deep copies in Python.
- π Understand recursion and its application in typical interview problems.
- βοΈ Get hands-on coding exercises for Python and Java interview scenarios.
- πΌ Better prepare for technical interviews with a structured approach.
Garis waktu
- 00:00:00 - 00:05:00
The video introduces the process of software development, highlighting its booming market. Viewers will learn to answer common software developer interview questions, covering basic software development and moving to coding questions and their expected answers.
- 00:05:00 - 00:10:00
The video focuses on conceptual interview questions related to data structures and algorithms. It aims to thoroughly prepare viewers for coding interviews by discussing commonly asked problems and providing a solid understanding of data structures like arrays, linked lists, stacks, and queues.
- 00:10:00 - 00:15:00
Detailed explanations are given for various data structure concepts such as binary trees, recursion, and object-oriented programming concepts (OOPs) like classes, inheritance, polymorphism, abstraction, and encapsulation. These form the foundational knowledge necessary for coding interviews.
- 00:15:00 - 00:20:00
The section provides a deep dive into understanding binary search trees, doubly linked lists, graphs, and the differences between linear and non-linear data structures. It also covers DEQs and highlights differences between stacks and arrays, emphasizing the need for mastering various data structure types.
- 00:20:00 - 00:25:00
The video explains sorting algorithms, significance of variable declaration in memory, and dynamic data structures. Afterwards, it transitions into programming interview questions, starting with reversing a string, checking palindromes, and counting character occurrences in strings.
- 00:25:00 - 00:30:00
Focusing on string manipulation, it addresses finding anagrams, counting vowels and consonants, matching elements in arrays, bubbling algorithms, and insertion sorts. Code snippets offer practical illustrations of the solutions discussed, enhancing understanding through examples.
- 00:30:00 - 00:35:00
Showcases solutions like reversing arrays, swapping numbers without a third variable, and using recursion for Fibonacci series. It includes explaining the factorial logic and reversing a linked list with code examples, offering a well-rounded view of essential programming challenges.
- 00:35:00 - 00:40:00
Explains implementing binary searches, finding second largest numbers in arrays, removing characters from strings, and inheritance through code. It differentiates overloading and overriding further and primes viewers on identifying prime numbers and summing array elements.
- 00:40:00 - 00:45:00
Focuses on practical coding challenges like executing Java without main method using static blocks and discusses multithreading, pointer absence in Java, JDK, JVM, and JRE functionalities. Highlighted are key differences between overloading and overriding.
- 00:45:00 - 00:50:00
Java section addresses packages, exception handling using libraries, implications of importing packages regarding sub-packages, and lack of go-to statements. It questions executability without the main method and dead thread restart possibilities, clarifying common Java interview queries.
- 00:50:00 - 00:55:00
Introduces Python interview questions with an emphasis toward data science. It differentiates shallow and deep copying, explains Python's memory management nuances, multi-threading mechanics, Django's architectural detail, and numpy's advantages over regular lists.
- 00:55:00 - 01:00:00
Python-centered questions examine serialization, argument passing (value vs reference), random number generation, operator functions, checking and replacing substrings, list operations, reverse file contents display, and showcasing function extensions through append and extend.
- 01:00:00 - 01:07:10
Final Python discussion addresses Euclidean distance computation, dataframe and series handling, error troubleshooting in data reading, plotting intricacies, indexing adjustments, and copying techniques. It concludes with questions on overfitting in training models and visualization tool identification.
Peta Pikiran
Pertanyaan yang Sering Diajukan
What is the main focus of this video?
The video focuses on preparing for coding interviews in software development, covering top Java and Python interview questions.
What are some key topics covered in this video?
The video covers data structures, coding interview questions, Java and Python-specific questions, threading, exceptions, packages, and more.
How many coding interview questions does the video discuss?
The video discusses 40 coding interview questions.
What is taught about multi-threading in this video?
The video explains multi-threading as a process of executing multiple threads simultaneously to maximize CPU resource usage.
Is there a section on Java interview questions in this video?
Yes, the video has a section dedicated to the top 10 tricky and frequently asked Java interview questions.
Does the video include Python-related interview content?
Yes, the video discusses Python-related interview questions and concepts, especially in the context of data science.
What programming concepts are emphasized for interviews?
Concepts like data structures, algorithms, multi-threading, OOP principles, and coding specific questions in Java and Python are emphasized.
Does the video provide actual coding examples for questions?
Yes, the video provides coding examples for various interview questions.
Are there any practical exercises included in the video?
The video does not explicitly mention practical exercises, but it provides coding examples and explanations that can be practiced.
How does the video approach the explanation of data structures?
The video explains data structures by discussing their definitions and providing example coding questions and answers relevant to interviews.
Lihat lebih banyak ringkasan video
Trying to Become Good at Programming except I am suffering
FASCISM: An In-Depth Explanation
Spongebob Squarepants: Skin Theory
Onramp Webinar Series E001: Bitcoinβs Full Potential Valuation
Industry Analysis: Porter's Five Forces Model | Strategic Management | From A Business Professor
Demographic transition | Society and Culture | MCAT | Khan Academy
- 00:00:00[Music]
- 00:00:07welcome to this new video by simply
- 00:00:09learn
- 00:00:10software development is a process of
- 00:00:12documenting designing programming and
- 00:00:15testing softwares
- 00:00:17in this tech era there is a boom in the
- 00:00:20market for software developers
- 00:00:22this video will prove a magic portion if
- 00:00:26you are on a way to grab the opportunity
- 00:00:29as a software developer
- 00:00:31by the end of this video
- 00:00:33you will be able to answer the most
- 00:00:35asked questions in the job interview as
- 00:00:38a software developer let's see what all
- 00:00:41we are going to cover in this video we
- 00:00:44will start this video with the basic
- 00:00:46introduction to software development
- 00:00:49and move ahead to know more about coding
- 00:00:52questions with their expected answers
- 00:00:54for an interview
- 00:00:56we will check on the top ask java
- 00:00:58interview questions
- 00:01:01and top ask python interview questions
- 00:01:04again with their expected answers
- 00:01:07so before we begin consider subscribing
- 00:01:09to our channel and hit the bell icon to
- 00:01:12never miss any updates from simply learn
- 00:01:15so let's begin
- 00:01:17hey everyone i hope you're all doing
- 00:01:19great welcome to simply learns youtube
- 00:01:21channel and today we'll be discussing
- 00:01:22about the coding interview questions
- 00:01:25we will begin this video with some
- 00:01:26conceptual questions about data
- 00:01:28structures algorithms and then move on
- 00:01:30to discussing the coding problems that
- 00:01:32are most commonly asked to solve in
- 00:01:33interviews
- 00:01:34these questions will help you summarize
- 00:01:36every important programming concept and
- 00:01:39serve as a perfect preparation resource
- 00:01:40for coding interviews
- 00:01:42by the end of this video i can assure
- 00:01:44you that you will have a proper
- 00:01:45understanding of data structure concepts
- 00:01:47and you will be able to code the most
- 00:01:49common problems asked in interviews
- 00:01:52so let's get started with an exciting
- 00:01:54video on coding interview questions
- 00:01:57before we begin please make sure to
- 00:01:58subscribe to our youtube channel and hit
- 00:02:00that bell icon to never miss an update
- 00:02:02from simply learn so i hope i was clear
- 00:02:05with the agenda now let's begin with the
- 00:02:07top 40 coding interview questions that
- 00:02:09you should know
- 00:02:11programming interview questions are an
- 00:02:12integral part of an interview for the
- 00:02:14developer's position no matter which
- 00:02:16programming language you master it is
- 00:02:18expected that you are familiar with the
- 00:02:20fundamental concepts of the programming
- 00:02:22coding skills are always the deciding
- 00:02:24factor in any programming interview we
- 00:02:27will discuss the top 40 coding interview
- 00:02:29questions you should absolutely know how
- 00:02:32to crack in interviews to get your dream
- 00:02:34job so without further ado let's get
- 00:02:36started so as discussed the first part
- 00:02:39would be the conceptual interview
- 00:02:40questions
- 00:02:42and that the first question we have to
- 00:02:44face is what is a data structure so the
- 00:02:47answer for this question is a data
- 00:02:49structure is a storage format that
- 00:02:51defines the way the data is stored
- 00:02:53organized and manipulated some popular
- 00:02:56data structures are arrays trees and
- 00:02:59graphs moving ahead we have our next
- 00:03:02question that is what is an array
- 00:03:05so basically all the items that an array
- 00:03:08stores are of the same data type it
- 00:03:10organizes data so that a related set of
- 00:03:13values can be easily sorted or searched
- 00:03:16now followed by an array the next
- 00:03:18question we have is about the linked
- 00:03:20list
- 00:03:21so what is a linked list it is
- 00:03:23completely similar to array but there
- 00:03:25are some basic differences like an array
- 00:03:27a linked list is a linear data structure
- 00:03:30in which elements are not necessarily
- 00:03:32stored in a continuous manner so linked
- 00:03:34list is basically a sequence of nodes
- 00:03:36where each node points to the next node
- 00:03:38forming a chain like structure
- 00:03:40so followed by the linked list we have
- 00:03:42the next question which is based on
- 00:03:43stacks so what exactly is a stack stack
- 00:03:46is a linear data structure that performs
- 00:03:48operations in a leaf order
- 00:03:51so in a stack elements can only be
- 00:03:53accessed starting from the top most to
- 00:03:55the bottom element
- 00:03:56so followed by stacks we have our next
- 00:03:58question which is what is a lifo so
- 00:04:02basically lifo stands for last in first
- 00:04:04out
- 00:04:05so it is a way of accessing storing and
- 00:04:08retrieving data
- 00:04:09the data that was stored at the last is
- 00:04:12extracted at the first
- 00:04:14the next one after lifo is a queue so
- 00:04:17what exactly is a queue
- 00:04:19q is a linear data structure that
- 00:04:21performs operations in a fifo order
- 00:04:23so basically fifo is first in first out
- 00:04:28in a queue the least recently added
- 00:04:30elements are removed first as opposite
- 00:04:32to the stack
- 00:04:33so up next we have the fifo so what
- 00:04:36exactly is fifo fifo stands for first in
- 00:04:39first out it is a way of accessing
- 00:04:42storing and retrieving data
- 00:04:44the data that was stored first is
- 00:04:46extracted first
- 00:04:48the next question is about the binary
- 00:04:50trees so what exactly are binary trees a
- 00:04:53binary tree is an extension of
- 00:04:55linkedlist data structure where each
- 00:04:58node has two children
- 00:05:01binary tree has two nodes at all the
- 00:05:03times a left node and a right node so
- 00:05:06these left and right nodes for the top
- 00:05:08node are known as children of the top
- 00:05:10node
- 00:05:12next we have as recursion so what is
- 00:05:15recursion recursion refers to a function
- 00:05:18calling itself based on a terminating
- 00:05:20condition
- 00:05:21it uses last and first start
- 00:05:23functionality and therefore makes use of
- 00:05:25the stacked data structure
- 00:05:28followed by recursion we have the oops
- 00:05:31so what is the oops concept
- 00:05:34oops stands for object-oriented program
- 00:05:36and system a paradigm that provides
- 00:05:39concepts such as objects classes
- 00:05:41inheritance polymorphism encapsulation
- 00:05:44etc so what are the concepts introduced
- 00:05:47in oops
- 00:05:49so the following concepts are introduced
- 00:05:51in oops they are object class
- 00:05:53inheritance polymorphism abstraction and
- 00:05:56encapsulation now we will discuss each
- 00:05:58one of them in a bit more detail
- 00:06:01so we will begin with object a real
- 00:06:03world entity having a particular state
- 00:06:05and a behavior is called as an object it
- 00:06:08can be defined as an instant of a class
- 00:06:11so next we have the class
- 00:06:13a logical entity that defines the
- 00:06:15blueprint from which an object can be
- 00:06:17created or instantiated is called as a
- 00:06:19class so basically class is a blueprint
- 00:06:22which we use to create an object
- 00:06:26so followed by classes and objects we
- 00:06:28have the inheritance a concept that
- 00:06:31refers to an object acquiring all the
- 00:06:32properties and behaviors of a parent
- 00:06:35object is called as inheritance so
- 00:06:37basically inheritance provides code
- 00:06:39reusability
- 00:06:40so followed by inheritance the next
- 00:06:42important concept we have is the
- 00:06:44polymorphism
- 00:06:46so polymorphism is a concept that allows
- 00:06:48the task to be performed in different
- 00:06:50ways
- 00:06:51in java we use method overloading and
- 00:06:53method overriding to achieve
- 00:06:54polymorphism
- 00:06:56followed by polymorphism we have the
- 00:06:58abstraction
- 00:07:00a concept that hides the internal
- 00:07:01details of an application and shows only
- 00:07:03the functionality is called as
- 00:07:05abstraction in java we use abstract
- 00:07:08classes and interface to achieve
- 00:07:10abstraction
- 00:07:11the last one is the encapsulation
- 00:07:13encapsulation is a concept that refers
- 00:07:15to wrapping of code and data together
- 00:07:18into a single unit so basically every
- 00:07:21code we have in the java will have data
- 00:07:24members and data manipulating methods so
- 00:07:26encapsulation is a basic concept that
- 00:07:29brings them together and binds them as a
- 00:07:31single unit
- 00:07:32so followed by oops concepts the next
- 00:07:34important question that we will be
- 00:07:35facing is about the binary search tree
- 00:07:39so explain binary search tree
- 00:07:41a binary search tree stores data in such
- 00:07:43a way that it can be retrieved very
- 00:07:45efficiently
- 00:07:47next the left sub tree contains nodes
- 00:07:49both keys are less than that of the
- 00:07:51node's key value
- 00:07:53the right sub tree contains nodes those
- 00:07:55keys are greater than or equal to the
- 00:07:57node's key value
- 00:07:59followed by that the next question we
- 00:08:01have is the doubly linked list so what
- 00:08:03exactly are doubly linked lists the
- 00:08:06doubly linked lists are special type of
- 00:08:08linked list in which traversal across
- 00:08:10the data elements can be done in both
- 00:08:12directions
- 00:08:13this is made possible by having two
- 00:08:15links in which one of the node will be
- 00:08:17connected to the next upcoming node and
- 00:08:20the other link is connected to the
- 00:08:23previous node
- 00:08:24so followed by the doubly linked list
- 00:08:26the next important question we have is
- 00:08:27the graph so what exactly is a graph a
- 00:08:30graph is one type of data structure that
- 00:08:33contains a set of ordered pairs
- 00:08:36so these ordered pairs are also referred
- 00:08:37as edges or arcs and arcs are used to
- 00:08:40connect nodes where data can be stored
- 00:08:42or retrieved so followed by this we have
- 00:08:44our next question that is called as the
- 00:08:46difference between
- 00:08:47linear and non-linear data structures
- 00:08:50so the first difference is the linear
- 00:08:51data structure in which data elements
- 00:08:53are adjacent to each other and the
- 00:08:55non-linear data structure is a structure
- 00:08:57in which each element can connect to two
- 00:09:00adjacent data elements
- 00:09:03followed by that the next difference is
- 00:09:05examples of linear data structure are
- 00:09:07the arrays linked list stacks and others
- 00:09:10like queues and examples for non-linear
- 00:09:12data structures are trees and graphs
- 00:09:15followed by that the next question is of
- 00:09:17what is a dq so dq is a double ended
- 00:09:20queue and this is a structure in which
- 00:09:22elements can be inserted or removed from
- 00:09:24either end
- 00:09:26followed by that we have our next
- 00:09:27question which says the difference
- 00:09:28between the stack and an array so stack
- 00:09:31follows a lifo pattern it means that the
- 00:09:33data axis follows a sequence in which
- 00:09:35the last data to be stored is the first
- 00:09:37element to be extracted
- 00:09:39next we have the array arrays on the
- 00:09:41other hand do not follow a particular
- 00:09:42order and instead can be accessed by
- 00:09:45referring the indexed element within the
- 00:09:46array
- 00:09:48followed by that the next question is
- 00:09:50which sorting algorithm is the best
- 00:09:52there are many types of sorting
- 00:09:53algorithms like quicksort bubble sort
- 00:09:56balloon sort radix sort merge sort etc
- 00:09:58and no algorithm can be considered as
- 00:10:00the best or the fastest because each is
- 00:10:03designed for a specific type of data
- 00:10:05structure where it performs the best
- 00:10:09and our 19th question is how does
- 00:10:12variable declaration affect memory
- 00:10:15so the amount of memory can be allocated
- 00:10:17or reserved depends on the data type
- 00:10:19being stored in that variable
- 00:10:22for example if a variable is declared to
- 00:10:24be integer type then 32 bits of memory
- 00:10:26storage will be reserved for that
- 00:10:27variable so the 20th question is what
- 00:10:30are dynamic data structures so dynamic
- 00:10:32data structures are the data structures
- 00:10:34that expand and contract as the program
- 00:10:36runs
- 00:10:38it provides a flexible means of
- 00:10:40manipulating data because it can adjust
- 00:10:41according to the size of the data
- 00:10:43so these were the conceptual based
- 00:10:45questions so far we discussed now
- 00:10:47next we will move ahead into the
- 00:10:49programming interview questions
- 00:10:52so at first we have
- 00:10:54how do you reverse a string in java so
- 00:10:57you can see on my screen we have a code
- 00:10:58segment that is capable of reversing a
- 00:11:00string so basically you declare a string
- 00:11:02then take the length of that string loop
- 00:11:04through the characters of the string and
- 00:11:06add these characters in the reverse
- 00:11:08order then print the resultant string
- 00:11:11next we have how do you determine if a
- 00:11:13string is a palindrome or not
- 00:11:16so for that particular question we have
- 00:11:18a code segment which is capable to
- 00:11:20reverse the string and check if it is a
- 00:11:22palindrome or not and accordingly
- 00:11:24provide the result so a string is a
- 00:11:26palindrome when it stays the same on the
- 00:11:28reversing order of characters in that
- 00:11:30string it is achieved by reversing the
- 00:11:32original string first and then checking
- 00:11:34if the reverse string is equal to the
- 00:11:36original string or not
- 00:11:38followed by that we have the 23rd
- 00:11:40question that says find the number of
- 00:11:42occurrences of a string character in a
- 00:11:44string so the following code segment is
- 00:11:46capable to find that particular task and
- 00:11:48to find the number of occurrences of
- 00:11:50loop through the string and search for
- 00:11:52that character in every iteration
- 00:11:54whenever it is found then the count will
- 00:11:56be updated
- 00:11:58followed by that the 24th question is
- 00:12:00find if the given two strings are
- 00:12:02anagrams or not
- 00:12:05two strings are considered as anagrams
- 00:12:07if they contain similar group of
- 00:12:08characters in varied sequence
- 00:12:11so for finding out if two strings are
- 00:12:13anagrams or not we have the code segment
- 00:12:15on the right part of my screen right now
- 00:12:17so basically you declare a boolean value
- 00:12:19that tells the end of the two strings
- 00:12:21are anagrams or not then first check the
- 00:12:23length of the both strings if they are
- 00:12:25same or not then
- 00:12:27if they are not same then they are not
- 00:12:29anagrams if they are same then they are
- 00:12:31anagrams like they might be a chance of
- 00:12:34being the two strings as anagrams and
- 00:12:36followed by the next step is convert
- 00:12:38both the strings to character arrays
- 00:12:39then sort them out and finally check the
- 00:12:42sorted arrays if they are equal or not
- 00:12:44if they are equal then print their
- 00:12:46anagrams and if they are not equal then
- 00:12:48you should print not anagrams the next
- 00:12:5125th question is how do you calculate
- 00:12:53the number of wobbles and consonants in
- 00:12:55a string so you can see on my screen i
- 00:12:57have a code segment which will be
- 00:12:59capable of counting bubbles and
- 00:13:01consonants in a string so look through
- 00:13:03the string so that's the first step
- 00:13:04followed by that increase the vocal
- 00:13:06variable by 1 whenever the character can
- 00:13:08be found as a vowel using the if
- 00:13:10condition otherwise increment the
- 00:13:12consonant variable finally print the
- 00:13:15values of both the vowels and consonants
- 00:13:17count
- 00:13:19the next important question we will be
- 00:13:21facing in the coding interview is how do
- 00:13:23you get matching elements in an integer
- 00:13:25array so for that we have a code segment
- 00:13:28on my screen right away now the steps
- 00:13:30for that are declare an array nest a
- 00:13:32couple of loops and compare the numbers
- 00:13:34with the other numbers in the array and
- 00:13:36finally print the matching elements
- 00:13:38whenever found so next we have this 27th
- 00:13:42question that says code bubbles out
- 00:13:44algorithm you don't have to code the
- 00:13:45entire bubble sort algorithm what you
- 00:13:47can do is just write the code segment
- 00:13:49which has a logic for it so that is
- 00:13:51currently on my screen right now so what
- 00:13:53you basically do is declare an array so
- 00:13:55next what you do is nest a couple of
- 00:13:57loops and compare the numbers in that
- 00:13:58array and then the array will be sorted
- 00:14:00in the ascending order by replacing the
- 00:14:02elements if found in any other order
- 00:14:0528th question is code the insertion sort
- 00:14:08algorithm so this is completely similar
- 00:14:10approach what we followed for the bubble
- 00:14:12sort you just have to write the code
- 00:14:14segment of logic so the steps will be
- 00:14:17first the element in the array is
- 00:14:18assumed to be sorted take the second
- 00:14:21element and then store it separately in
- 00:14:24key now the first two elements are like
- 00:14:26sorted take the third element and then
- 00:14:29compare it with the elements in the left
- 00:14:30of it
- 00:14:32the process goes on until the array is
- 00:14:34sorted
- 00:14:35so next we have the 29th question how do
- 00:14:38you reverse an array so you can see on
- 00:14:40my screen we have a code segment that
- 00:14:41says how to reverse an array loop till
- 00:14:44the half length of the array next we
- 00:14:46have to replace the numbers
- 00:14:47corresponding to the indexes from the
- 00:14:49starting to the end
- 00:14:51followed by that we have the 30th
- 00:14:53question where we have to find a way to
- 00:14:55swap two numbers without the third
- 00:14:57variable so this type of interview
- 00:14:59question will be asked most number of
- 00:15:00times to the beginners most frequently
- 00:15:03now the solution for that has been
- 00:15:04written on my screen right away you can
- 00:15:05check out that and the steps to be
- 00:15:07followed are declare two variables and
- 00:15:09initialize them with the values make b
- 00:15:12the sum of both the numbers then
- 00:15:14subtract the sum that is the b
- 00:15:17from a so a is now swapped lastly
- 00:15:20subtract a from the sum b
- 00:15:23so b is now also swapped
- 00:15:26next we have the 31st question which
- 00:15:28says print a fibonacci series using
- 00:15:30recursion so for that we have a code
- 00:15:32segment which can print a fibonacci
- 00:15:34series on my screen right now so the
- 00:15:36code on my screen can be used to print
- 00:15:38the fibonacci series so basically what
- 00:15:40are fibonacci numbers so the fibonacci
- 00:15:42numbers are the numbers in the following
- 00:15:43integer sequence 0 1 1 2 3 5 8 13 21 and
- 00:15:48so on they can be calculated using the
- 00:15:50mathematical formula used in the
- 00:15:52fibonacci recursive function
- 00:15:55the next question you'll be facing is
- 00:15:57how do you find the factorial of an
- 00:15:58integer
- 00:16:00so we have the code segment on my screen
- 00:16:02which can perform the factorial of an
- 00:16:03integer operation so the factorial is a
- 00:16:06function that multiplies a number by
- 00:16:08every number below it for example
- 00:16:11factorial of 5 is 5 into 4 into 3 into 2
- 00:16:15into 1 which is equal to 120. so
- 00:16:17recursive function multiplies the number
- 00:16:19until it reaches 1. the next one is how
- 00:16:22do you reverse a linked list so for that
- 00:16:25we have the code segment on my screen
- 00:16:26right away you can please check it out
- 00:16:28and try it so if you can find out if it
- 00:16:31can reverse a linked list or not so the
- 00:16:33steps to be done for that are declare a
- 00:16:35linked list first then add elements to
- 00:16:37that linked list apply the descending
- 00:16:39iterator method to the linked list and
- 00:16:41then they should reverse the order of
- 00:16:44the elements in the linked list
- 00:16:46the 34th question is how do you
- 00:16:48implement the binary search
- 00:16:50so for that we have the code segment
- 00:16:52right on my screen you can check that
- 00:16:53out and the steps to be followed are
- 00:16:55mentioned in the code segment so the
- 00:16:57binary search divides the array into
- 00:17:00half in every iteration step until it
- 00:17:03finds the element
- 00:17:04it works on sorted array since it
- 00:17:06compares the values of adjacent elements
- 00:17:08and then calculates the middle number if
- 00:17:10the value of low becomes greater than
- 00:17:12high
- 00:17:13at any point it means the element is not
- 00:17:16present in the list so this is how the
- 00:17:18binary search basically works followed
- 00:17:20by that we have the 35th question which
- 00:17:22says find the second largest number in
- 00:17:24the array so you can see we have a code
- 00:17:26segment on my screen to find it out so
- 00:17:28the steps to be followed are loop
- 00:17:30through the array if the value of i is
- 00:17:33greater than the highest store the value
- 00:17:35of i in the highest and store the value
- 00:17:38of highest in the second highest
- 00:17:40variable
- 00:17:42so now let's move ahead to the 36th
- 00:17:45question
- 00:17:46how do you remove all occurrences of a
- 00:17:48given character from the input string so
- 00:17:50we have a simple small code segment on
- 00:17:53my screen right away so that code
- 00:17:54segment can be used to remove all the
- 00:17:56occurrences of a given character from an
- 00:17:59input string so what you can do is use
- 00:18:01the built in string method that is
- 00:18:04replace to replace a character with any
- 00:18:07other character including symbols and
- 00:18:09white spaces
- 00:18:11so followed by that we have our 37th
- 00:18:13question so that is showcase inheritance
- 00:18:17with the help of a program so we have a
- 00:18:20small course limit on my screen to
- 00:18:22showcase the one of the major object
- 00:18:24oriented programming method that is
- 00:18:27inheritance
- 00:18:28so the class cat inherits the property
- 00:18:30color from class animal by extending the
- 00:18:33parent class animal this way a class cat
- 00:18:36can have more parent classes if it
- 00:18:38wishes to inherit their properties as
- 00:18:40well
- 00:18:41so next question that is the 38th
- 00:18:43question is explain overloading and
- 00:18:46overriding with the help of a program
- 00:18:48so this is a major question which is
- 00:18:50asked many number of times most
- 00:18:53frequently for the beginners and
- 00:18:55sometimes even the experienced
- 00:18:56candidates cannot escape this question
- 00:18:59so first we'll discuss overloading when
- 00:19:01a class has two or more methods with the
- 00:19:03same name they are called as overloaded
- 00:19:06methods so you can see a code segment on
- 00:19:08the right side part of my screen right
- 00:19:10away so this is an example for
- 00:19:12overloading next we will discuss the
- 00:19:14overriding
- 00:19:15so next we will discuss the overriding
- 00:19:18so when a super class method is also
- 00:19:19implemented in the child class then it's
- 00:19:21a clear case of overriding so on the
- 00:19:24right side part of my screen you can see
- 00:19:26a code segment where a child class is
- 00:19:29extending the base class method which is
- 00:19:31print name
- 00:19:33now followed by that we have the 39th
- 00:19:35question
- 00:19:37that is check if the given number is
- 00:19:39prime or not
- 00:19:41so you can see a code segment on my
- 00:19:43screen which determines if the given
- 00:19:45number is a prime number or not
- 00:19:47so the steps to be followed to find if a
- 00:19:49given number is prime or not r use if
- 00:19:51statements to check for each condition
- 00:19:54separately if the number is 0 or 1 it
- 00:19:57cannot be prime if the number is 2 it is
- 00:20:00prime if the number is
- 00:20:03and finally the third condition you need
- 00:20:05to take care of is if the number is
- 00:20:07indivisible by other numbers then it is
- 00:20:09prime so basically prime numbers are
- 00:20:11divisible by 1 or itself if any other
- 00:20:13number is capable to divide the number
- 00:20:16then it is not a prime number
- 00:20:18now the last question in the list is how
- 00:20:20do you sum all the elements in an array
- 00:20:22so for that we have a code segment right
- 00:20:24on my screen please check it and try to
- 00:20:27run it and that's the best way to learn
- 00:20:30so the steps to be followed are use the
- 00:20:32loop to iterate through the array and
- 00:20:33keep adding the elements in that array
- 00:20:35and finally you'll get the sum of the
- 00:20:37elements in the array and you can just
- 00:20:38print this sum at the last so with that
- 00:20:42as you prepare for your upcoming job
- 00:20:43interview we hope these coding questions
- 00:20:45have provided more insight into what
- 00:20:47types of questions you are likely to be
- 00:20:49asked
- 00:20:51hey everyone welcome to simply learn's
- 00:20:53youtube channel
- 00:20:55in terms of programming java is a very
- 00:20:58vast subject
- 00:20:59there are high chances that a beginner
- 00:21:01couldn't always cover every topic for an
- 00:21:03interview
- 00:21:04but what if you can stay on the safer
- 00:21:07side with the most frequently asked top
- 00:21:0910 questions that could always back you
- 00:21:11up
- 00:21:12this video from simplylearn is about the
- 00:21:14same
- 00:21:14here we will discuss the top 10 tricky
- 00:21:17and most frequently asked java interview
- 00:21:20questions
- 00:21:21so before we begin make sure that you
- 00:21:23have subscribed to our youtube channel
- 00:21:24and hit that bell icon to never miss an
- 00:21:27update from simply learn
- 00:21:29now without further ado let's get
- 00:21:31started with the top 10 java interview
- 00:21:33questions
- 00:21:34so the top 10 question in our list for
- 00:21:37today is what is multi-threading
- 00:21:40so the answer for this question is
- 00:21:42multi-threading is a procedure of
- 00:21:44executing two or more threads
- 00:21:46simultaneously to perform a certain
- 00:21:48operation via utilizing the cpu
- 00:21:50resources to the maximum
- 00:21:54multiple threads do not need separate
- 00:21:55memory allocation for each one of them
- 00:21:58so by this way they also save time and
- 00:22:01memory and run in parallel to each other
- 00:22:04so followed by the 10 question let us
- 00:22:07move on to the top ninth question
- 00:22:11does java include pointers now this
- 00:22:14question is most frequently asked
- 00:22:15amongst many interviews for the
- 00:22:17beginners
- 00:22:18so basically java has java virtual
- 00:22:21machine so in that instance we have some
- 00:22:23advantages and we might not need point
- 00:22:26is exactly there now let's look into the
- 00:22:28answer
- 00:22:29so java includes java virtual machine
- 00:22:31which automatically takes care of memory
- 00:22:33allocations so we do not find any use of
- 00:22:36pointers in real-time programming in
- 00:22:38java and also java has its own garbage
- 00:22:41collector to free the unused memory as
- 00:22:43well
- 00:22:45moving on to the next question
- 00:22:50what are jdk jvm and jre this is also
- 00:22:54one of the commonly asked questions now
- 00:22:56let us discuss the full forms of jdk jvm
- 00:22:59and gre and also what are their
- 00:23:01functionalities
- 00:23:02so jdk stands for java development kit
- 00:23:06so this is the package which you
- 00:23:08download for your jvm and jre together
- 00:23:11so when you download jdk from the
- 00:23:12official oracle website you will be
- 00:23:14getting the packages of jvm and jre
- 00:23:17together and you need to download them
- 00:23:19and later install them after installing
- 00:23:21jdk you need to set the path for jvm and
- 00:23:24jre together
- 00:23:26more about that and how to install java
- 00:23:28in your windows system and the link to
- 00:23:30the video is added in the description
- 00:23:32box below kindly check it now moving on
- 00:23:35to the next one which is jbm so jvm
- 00:23:38stands for java virtual machine so this
- 00:23:41is the tool that is mainly responsible
- 00:23:43to convert your program into bytecode so
- 00:23:46basically when you run a java code the
- 00:23:49compiler will not directly run your code
- 00:23:51first it will convert the entire program
- 00:23:54directly into the bytecode and that
- 00:23:56particular bytecode is run by the
- 00:23:58compiler this is the main reason why
- 00:24:01java is being
- 00:24:02platform independent
- 00:24:05so moving on to the next one that is gre
- 00:24:08jre stands for java runtime environment
- 00:24:12so java runtime environment is the one
- 00:24:14which is responsible to provide you all
- 00:24:16the class libraries and resources for
- 00:24:19the code execution
- 00:24:21now moving on to the next question
- 00:24:26what is the difference between
- 00:24:27overloading and overriding so by now i
- 00:24:30suppose most of you have been facing
- 00:24:32this question in many interviews so the
- 00:24:34fundamental difference between the
- 00:24:36overloading and overriding is as follows
- 00:24:39when you have two or more methods in the
- 00:24:42same class with the same name but
- 00:24:44different parameters parameters in the
- 00:24:46sense the number of values you pass to
- 00:24:49your function call for example let us
- 00:24:51imagine that we have two functions by
- 00:24:53the name add and the function that they
- 00:24:55will be performing is addition so one
- 00:24:58method will be having two variables for
- 00:25:01example add in a into b so you are
- 00:25:04sending two values to the function and
- 00:25:07another function with the same name that
- 00:25:08is add will have three values that is
- 00:25:12add intex into y and set so here we have
- 00:25:16different parameters but with the same
- 00:25:19function call this type of scenario is
- 00:25:21called as
- 00:25:22overloading in java
- 00:25:24now let us discuss about overriding in
- 00:25:27java when the method signature has same
- 00:25:30name and same number of parameters in
- 00:25:32both super class and child class then it
- 00:25:35is called as overriding
- 00:25:37now let us imagine that we have the same
- 00:25:39method that is add int a into b in both
- 00:25:43super class and child class now super
- 00:25:46class is something which has highest
- 00:25:48priority let us imagine that we have to
- 00:25:51call a method from child to class so
- 00:25:54based on the priority of the function
- 00:25:56call the jvm might call the method from
- 00:25:59child class ignoring the super class
- 00:26:02so this is where a method got overridden
- 00:26:05by the priorities so this particular act
- 00:26:07is called as function overriding or
- 00:26:10method overriding in java now moving
- 00:26:12forward we have our next question
- 00:26:17what is package in java remember that
- 00:26:20whenever you write a code in java you
- 00:26:23need a package
- 00:26:24so especially when you're working on a
- 00:26:26high-end ide like eclipse you need to
- 00:26:29define the package first
- 00:26:31it is possible that for some minor
- 00:26:33programs which you can run on command
- 00:26:35prompt you don't need a package but it
- 00:26:37is a good habit to use a package so here
- 00:26:40the question is what exactly is a
- 00:26:42package
- 00:26:44a package in java is a namespace that
- 00:26:47organizes a set of related classes and
- 00:26:49interfaces
- 00:26:50conceptually you can think of packages
- 00:26:53as being a similar version of your
- 00:26:55folders in your computer
- 00:26:57now moving on to the next question
- 00:27:03which is the base class of all the
- 00:27:05exceptions in java or you can also
- 00:27:08consider this question as which is the
- 00:27:10library that is responsible for all the
- 00:27:12exceptions in java
- 00:27:14so the answer for this question is
- 00:27:17the parent class or the base class for
- 00:27:19all the exceptions in java as
- 00:27:22java.lang library now the next question
- 00:27:26if i import a package
- 00:27:28will the jvm import all the sub packages
- 00:27:30of the imported package
- 00:27:32now let us imagine that you're working
- 00:27:34on a package called x
- 00:27:36and you needed something from a
- 00:27:38different package let us imagine that
- 00:27:40package is a
- 00:27:42so that package has already imported few
- 00:27:45more packages like pc and d so let us
- 00:27:48imagine again you have a package that
- 00:27:50you are currently working on that is x
- 00:27:52and you needed something from a
- 00:27:54different package that is a so a has
- 00:27:56already imported package b packet c and
- 00:27:59package t so if you now import package a
- 00:28:03into package x then do you have the
- 00:28:06possibilities that you also import
- 00:28:08package b c d along with a
- 00:28:12so the answer for this question is no
- 00:28:14when you import a specific package then
- 00:28:16the sub packages of this thing will not
- 00:28:19be imported here in the scenario
- 00:28:22if you wanted to include package a into
- 00:28:25package x then you can do it but the
- 00:28:28packages that a already included in
- 00:28:30itself that is b c and d will not be
- 00:28:34imported into x however the developer
- 00:28:36can manually import the sub packages
- 00:28:39when fines necessary so if the developer
- 00:28:41needs the sub packages that is bc and d
- 00:28:45he can manually import it into x
- 00:28:48but they will not come automatically
- 00:28:50when you import a into x
- 00:28:54now moving ahead into our next question
- 00:28:58does java has go to statement so goto is
- 00:29:02something we can face in some
- 00:29:04programming languages like c
- 00:29:06now does java also support that
- 00:29:09the answer for this question is
- 00:29:11no java does not have goto statement but
- 00:29:14it has something similar called labels
- 00:29:17so labels are used to change the flow of
- 00:29:19a program and gem to a specific
- 00:29:21instruction and label is based on a
- 00:29:24condition
- 00:29:27now moving ahead into our next question
- 00:29:30is it possible to have a class compiled
- 00:29:33without main method
- 00:29:36yes so the main method is always the
- 00:29:39starting point for compiling for a
- 00:29:41compiler or an interpreter but can you
- 00:29:44compile a complete class without a main
- 00:29:47method so this is one of the frequently
- 00:29:49asked questions so in java it is
- 00:29:52possible
- 00:29:54you can execute a java program without a
- 00:29:57main method by using static block static
- 00:30:00block in java is a group of statements
- 00:30:02that gets executed only once when the
- 00:30:05class is loaded into the memory by java
- 00:30:08class loader it is also known as static
- 00:30:11initialization block
- 00:30:14now the last question in our list
- 00:30:18can a dead thread be restarted in java's
- 00:30:22multi-threading so there are chances
- 00:30:24that sometimes you need to kill a thread
- 00:30:26so sometimes after you kill a thread you
- 00:30:29feel that that thread might be important
- 00:30:31for your program so is it kind of
- 00:30:33possible to restart it again
- 00:30:35the answer for this question is no
- 00:30:39once a thread is terminated in java we
- 00:30:41cannot restart it
- 00:30:43hello and welcome to python interview
- 00:30:45questions my name is richard kirchner
- 00:30:48with the simply learn team that's
- 00:30:51www.simplylearn.com get certified get
- 00:30:53ahead certainly the questions we're
- 00:30:55going to ask in here are very general
- 00:30:58with a few specifics towards data
- 00:30:59science since that's the main direction
- 00:31:01that python's going in and you'd want to
- 00:31:03expand your questions for your interview
- 00:31:05depending on the domain that you're
- 00:31:07using the python in specifically let's
- 00:31:09dive in and get started with some python
- 00:31:11interview questions number one what is
- 00:31:14the difference between shallow copy and
- 00:31:16deep copy and you can see with shallow
- 00:31:18copy we have object one which has child
- 00:31:21one child two child three and so on and
- 00:31:23object two which has child one child two
- 00:31:25child three a deep copy creates a
- 00:31:27different object and populates it with
- 00:31:29the child objects of the original object
- 00:31:32therefore changes in the original object
- 00:31:34is not reflected in the copy copy.deep
- 00:31:37copy creates a deep copy shallow copy
- 00:31:40creates a different object and populates
- 00:31:42it with the references of the child
- 00:31:44objects within the original object
- 00:31:46therefore changes in the original object
- 00:31:48is reflected in the copy copy.copy
- 00:31:51creates a shallow copy and you can look
- 00:31:53at this if we make a change to child one
- 00:31:55it's only a pointer so if you make it in
- 00:31:57object one and change to child one and
- 00:31:59object one it will also make that change
- 00:32:01in object two number two how is
- 00:32:03multi-threading achieved in python oh
- 00:32:06this is a good one with multi-processing
- 00:32:08and multi-threading this question is
- 00:32:10actually asking you do you know the
- 00:32:11difference between multi-processing and
- 00:32:13multi-threading and how multi-threading
- 00:32:15works multi-threading usually implies
- 00:32:18that multiple threads are executed
- 00:32:20concurrently the python global
- 00:32:22interpreter lock doesn't allow more than
- 00:32:24one thread to hold the python
- 00:32:26interpreter at that particular point of
- 00:32:28time so multi-threading in python is
- 00:32:30achieved through context switching it's
- 00:32:32very different than multi-processing
- 00:32:34which actually opens up multiple
- 00:32:36processes across multiple threads so
- 00:32:38multi-threading discuss the django
- 00:32:41architecture so the django architecture
- 00:32:43and the first thing to know is that the
- 00:32:46django is a web service way to build
- 00:32:48your web pages basically and so we look
- 00:32:51at the architecture you can see here we
- 00:32:53have a nice model drawn out where the
- 00:32:54user initiates the jangle which
- 00:32:56initiates the url which indicates the
- 00:32:58view what they're going to view and you
- 00:33:00have your model and your template so the
- 00:33:02model of data whatever data model you're
- 00:33:04pulling goes into the template and then
- 00:33:05goes back up the pipeline to the user
- 00:33:08and the important thing to note is
- 00:33:09there's a template the front end of the
- 00:33:11web page this is what they're going to
- 00:33:13see there's a model the back end where
- 00:33:15the data is stored so you can keep the
- 00:33:17template and the looks and everything
- 00:33:19looks the same but you can swap out the
- 00:33:21underlying information that goes into
- 00:33:23that template then you have your view
- 00:33:25which interacts with the model and
- 00:33:26template and maps it to the url and then
- 00:33:28the django serves the page to the user
- 00:33:31so your django grabs it and says okay
- 00:33:33thank you for the url and here you go
- 00:33:35user what advantage does numpy array
- 00:33:38have over a nested list
- 00:33:40so numpy's a module you import almost
- 00:33:43always see numpy import numpy as np
- 00:33:46numpy is written in c such that all his
- 00:33:48complexities are backed into a simple to
- 00:33:50use module lists on the other hand are
- 00:33:53dynamically typed therefore python must
- 00:33:56check the data type of each element
- 00:33:57every time it uses it this make number
- 00:34:00arrays much faster than lists i would
- 00:34:02also add in that numpy has a lot of
- 00:34:05additional functionality that you don't
- 00:34:07have in lists there's a lot of things
- 00:34:09you can automate in the numpy quick flip
- 00:34:11over to our jupiter notebook any ide
- 00:34:13will work if you're going to do a set of
- 00:34:15interview questions taking a quick look
- 00:34:17at code is always important we have our
- 00:34:19import numpy as np we'll go ahead and
- 00:34:21import time here's our list list sub for
- 00:34:24iron range of 100 and what we're doing
- 00:34:26is we're going to time it so we're going
- 00:34:28to create a list then we're going to
- 00:34:30create a numpy zeros array and you can
- 00:34:33see here look how quick you can create
- 00:34:34this numpy zeros array here we are
- 00:34:37appending one zero at a time for a
- 00:34:38regular python list and here we are with
- 00:34:40numpy they're all zeros and they're all
- 00:34:43of type integer i believe it's either
- 00:34:44float or integer on this i'd have to
- 00:34:46actually do a type on it and then so if
- 00:34:47we take in and we create a tl1 time
- 00:34:50equals time and then we do for i in
- 00:34:52range of 100 for j and range of 100 l of
- 00:34:56i j equals l of i j plus 5. so we're
- 00:34:59just doing a simple calculation on our
- 00:35:02array and subarrays this is an array of
- 00:35:04rays and we'll do the same thing with
- 00:35:06tl2 tl2 time dot time tl1 equal so here
- 00:35:10we have our final time on that and then
- 00:35:12we'll do this with an array array op and
- 00:35:14this is what i really love a equals a
- 00:35:16plus 10 and then you can just print it
- 00:35:18right out so you can see right here with
- 00:35:20the numpy array i'm doing the same thing
- 00:35:22if i run this our time is significantly
- 00:35:26different here we have 0.09 and 0.003 uh
- 00:35:29so you can see that the time drops
- 00:35:31significantly when you're running this
- 00:35:33on a numpy array versus a list array
- 00:35:35also important to note these times
- 00:35:37aren't going to be they'll change each
- 00:35:39time i run it depending on what i have
- 00:35:40running in the background so there we go
- 00:35:42number five what is pickling and
- 00:35:45unpickling amazes me how many times i
- 00:35:47pickle and unpickle something converting
- 00:35:49a python object hierarchy to a bite
- 00:35:52stream is called pickling pickling is
- 00:35:54also referred to as serialization
- 00:35:57unpickling converting a byte stream to a
- 00:35:59python object hierarchy is also called
- 00:36:02unpickling unpickling is also referred
- 00:36:04to as
- 00:36:05deserialization so if you just created a
- 00:36:08neural network model you can now save
- 00:36:10that model to your hard drive pickle it
- 00:36:13and then you can unpickle it to bring it
- 00:36:14back into another software program or to
- 00:36:17use at a later time how is memory
- 00:36:19managed in python number six python has
- 00:36:22a private heap space where it stores all
- 00:36:24the objects the python memory manager
- 00:36:26manages various aspects of this heap
- 00:36:29like sharing caching segmentation and
- 00:36:31allocation the user has no control over
- 00:36:33the heap only the python interpreter has
- 00:36:35the access you have a nice little
- 00:36:37diagram here here's your program there's
- 00:36:39your interpreter we have our heap memory
- 00:36:41management on the garbage collector
- 00:36:43going off of there number seven are
- 00:36:45arguments in python pass by value or by
- 00:36:48reference arguments are passed in python
- 00:36:51by reference this means that any change
- 00:36:53made within a function is reflected on
- 00:36:55the original object so you can see here
- 00:36:58def function of l l of 0 equals 3 l
- 00:37:02equals 1 2 3 4 function l print l and
- 00:37:06you're going to get three two three four
- 00:37:08because we passed l in there so it's a
- 00:37:10pointer here we have def function l l
- 00:37:13equals three two three four l equals one
- 00:37:15two three four function of l print l
- 00:37:18because in this function i have assigned
- 00:37:21instead of operating on a piece of l the
- 00:37:24list i've consigned a whole new value to
- 00:37:27that list or l it then at that point
- 00:37:29will create a new object so if i make
- 00:37:32changes to the object it's going to
- 00:37:33change it in the outside the definition
- 00:37:36if i use a variable and i cited a
- 00:37:38completely new value like l equals 3 2 3
- 00:37:414 that will not show up when you're
- 00:37:44outside the function number eight how
- 00:37:46would you generate random numbers in
- 00:37:49python to generate random numbers in
- 00:37:51python you must first import the random
- 00:37:54module the random function generates a
- 00:37:57random float value between 0 and 1. the
- 00:38:00random range function generates a random
- 00:38:03number within a given range and you can
- 00:38:06see here one is the lower end tens the
- 00:38:08upper end and step two so it would be
- 00:38:10one three five and so on as far as the
- 00:38:13options in the random generation number
- 00:38:15nine what does the double forward slash
- 00:38:19operator do in python the forward slash
- 00:38:21operator performs division and returns
- 00:38:24the quotient in float for example 5 over
- 00:38:272 returns 2.5 to do a double forward
- 00:38:30slash operator on the other hand returns
- 00:38:32the quotient an integer for example 5
- 00:38:35double slash returns 2. 5 divided by 2
- 00:38:38and you drop the 0.5 number 10 what does
- 00:38:41the is operator do the is operator
- 00:38:44compares the id of the two objects and
- 00:38:47you can see in here where list one
- 00:38:49equals brackets round one two three list
- 00:38:52one equals list two equals true and you
- 00:38:54have the double equals in python of
- 00:38:56course and you can do list one is list
- 00:38:58two where list two equals one two three
- 00:39:01is false list two is not the brackets
- 00:39:04one two three it equals it but it's not
- 00:39:06the brackets and if we do list three
- 00:39:08equals list one then list one is list
- 00:39:11three equals true number 11 what is the
- 00:39:14purpose of pass statement the pass
- 00:39:16statement is used when there's a
- 00:39:17syntactic but not an operational
- 00:39:20requirement for example the program
- 00:39:22below prints a string ignoring the
- 00:39:24spaces and so here we have variable
- 00:39:26equals simply learn we've added two
- 00:39:28spaces in it for i and variable so it
- 00:39:31goes through each eye if i equals space
- 00:39:33do nothing else print i and then we'll
- 00:39:36have the end equals bracket bracket and
- 00:39:38they'll print out simply learn now of
- 00:39:40course you would probably write this if
- 00:39:42i does not equal blank space print but
- 00:39:44this would be another way you could do
- 00:39:46that if you need a placeholder for that
- 00:39:48first logical set or that first area you
- 00:39:51can also do a function like this you
- 00:39:52could do function
- 00:39:54whatever your def function name brackets
- 00:39:57colon pass so it goes into the function
- 00:40:00and does nothing but it's a placeholder
- 00:40:02number 12 how will you check all the
- 00:40:04characters in a string are alphanumeric
- 00:40:06python has an inbuilt method is all
- 00:40:10number which returns true if all
- 00:40:11characters in the string are
- 00:40:13alphanumeric and so you can see here a b
- 00:40:15c d one two three is all number output
- 00:40:19equals true and the second line a b c d
- 00:40:22the at symbol one two three the pound
- 00:40:24symbol is all nume output equals false
- 00:40:27so really just want to know about is all
- 00:40:29new all numerical alphanumerical number
- 00:40:3212 how will you check if all characters
- 00:40:34in a string are alphanumeric so here we
- 00:40:37go
- 00:40:38if you know is all number which returns
- 00:40:39that the characters in the string are
- 00:40:41alphanumeric one can also use regex
- 00:40:44instead and so we have boolean re match
- 00:40:47what's important about this is to note
- 00:40:49your capital a dash to capital z a lower
- 00:40:52codes to dash to z 0 to 9 means that
- 00:40:56that array includes all of those the way
- 00:40:58they have it written out plus a dollar
- 00:41:00sign and then we have what we're
- 00:41:02comparing it to the string we're
- 00:41:03comparing to the abcd123
- 00:41:05and so we can do an re.match and if it
- 00:41:08matches if all these things if all the
- 00:41:10different entities in that array matches
- 00:41:12the first one we get an output true and
- 00:41:14if not an output false number 13 how
- 00:41:17will you merge elements in a sequence
- 00:41:20sequence there are three types of
- 00:41:22sequences in python there's lists tuples
- 00:41:25and strings python across makes this
- 00:41:28easy if we have a list one and list two
- 00:41:30and list one is square brackets one
- 00:41:32comma two comma three list two is four
- 00:41:34five and six we can simply do list one
- 00:41:37plus list two and our output is one two
- 00:41:40three four five six if we have tuples
- 00:41:42your tuple is the curved brackets
- 00:41:44designates it and again just add them
- 00:41:46together same thing with strings we have
- 00:41:48simply learn s1 plus s2 equals simply
- 00:41:51learn number 14 how will you remove all
- 00:41:54leading white space in a string python
- 00:41:57provides the inbuilt function l strip to
- 00:42:00remove all leading access from a string
- 00:42:02and you can see here spacebase base
- 00:42:04python.l strip leading strip python and
- 00:42:07you can also do strip which release
- 00:42:09leading and ending of course there's
- 00:42:11also the ending set number 15 how will
- 00:42:14you replace all occurrences of a stub
- 00:42:16string with a new string the replace
- 00:42:18function can be used with strings for
- 00:42:20replacing a substring with a given
- 00:42:22string syntax string dot replace old
- 00:42:25comma new come account replace returns a
- 00:42:27new string without modifying the
- 00:42:29original string hey john how are you
- 00:42:31john question mark replace john with
- 00:42:34capital j-o-h-n one and then you can see
- 00:42:36right here hey john how are you and
- 00:42:38since we designated with the one just
- 00:42:40says we're only going to replace one of
- 00:42:42these 16 what is the difference between
- 00:42:45dell and remove brackets on lists dell
- 00:42:48for delete dell removes all elements of
- 00:42:51a list within a given range syntax dell
- 00:42:54list start to end remove remove brackets
- 00:42:57removes the first occurrence of a
- 00:42:59particular character syntax list remove
- 00:43:01element and we see a nice example over
- 00:43:03here if we delete the list one to three
- 00:43:06it will delete the first in this case b
- 00:43:09one two it doesn't do three remember
- 00:43:11that one two so we'll delete b and c and
- 00:43:13you end up with a d where if we do
- 00:43:15remove b from the list and we have an
- 00:43:17abbd it's only gonna remove the first b
- 00:43:19number 17 how to display the contents of
- 00:43:22text file in reverse order open the file
- 00:43:25using the open function store the
- 00:43:27contents of the file into a list reverse
- 00:43:29the contents of the list run a for loop
- 00:43:32to iterate through the list number 18
- 00:43:34differential between append and extend
- 00:43:38append adds an element to the end of the
- 00:43:40list you can see right here we have a
- 00:43:42list one two three four and we append
- 00:43:44four we end up with an output one two
- 00:43:46three four and extend adds an element
- 00:43:49from an interval to the end of the list
- 00:43:52and we have here list equals one two
- 00:43:54three list dot extend four five six
- 00:43:57output is one two three four five six so
- 00:44:00if you wanna append an array to the end
- 00:44:02of another array you wanna use the
- 00:44:04extend number nineteen what's the output
- 00:44:07of the below code justify your answer
- 00:44:10this is a great interview question
- 00:44:11because these are the kind of things
- 00:44:13that come up when you're proofing code
- 00:44:14def add to list value and list so we
- 00:44:18have value in and a list dent or list
- 00:44:20equals an empty in this case an empty
- 00:44:21list list data pin value return list
- 00:44:24list one equals add to list one list two
- 00:44:28equals add to list one two three empty
- 00:44:30bracket list three equals add to list a
- 00:44:34and then we want to print them list one
- 00:44:36equals and you can see the formatting we
- 00:44:38have our placeholder list one list two
- 00:44:40and list three so when it prints list
- 00:44:42one we get one comma a and what you want
- 00:44:45to notice here is that list one and list
- 00:44:48three are equal why are they equal well
- 00:44:51when we passed the information to the
- 00:44:54add to list we passed value without
- 00:44:57passing the list equals brackets without
- 00:44:59passing a second value what this means
- 00:45:01is that list as we have it if you don't
- 00:45:05have a list it'll start off with empty
- 00:45:07list which we append the one to the
- 00:45:09second one list two we appended a value
- 00:45:12to an empty list so it's only going to
- 00:45:14be one two three doesn't matter what the
- 00:45:16list was before we've already assigned
- 00:45:18an empty list and then list three here's
- 00:45:20the tricky one we're adding a to the
- 00:45:23list but because we didn't designate the
- 00:45:25list list is a shared value in other
- 00:45:28words it doesn't reset it and we end up
- 00:45:31with list one equals list three one
- 00:45:33comma a default this is created only
- 00:45:35once during the function and not during
- 00:45:38its call number 20 what is the
- 00:45:40difference between a list and a tuple
- 00:45:42lists are mutable while tuples are
- 00:45:44immutable and you can see an example
- 00:45:46down here where i have list equals one
- 00:45:48two three square brackets denote it's a
- 00:45:50list list of two equals four and i print
- 00:45:52it out i now have one two four if i do
- 00:45:54the same thing with the tuple i get an
- 00:45:56error because you can't change the tuple
- 00:45:58one two three into one two four you have
- 00:46:01to completely reassign tuple to a new
- 00:46:03value what is docs string in python docs
- 00:46:06strings are used in providing
- 00:46:08documentation to various python modules
- 00:46:10classes functions and methods and so you
- 00:46:12can see here we have def for a function
- 00:46:15add a b and this is a doc string we have
- 00:46:18the
- 00:46:19triple brackets on there you can add
- 00:46:21carriage return in that so that you can
- 00:46:23go multiple lines and it says this
- 00:46:25function adds two numbers and then sum a
- 00:46:27b return sum and so we have down here
- 00:46:31two different ways of accessing this
- 00:46:33function output accessing docs string
- 00:46:35method one this function adds two
- 00:46:37numbers accessing docs string method two
- 00:46:40help unfunction add in model main this
- 00:46:42function adds two numbers and so you can
- 00:46:44see the code down here has two very
- 00:46:47different
- 00:46:48in values the second one is basically a
- 00:46:51help menu there's our help menu number
- 00:46:5322 how to use print without the new line
- 00:46:57the solution to this depends on the
- 00:46:59python version you are using in python
- 00:47:01version 2 you can do print hi and then
- 00:47:04you add a comma afterwards print how are
- 00:47:07you and you have hi how are you in
- 00:47:10version three print hi comma end equals
- 00:47:14and it'll add a space on the end there
- 00:47:16you can put different characters in
- 00:47:17there but you just want to put a space
- 00:47:18to put a space on the end print how are
- 00:47:20you and now we get hi how are you number
- 00:47:2223 how do you use the split function in
- 00:47:25python the split function splits a
- 00:47:27string into a number of strings based on
- 00:47:29a specific delimiter so we have string
- 00:47:32split delimiter comma max the maximum
- 00:47:35number of splits the character based on
- 00:47:37which the string is to split by default
- 00:47:39is space so here we have an example we
- 00:47:42have a variable red blue green orange
- 00:47:44and we want to split it by commas and we
- 00:47:46only want to do the first two so if we
- 00:47:49print the list now you'll find it has
- 00:47:50red blue and only spread it split it the
- 00:47:53first two times and it gets to the third
- 00:47:54one and just groups them all together
- 00:47:56green and orange if you leave the two
- 00:47:57off you'll split the whole thing number
- 00:47:5924 is python object oriented or
- 00:48:02functional programming python follows
- 00:48:05object oriented paradigm and you should
- 00:48:07really know in depth what they mean by
- 00:48:09object oriented paradigm if you're doing
- 00:48:10any interview for scripting languages
- 00:48:13python allows the creation of objects
- 00:48:15and is manipulation through specific
- 00:48:17methods it supports most of the features
- 00:48:20of oops which has inheritance on a
- 00:48:23polymorphism so you have an object and
- 00:48:25you can inherit all the traits of that
- 00:48:26object and then add new traits in or
- 00:48:28alter some of those traits that's what
- 00:48:30object oriented means python follows
- 00:48:32functional programming paradigm
- 00:48:34functions may be used as first class
- 00:48:37object python supports lambda functions
- 00:48:39which are characteristic of functional
- 00:48:41paradigm so you can set a variable to a
- 00:48:44function as opposed to setting it to an
- 00:48:46object number 25 write a function
- 00:48:49prototype that takes variable number of
- 00:48:51arguments here we have def function name
- 00:48:54list so we could have in this case
- 00:48:56whatever the list is def function the
- 00:48:58asterisk denotes so we're going to take
- 00:49:01multiple arguments of a variable and we
- 00:49:03can do for i and var print i so if you
- 00:49:06send function of one you'll end up with
- 00:49:08a one function one two five six they'll
- 00:49:10actually print those out one at a time
- 00:49:12the first one just prints out a one
- 00:49:13because it only sent one variable the
- 00:49:14second one will print one another line
- 00:49:1625 and the line six number 26 what is
- 00:49:20asterisks args and asterisks quarks
- 00:49:23args used in function prototype to
- 00:49:26accept varying number of arguments it's
- 00:49:28an interval object def function arcs and
- 00:49:32you can imagine it's just a basic list
- 00:49:34so if i send add the numbers a comma b
- 00:49:38or a comma b comma c it doesn't really
- 00:49:40matter it'll have that number of objects
- 00:49:43in it whatever i send to it and there's
- 00:49:45other uses for it but that's very basic
- 00:49:46korg's i can actually tell it what i
- 00:49:50want to send so used in a function
- 00:49:52prototype and to accept varying number
- 00:49:54of keyword arguments it's in both are
- 00:49:56interval objects so you can go through
- 00:49:58them one at a time and the def function
- 00:50:00chords you can now set like color equals
- 00:50:03red units equal to so you'll see that
- 00:50:06especially in machine learning there's a
- 00:50:07lot of like they'll have inline equals
- 00:50:10true that kind of thing number 27 in
- 00:50:12python functions are first class objects
- 00:50:16what do you understand from this
- 00:50:18this means i could return a function
- 00:50:20could be one from another function i
- 00:50:22could create a function and treat it
- 00:50:24just like an object i can assign it to a
- 00:50:26variable i can pass them as arguments to
- 00:50:28other functions number 28 what is the
- 00:50:31output of print name underscore
- 00:50:34underscore name and justify your answer
- 00:50:36the double underscore name double
- 00:50:38underscore is a special variable that
- 00:50:40holds the name of the current module
- 00:50:42program execution starts from main or a
- 00:50:45code with zero indentation thus double
- 00:50:48underscore name dumbbell underscore name
- 00:50:50has a value double underscore main
- 00:50:52double underscore in the above case if
- 00:50:54the file is imported from another module
- 00:50:57then double underscore name underscore
- 00:50:59double underscore holds the name of this
- 00:51:01module number 29 what is a numpy array
- 00:51:05and we briefly touched numpy array
- 00:51:06compared to a list early in processing
- 00:51:08speed now let's go ahead and look at
- 00:51:10some of the more specifics a numpy array
- 00:51:13is a grid of values all of the same type
- 00:51:16so if they're either all float all
- 00:51:18integer all string and is indexed by a
- 00:51:21tuple of non-negative integers the
- 00:51:23number of dimensions is the rank of the
- 00:51:25array and the shape of an array is a
- 00:51:28tuple of integers giving the size of the
- 00:51:29ray along each dimension number 30 what
- 00:51:33is the difference between matrices and
- 00:51:35arrays a matrix comes from linear
- 00:51:38algebra and is a two-dimensional
- 00:51:39representation of data it comes with a
- 00:51:42powerful set of mathematical operations
- 00:51:44that allow you to manipulate the data in
- 00:51:46interesting ways now arrays an array is
- 00:51:49a sequence of objects of similar data
- 00:51:51type an array within another array forms
- 00:51:54a matrix like we said here
- 00:51:56two-dimensional so if you have an array
- 00:51:58of three by four that would be a matrix
- 00:52:00number 31 how to get indexes of n
- 00:52:03maximum values in a numpy array of
- 00:52:05course the first thing to do is to
- 00:52:07import your numpy as np you don't
- 00:52:09necessarily have to use mp but that is
- 00:52:11the most standard use of numpy we create
- 00:52:13our array equals an np.array of one two
- 00:52:16three four five and then if we want to
- 00:52:18get our indexes of n at maximum values
- 00:52:21in a numpy array we can do one way to do
- 00:52:24it is to take our array sort it then do
- 00:52:27minus in colon that means we're going to
- 00:52:30do once you've sorted it you can do
- 00:52:32minus in n would equal then the number
- 00:52:35of indices so it's not the actual letter
- 00:52:37n colon and really this is about
- 00:52:40understanding this notation that we can
- 00:52:42sort it so it goes from lowest to
- 00:52:44biggest and then we can get the top
- 00:52:46values for n indexes and then we have
- 00:52:49our final set of brackets with the minus
- 00:52:52one on there number 32 how would you
- 00:52:54obtain the resulting set from the train
- 00:52:57set and the test set from below and
- 00:52:59let's go ahead and look at the two
- 00:53:00different variables we have train set
- 00:53:02equals an array of one two three test
- 00:53:04set equals a numpy of ray of arrays we
- 00:53:08have zero one two one two three what's
- 00:53:12important here is that one it's a numpy
- 00:53:14so that leaves a out and then we're
- 00:53:16stuck with three other options and i'm
- 00:53:19going to say the d is out none of these
- 00:53:20and let's look at
- 00:53:22np.concatenate
- 00:53:24versus
- 00:53:25np.v stack concatenate would put one set
- 00:53:29after the other so you would end up with
- 00:53:31probably give you an error because one
- 00:53:33set is one two three and then we're
- 00:53:35going to concatenate array zero one two
- 00:53:38and one array one two three the array of
- 00:53:41arrays onto the end of that what we
- 00:53:43really want to do is stack and by the
- 00:53:44way you can actually switch there's
- 00:53:46variables you can put into concatenate
- 00:53:47obviously they can change this so you
- 00:53:49could use the concatenate with a lot of
- 00:53:50fudging around but really we're looking
- 00:53:52for is v stack v stands for vertical
- 00:53:55versus the h stack which is horizontal
- 00:53:57and if we do a v stack we can simply do
- 00:53:59train set comma test set and stack them
- 00:54:02together and so we have c resulting set
- 00:54:05equals np.v stack train stack test set
- 00:54:08both option a and b would do horizontal
- 00:54:11stacking but we would like to have the
- 00:54:12vertical stacking option she does this
- 00:54:15again you could add the axes in and use
- 00:54:17the concatenate to stack it the correct
- 00:54:19way number 33 how would you import a
- 00:54:22decision tree classifier in sk learn we
- 00:54:25have sklearn dot decision tree import
- 00:54:28decision tree classifier from sklearn
- 00:54:30ensemble import decision tree classifier
- 00:54:33and we look at these they're all import
- 00:54:34decision tree classifier that actually
- 00:54:36last part happens to be correct and it's
- 00:54:38really just a vocabulary knowing where
- 00:54:41is the decision tree classifier stored
- 00:54:43what module is that a part of and it is
- 00:54:46of course part of the sklearn.tree
- 00:54:48number c number 34. you have uploaded
- 00:54:51the data set in csv format on google
- 00:54:54spreadsheet and shared it publicly how
- 00:54:57can you access this in python what's
- 00:54:59important here is to know that we can
- 00:55:01read stuff with pandas so we don't show
- 00:55:04it here but you can there's actually a
- 00:55:05number of ways to do this what's
- 00:55:06important here is to know a couple
- 00:55:08things one we have our link generated
- 00:55:11from the google docs and spreadsheets
- 00:55:13and then we can do a string io dot
- 00:55:16string io request get link.content so
- 00:55:19there's our source and then finally we
- 00:55:21know that pandas can read a csv there's
- 00:55:24obviously many ways to read a csv but
- 00:55:25data equals pd.read underscore csv
- 00:55:28source number 35 what is the difference
- 00:55:31between the two data series given below
- 00:55:34below we have df name and df location
- 00:55:37colon comma brackets around asterisks
- 00:55:40around name comma where and then we have
- 00:55:42df equals pd data frame aabb xx uu comma
- 00:55:4721 16 50 33 columns equal name and age
- 00:55:51so let's take a look and see what
- 00:55:53they're looking at we have just glancing
- 00:55:56at the questions they want to know is it
- 00:55:58the original data frame or is it the
- 00:56:01copy of the data frame and you can see
- 00:56:02here that one is view of the original
- 00:56:05data frame and two is a copy of the
- 00:56:06original data frame two is a view of the
- 00:56:09original data frame and one is a copy of
- 00:56:11the original data frame both are copies
- 00:56:13both are views and if you're working
- 00:56:15with pandas you know that unless you
- 00:56:18specifically in certain things tell it
- 00:56:20to do it in line and a lot of functions
- 00:56:22don't allow you that you're always
- 00:56:24taking a slice and it is always a copy
- 00:56:26so c both are copies of the original
- 00:56:29data frame number 36 you get the
- 00:56:31following error while trying to read a
- 00:56:33file temp dot csv using pandas which of
- 00:56:36the following could correct it so here's
- 00:56:39our error trace back most recent call
- 00:56:41last file input line 1 and module
- 00:56:43unicode in code error ascii codecs can't
- 00:56:47encode character oh i hate it when that
- 00:56:50one comes up and we have four different
- 00:56:52entries we'll go ahead and just pretend
- 00:56:54that d doesn't exist unless we really
- 00:56:56can't fit it into one of the other
- 00:56:57answers and the first one is pd read csv
- 00:57:01has our file compression equals gzip
- 00:57:04well g zip is just an unzipping and you
- 00:57:06actually get a zip error on there the
- 00:57:08second one is dialect equals string
- 00:57:10again not an encoding or coding setup
- 00:57:14and then we have encoding equals utf-8
- 00:57:17well that would be the encoding error
- 00:57:19switching it from the character code
- 00:57:20there's utf-8 there is unicode that's
- 00:57:23the most common tool that goes between
- 00:57:25so really this is about understanding
- 00:57:26the difference between a utf-8 coding
- 00:57:29and a unicode and the error that comes
- 00:57:31up quite regularly with that number c
- 00:57:33encoding should be utf-8 number 37 how
- 00:57:37to set a line width in a plot given
- 00:57:39below so looking at this we have import
- 00:57:42map plot library pi plot is plt and you
- 00:57:45should know your way around this how to
- 00:57:46do a plot in there
- 00:57:48plt.plot1234 plot equals show so this is
- 00:57:51a little bit of a vocabulary test the
- 00:57:54vocabulary is it width equals three line
- 00:57:56width equals three lw equals three or
- 00:57:59something else and the vocabulary word
- 00:58:01that we're looking for is lw equals
- 00:58:04three which stands for line width in pi
- 00:58:06plot library pi plot number 38 how would
- 00:58:10you reset the index of a data frame to a
- 00:58:12given list so this is a vocabulary
- 00:58:16challenge and understanding what
- 00:58:18re-indexing is re-indexing as we have
- 00:58:21the different values here we have the
- 00:58:22first one which is reset the index well
- 00:58:25we're not really resetting the index
- 00:58:26reindex number b means we are double
- 00:58:29checking our indexes to the column and
- 00:58:31to the main index and so the values
- 00:58:34match correctly where re-index like now
- 00:58:37brings in a new index outside of our
- 00:58:40data frame to a given list so this is
- 00:58:42coming from external and thus the
- 00:58:43vocabulary word like is our keyword that
- 00:58:46is external and we have a data friend to
- 00:58:48a given list number 39 how can you copy
- 00:58:51objects in python the functions used to
- 00:58:53copy objects in python we have copy copy
- 00:58:56for shallow copying and copy deep
- 00:58:58copying for deep copy number 40 what is
- 00:59:01the difference between range and x range
- 00:59:04functions in python well this is a good
- 00:59:07one we have matrixes and arrays with a
- 00:59:09matrix the range returns a python list
- 00:59:11object x range returns an x range object
- 00:59:15and with arrays an x-ray returns an
- 00:59:17x-range object x-range creates values as
- 00:59:20you need them through yielding the key
- 00:59:22here is that x-range returns the values
- 00:59:25as you need them so it actually
- 00:59:28processes it post like if you have for x
- 00:59:31or for a variable in x range it is
- 00:59:33processing them as you need them zero to
- 00:59:36nine it doesn't create an array zero to
- 00:59:37nine it just hands you zero then one two
- 00:59:39three four one at a time number forty
- 00:59:41one how can you check whether a pandas
- 00:59:44data frame is empty or not the tribute
- 00:59:47df.empty is used to check whether a
- 00:59:49panda's data frame is empty or not and
- 00:59:51so you can simply create a we have down
- 00:59:53here import our pandas as pd we create
- 00:59:55our pen as data frame equal to an empty
- 00:59:57array and is df dot empty comes out as
- 01:00:00true one of the catches you got to
- 01:00:02remember with these vocabularies is with
- 01:00:04empty along with some other pandas set
- 01:00:06up whether you need the brackets or not
- 01:00:08at the end number 42 write the code to
- 01:00:12sort an array in numpy by the n minus
- 01:00:15one column this can be achieved using
- 01:00:17arg sort function let's take an array x
- 01:00:20then to sort the n minus one column the
- 01:00:22code will be x to
- 01:00:24x to colon n minus two dot args sort so
- 01:00:29let's see what that code looks like we
- 01:00:30import numpy as np we'll create our
- 01:00:33array um our numpy array which is uh one
- 01:00:36two three zero five two two three four
- 01:00:38so we have three different entities with
- 01:00:41three different columns in there and we
- 01:00:43go x of x and so we take x of
- 01:00:47all the rows first entity well in this
- 01:00:50case it's actually the second one
- 01:00:51because it's 0 1 2 dot arg sort so that
- 01:00:54would be the second entity or minus two
- 01:00:56would also be the same you could also do
- 01:00:58instead of one you could also do minus
- 01:00:59two there instead of the one arg sort
- 01:01:01and then we get an output of the array
- 01:01:03one two three zero five two two three
- 01:01:06four number 43 how to create a series
- 01:01:09from a list numpy array and dictionary
- 01:01:12so we'll go ahead and input import our
- 01:01:14numpy our pandas and have my list and
- 01:01:16you can see here we have my list equals
- 01:01:18list of abcdefg all the way through so
- 01:01:22my list now makes a list of that
- 01:01:24for
- 01:01:25array we have np.a range to 26 my
- 01:01:29dictionary will create a dictionary with
- 01:01:31a zip my list my arguments so i'll just
- 01:01:33use the numpy array we just created with
- 01:01:35my array to go into the dictionary and
- 01:01:38the solution is simple with the
- 01:01:40pd.series my list pd.series my array
- 01:01:44pd.series my dictionary so it's all
- 01:01:47about knowing the dot capital
- 01:01:49s-e-r-i-e-s don't forget that
- 01:01:51capitalization number 44 how to get the
- 01:01:54items not common to both series a and
- 01:01:57series b and you can see here we have
- 01:02:00instead of series a and b we have series
- 01:02:01one and two and we have one two three
- 01:02:03four five four five six seven eight the
- 01:02:05solution
- 01:02:06is we take a panda series we have a
- 01:02:09series u equals a panda series np union
- 01:02:11one dimension series one series two so
- 01:02:14we can now make a union of them we now
- 01:02:16have series one panda series with an
- 01:02:18intersection and then we can remove one
- 01:02:22from the other series u is series u dot
- 01:02:25is in series one so if the union is not
- 01:02:29in the intersection then you know it's a
- 01:02:32unique value a little bit of logic going
- 01:02:34on there playing with three different
- 01:02:36terms to get the answer we want 45 how
- 01:02:40to keep only the top two most frequent
- 01:02:42values as it is and replace everything
- 01:02:44else as other in a series so again we're
- 01:02:47working with pandas because we're
- 01:02:49talking series and data frames that
- 01:02:52means we're working with pandas so we're
- 01:02:54going to import pandas as pd we'll go
- 01:02:56ahead and create our panda series we're
- 01:02:58going to do that by creating a numpy
- 01:03:00random random state 100 so 100 in the
- 01:03:03numpy one and then we have our panda
- 01:03:05series you can see here we're random
- 01:03:07integer numpy random random integer of
- 01:03:10one comma five by 12. and so the
- 01:03:12solution for this is we go ahead and
- 01:03:15we've created a pd dot remember the
- 01:03:17capital s series solution we're going to
- 01:03:19print the top two frequencies and that
- 01:03:22is our series dot value counts and then
- 01:03:25we take series values count dot index of
- 01:03:28up to two so we're going to take
- 01:03:30everything up to two and then we'll do
- 01:03:32the series is in so if it's not in the
- 01:03:35first two then it's going to equal other
- 01:03:37and this would be something you'd want
- 01:03:38to write down on paper if you're if it
- 01:03:41looks confusing take a moment pause the
- 01:03:43video
- 01:03:44write this down and see if you can
- 01:03:46figure out how the logic came together
- 01:03:47and try to throw yourself a couple other
- 01:03:49little logic puzzles like this number 46
- 01:03:52how to find the positions of numbers
- 01:03:54that are multiples of three from a
- 01:03:56series and in here we're actually going
- 01:03:59to use a numpy to solve it the first
- 01:04:01part series lets you know it's going to
- 01:04:03be a panda series and if we come down
- 01:04:05here we have
- 01:04:06np.org where this is a vocabulary
- 01:04:09question series with remember the
- 01:04:11percentile three is a remainder so if
- 01:04:14the remainder equals zero then we're
- 01:04:15going to generate that string where the
- 01:04:18object divided by three equals zero has
- 01:04:20no remainder so then we know it's a
- 01:04:21multiple of three number 47 how to
- 01:04:24compute the euclidean distance between
- 01:04:26two series and this one's really cool
- 01:04:29because we have our panda series p and q
- 01:04:32and what i like about this one is they
- 01:04:34give us two solutions you can go with
- 01:04:36and really you should kind of know both
- 01:04:38the first one would be yes you know what
- 01:04:40the euclidean distance is and that is we
- 01:04:42can take the first series minus the
- 01:04:44second series squared and then sum them
- 01:04:46up and then we do the square root which
- 01:04:49is the same as taking the power to 0.5
- 01:04:51doing the power to 0.5 is
- 01:04:54easier than doing the square root so a
- 01:04:57lot of times you'll see that as a switch
- 01:04:59but you could have also done the square
- 01:05:00root and used the math in there so
- 01:05:01there's solution one you should know
- 01:05:03your euclidean distance and then
- 01:05:05solution two is the numpy solution so we
- 01:05:07have np dot lin-alg dot norm that's how
- 01:05:11we're going to compute our euclidean
- 01:05:13distance
- 01:05:14p minus q very elegant and very
- 01:05:16straightforward and easy to compute
- 01:05:19number 48 how to reverse the rows of
- 01:05:22data frame so here we have our data
- 01:05:23frame we're going to create a numpy
- 01:05:25array by 25 reshape it five minus one
- 01:05:28and this creates a 25 by 25 data frame
- 01:05:32and so our solution is to do the dfi
- 01:05:34location and this is just understanding
- 01:05:37how steps work the steps you have your
- 01:05:40colon colon minus one so we're taking
- 01:05:42all the rows all the columns minus one
- 01:05:45so we're stepping minus one going the
- 01:05:47reverse direction and then we're just
- 01:05:49going to use across all the different
- 01:05:50columns on there let me say that again
- 01:05:52the first colon is going to be your row
- 01:05:56starting row stopping row step minus one
- 01:05:59that's all this is about is that step
- 01:06:00minus one comma and then all the columns
- 01:06:0349
- 01:06:04if you split your data into train test
- 01:06:06splits is it possible to over fit your
- 01:06:09model and the answer is yes it's
- 01:06:12definitely possible one common beginner
- 01:06:14mistake is retuning a model or training
- 01:06:17new models with different parameters
- 01:06:18after seeing his performance on the test
- 01:06:20set my favorite example of this is you
- 01:06:23have your script put together and you
- 01:06:25keep hitting the rerun button until you
- 01:06:28get the answer you want not taking the
- 01:06:30answer it first gave you or running it
- 01:06:33over an array and recording all the
- 01:06:34answers to see how they vary number 50
- 01:06:37which python library is built on top of
- 01:06:40matplot library and pandas to ease data
- 01:06:44plotting the answer this is seaborn
- 01:06:46seaborn is a data visualization library
- 01:06:48in python that provides a high level
- 01:06:51interface for drawing statistical
- 01:06:53information and formative graphs
- 01:06:58hi there if you like this video
- 01:07:00subscribe to the simply learn youtube
- 01:07:02channel and click here to watch similar
- 01:07:04videos to nerd up and get certified
- 01:07:07click here
- software development
- coding interviews
- Java questions
- Python questions
- data structures
- multi-threading
- OOP concepts
- algorithms
- JavaScript
- simplylearn