Top Software Development Interview Questions and Answers For 2022 | Simplilearn

01:07:10
https://www.youtube.com/watch?v=k2v5F6nsI8Y

Summary

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.

Timeline

  • 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.

Show more

Mind Map

Video Q&A

  • 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.

View more video summaries

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