Python Data Science Jobs & Interviews
20.6K subscribers
192 photos
4 videos
25 files
334 links
Your go-to hub for Python and Data Scienceβ€”featuring questions, answers, quizzes, and interview tips to sharpen your skills and boost your career in the data-driven world.

Admin: @Hussein_Sheikho
Download Telegram
NUMPY FOR DS.pdf
4.5 MB
Let's start at the top...

NumPy contains a broad array of functionality for fast numerical & mathematical operations in Python

The core data-structure within #NumPy is an ndArray (or n-dimensional array)

Behind the scenes - much of the NumPy functionality is written in the programming language C

NumPy functionality is used in other popular #Python packages including #Pandas, #Matplotlib, & #scikitlearn!

βœ‰οΈ Our Telegram channels: https://t.iss.one/addlist/0f6vfFbEMdAwODBk
Please open Telegram to view this post
VIEW IN TELEGRAM
❀1πŸ‘1
Question 13 (Intermediate):
In NumPy, what is the difference between np.array([1, 2, 3]) and np.array([[1, 2, 3]])?

A) The first is a 1D array, the second is a 2D row vector
B) The first is faster to compute
C) The second automatically transposes the data
D) They are identical in memory usage

#Python #NumPy #Arrays #DataScience

βœ… By: https://t.iss.one/DataScienceQ
❀3
πŸš€ Comprehensive Guide: How to Prepare for a Data Analyst Python Interview – 350 Most Common Interview Questions

Are you ready: https://hackmd.io/@husseinsheikho/pandas-interview

#DataAnalysis #PythonInterview #DataAnalyst #Pandas #NumPy #Matplotlib #Seaborn #SQL #DataCleaning #Visualization #MachineLearning #Statistics #InterviewPrep


βœ‰οΈ Our Telegram channels: https://t.iss.one/addlist/0f6vfFbEMdAwODBk

πŸ“± Our WhatsApp channel: https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
Please open Telegram to view this post
VIEW IN TELEGRAM
❀3
❓ Interview question :
What is NumPy, and why is it essential for scientific computing in Python?

❓ Interview question :
How do arrays in NumPy differ from Python lists?

❓ Interview question :
What is the purpose of ndarray in NumPy?

❓ Interview question :
How can you create a 2D array using NumPy?

❓ Interview question :
What does shape represent in a NumPy array?

❓ Interview question :
How do you perform element-wise operations on NumPy arrays?

❓ Interview question :
What is broadcasting in NumPy, and how does it work?

❓ Interview question :
How do you reshape a NumPy array using reshape()?

❓ Interview question :
What is the difference between copy() and view() in NumPy?

❓ Interview question :
How do you concatenate two NumPy arrays along a specific axis?

❓ Interview question :
What is the role of axis parameter in NumPy functions like sum(), mean(), etc.?

❓ Interview question :
How do you find the maximum and minimum values in a NumPy array?

❓ Interview question :
What are ufuncs in NumPy, and give an example?

❓ Interview question :
How do you sort a NumPy array using np.sort()?

❓ Interview question :
What is the use of np.where() in conditional indexing?

❓ Interview question :
How do you generate random numbers using NumPy?

❓ Interview question :
What is the difference between np.random.rand() and np.random.randn()?

❓ Interview question :
How do you load data from a file into a NumPy array?

❓ Interview question :
What is vectorization in NumPy, and why is it important?

❓ Interview question :
How do you calculate the dot product of two arrays in NumPy?

#️⃣ tags: #NumPy #Python #ScientificComputing #Array #ndarray #ElementWiseOperations #Broadcasting #Reshape #CopyView #Concatenation #AxisParameter #MaximumMinimum #ufuncs #Sorting #ConditionalIndexing #RandomNumbers #DataLoading #Vectorization #DotProduct

By: t.iss.one/DataScienceQ πŸš€
⁉️ Interview question 
What happens when you perform arithmetic operations between a NumPy array and a scalar value, and how does NumPy handle the broadcasting mechanism in such cases?

The operation is applied element-wise, and the scalar is broadcasted to match the shape of the array, enabling efficient computation without explicit loops.

#️⃣ tags: #numpy #python #arrayoperations #broadcasting #interviewquestion

By: t.iss.one/DataScienceQ πŸš€
⁉️ Interview question 
Given the following NumPy code snippet, what will be the output and why?

import numpy as np

arr = np.array([[1, 2], [3, 4]])
result = arr + 5
print(result)

The output will be a 2x2 array where each element is incremented by 5: [[6, 7], [8, 9]]. This happens because NumPy automatically broadcasts the scalar value 5 to match the shape of the array, performing element-wise addition.

#️⃣ tags: #numpy #python #arrayaddition #broadcasting #interviewquestion #programming

By: t.iss.one/DataScienceQ πŸš€
⁉️ Interview question
What will be the output of the following NumPy code snippet?

import numpy as np

arr = np.array([1, 2, 3, 4, 5])
result = arr[1:4:2] + arr[::2]
print(result)


<details><summary>Click to reveal</summary>Answer: [3 5]</details>

#️⃣ tags: #numpy #python #interviewquestion #arrayoperations #slicing #broadcasting

By: @DataScienceQ πŸš€
⁉️ Interview question
What does the following NumPy code return?

import numpy as np

a = np.arange(6).reshape(2, 3)
b = np.array([[1, 2, 3], [4, 5, 6]])
result = np.dot(a, b.T)
print(result)


<details><summary>Click to reveal</summary>Answer: [[ 8 20] [17 47]]</details>

#️⃣ tags: #numpy #python #interviewquestion #arrayoperations #matrixmultiplication #dotproduct

By: @DataScienceQ πŸš€
#numpy #python #programming #question #array #basic

Write a Python code snippet using NumPy to create a 2D array of shape (3, 4) filled with zeros. Then, modify the element at position (1, 2) to be 5. Print the resulting array.

import numpy as np

# Create a 2D array of zeros with shape (3, 4)
arr = np.zeros((3, 4))

# Modify the element at position (1, 2) to be 5
arr[1, 2] = 5

# Print the resulting array
print(arr)

Output:
[[0. 0. 0. 0.]
[0. 0. 5. 0.]
[0. 0. 0. 0.]]

By: @DataScienceQ πŸš€
❀2
#numpy #python #programming #question #array #intermediate

Write a Python program using NumPy to perform the following tasks:

1. Create a 1D array of integers from 1 to 10.
2. Reshape it into a 2D array of shape (2, 5).
3. Compute the sum of each row and store it in a new array.
4. Find the indices of elements greater than 7 in the original 1D array.
5. Print the resulting 2D array, the row sums, and the indices.

import numpy as np

# 1. Create a 1D array from 1 to 10
arr_1d = np.arange(1, 11)

# 2. Reshape into a 2D array of shape (2, 5)
arr_2d = arr_1d.reshape(2, 5)

# 3. Compute the sum of each row
row_sums = np.sum(arr_2d, axis=1)

# 4. Find indices of elements greater than 7 in the original 1D array
indices_greater_than_7 = np.where(arr_1d > 7)[0]

# 5. Print results
print("2D Array:\n", arr_2d)
print("Row sums:", row_sums)
print("Indices of elements > 7:", indices_greater_than_7)

Output:
2D Array:
[[ 1 2 3 4 5]
[ 6 7 8 9 10]]
Row sums: [15 40]
Indices of elements > 7: [7 8 9]

By: @DataScienceQ πŸš€
❀4