Category: Interview Part 2

  • Q.3 How will you create an identity matrix using numpy?

    Ans. In order to create the identity matrix with numpy, we will use the identity() function. Numpy is imported as npnp.identity(3) We will obtain the output as – array([[1., 0., 0.],[0., 1., 0.],[0., 0., 1.]])

  • Q.2 How will you measure the Euclidean distance between the two arrays in numpy?

    Ans. In order to measure the Euclidean distance between the two arrays, we will first initialize our two arrays, then we will use the linalg.norm() function provided by the numpy library. Here, numpy is imported as np. a = np.array([1,2,3,4,5]) b = np.array([6,7,8,9,10]) # Solution e_dist = np.linalg.norm(a-b) e_dist 11.180339887498949 With data integrity, we can define…

  • Python Data Science Interview

    Q.1 What is a lambda expression in Python? Ans. With the help of lambda expression, you can create an anonymous function. Unlike conventional functions, lambda functions occupy a single line of code. The basic syntax of a lambda function is – lambda arguments: expression An example of lambda function in Python data science is – x =…