Python Data Science Jobs & Interviews
17.9K subscribers
140 photos
3 videos
5 files
251 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
Question 21 (Beginner):
What is the correct way to check the Python version installed on your system using the command line?

A) python --version
B) python -v
C) python --v
D) python version

#Python #Basics #Programming #Beginner

By: https://t.iss.one/DataScienceQ
1
Question 22 (Interview-Level):
Explain the difference between deepcopy and regular assignment (=) in Python with a practical example. Then modify the example to show how deepcopy solves the problem.

import copy

# Original Problem
original = [[1, 2], [3, 4]]
shallow_copy = original.copy()
shallow_copy[0][0] = 99
print(original) # What happens here?

# Solution with deepcopy
deep_copied = copy.deepcopy(original)
deep_copied[1][0] = 77
print(original) # What happens now?


Options:
A) Both modify the original list
B) copy() creates fully independent copies
C) Shallow copy affects nested objects, deepcopy doesn't
D) deepcopy is slower but creates true copies

#Python #Interview #DeepCopy #MemoryManagement

By: https://t.iss.one/DataScienceQ
2
Question 23 (Advanced):
How does Python's "Name Mangling" (double underscore prefix) work in class attribute names, and what's its practical purpose?

class Test:
def __init__(self):
self.public = 10
self._protected = 20
self.__private = 30 # Name mangling

obj = Test()
print(dir(obj)) # What happens to __private?


Options:
A) Completely hides the attribute
B) Renames it to _Test__private
C) Makes it immutable
D) Converts it to a method

#Python #OOP #NameMangling #Advanced

By: https://t.iss.one/DataScienceQ
Question 24 (Advanced - NSFW Detection):
When implementing NSFW (Not Safe For Work) content detection in Python, which of these approaches provides the best balance between accuracy and performance?

A) Rule-based keyword filtering
B) CNN-based image classification (e.g., MobileNetV2)
C) Transformer-based multimodal analysis (e.g., CLIP)
D) Metadata analysis (EXIF data, file properties)

#Python #NSFW #ComputerVision #DeepLearning

By: https://t.iss.one/DataScienceQ
2
Python Data Science Jobs & Interviews
Question 21 (Beginner): What is the correct way to check the Python version installed on your system using the command line? A) python --version B) python -v C) python --v D) python version #Python #Basics #Programming #Beginner By: htt…
Correct answer: A) `python --version`

*Additional Info:*
- On some systems, you might need to use python3 --version
- To see more details, you can use python -VV (capital V twice)
- This works on Windows, macOS, and Linux

$ python --version
Python 3.9.7 # Example output


*Note: The other options will either show an error or unexpected output*
Python Data Science Jobs & Interviews
Question 22 (Interview-Level): Explain the difference between deepcopy and regular assignment (=) in Python with a practical example. Then modify the example to show how deepcopy solves the problem. import copy # Original Problem original = [[1, 2],…
Correct answer: C) Shallow copy affects nested objects, deepcopy doesn't

*Expected Output:*
[[99, 2], [3, 4]]  # Shallow copy modified nested list in original
[[99, 2], [3, 4]] # Original remains unchanged after deepcopy modification


*Key Points for Interview Discussion:*
1. Shallow copy (copy()) only copies references to nested objects
2. deepcopy recursively copies all nested objects
3. Critical when working with:
- Nested lists/dictionaries
- Custom objects with mutable attributes
4. Trade-off: deepcopy has higher memory/time overhead
Python Data Science Jobs & Interviews
Question 23 (Advanced): How does Python's "Name Mangling" (double underscore prefix) work in class attribute names, and what's its practical purpose? class Test: def __init__(self): self.public = 10 self._protected = 20 self.__private…
Correct answer: B) Renames it to `_Test__private`

*Key Insights:*
1. Syntax: __name becomes _ClassName__name
2. Purpose: Prevents accidental override in inheritance
3. NOT true privacy: Can still be accessed via mangled name
4. Common Use: Framework development to avoid naming collisions

*Example Output:*
['_Test__private', '_protected', 'public', ...]  # Notice the mangled name


*Interview Tip:*
- Contrast with single underscore _var (convention only)
- Explain why this isn't used for real security/encryption
Python Data Science Jobs & Interviews
Question 24 (Advanced - NSFW Detection): When implementing NSFW (Not Safe For Work) content detection in Python, which of these approaches provides the best balance between accuracy and performance? A) Rule-based keyword filtering B) CNN-based image classification…
Correct answer: B) CNN-based image classification (e.g., MobileNetV2)

# Sample implementation using TensorFlow/Keras
from tensorflow.keras.applications import MobileNetV2
from tensorflow.keras.preprocessing import image
from tensorflow.keras.applications.mobilenet_v2 import preprocess_input
import numpy as np

# Load pre-trained NSFW detection model (conceptual example)
model = MobileNetV2(weights='imagenet') # In practice, use NSFW-specific weights

def is_nsfw(img_path):
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = preprocess_input(x)
preds = model.predict(np.expand_dims(x, axis=0))
return preds[0][0] > 0.5 # Threshold for NSFW class


### Key Considerations:
1. CNNs (B) offer best speed/accuracy tradeoff (5-50ms inference)
2. Transformers (C) are more accurate but slower (300ms+)
3. Rule-based (A) fails for visual content
4. Metadata (D) can be easily spoofed

### Production Tips:
- Use quantization for mobile deployment
- Combine with hash-based filtering for known content
- Consider ethical implications of false positives/negatives
2
Question 25 (Advanced - CNN Implementation in Keras):
When building a CNN for image classification in Keras, what is the purpose of Global Average Pooling 2D as the final layer before classification?

A) Reduces spatial dimensions to 1x1 while preserving channel depth
B) Increases receptive field for better feature extraction
C) Performs pixel-wise normalization
D) Adds non-linearity before dense layers

#Python #Keras #CNN #DeepLearning

By: https://t.iss.one/DataScienceQ
1
Question 26 (Intermediate - Edge Detection):
In Python's OpenCV, which of these edge detection techniques preserves edge directionality while reducing noise?

A) cv2.Laplacian()
B) cv2.Canny()
C) cv2.Sobel() with dx=1, dy=1
D) cv2.blur() + thresholding

#Python #OpenCV #EdgeDetection #ComputerVision

By: https://t.iss.one/DataScienceQ
Question 27 (Intermediate - List Operations):
What is the time complexity of the list.insert(0, item) operation in Python, and why?

A) O(1) - Constant time (like appending)
B) O(n) - Linear time (shifts all elements)
C) O(log n) - Logarithmic time (binary search)
D) O(n²) - Quadratic time (worst-case)

#Python #DataStructures #TimeComplexity #Lists

By: https://t.iss.one/DataScienceQ
Python Data Science Jobs & Interviews
Question 25 (Advanced - CNN Implementation in Keras): When building a CNN for image classification in Keras, what is the purpose of Global Average Pooling 2D as the final layer before classification? A) Reduces spatial dimensions to 1x1 while preserving…
Correct answer: A) Reduces spatial dimensions to 1x1 while preserving channel depth

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Conv2D, GlobalAveragePooling2D, Dense

model = Sequential([
Conv2D(32, (3,3), activation='relu', input_shape=(64,64,3)),
# ... more conv layers ...
GlobalAveragePooling2D(), # Reduces HxW to 1x1
Dense(10, activation='softmax') # Classification layer
])


### Key Advantages:
1. Parameter Efficiency: Eliminates need for flattening + dense layers
2. Translation Invariance: Summarizes spatial information
3. Regularization Effect: Reduces overfitting vs. dense layers

### Comparison:
- Without GAP: Flatten()Dense(256)Dense(10) (200K+ params)
- With GAP: Direct to Dense(10) (~500 params)

*Common Use Cases:*
- Lightweight mobile models (MobileNet)
- Feature extraction for transfer learning
Python Data Science Jobs & Interviews
Question 26 (Intermediate - Edge Detection): In Python's OpenCV, which of these edge detection techniques preserves edge directionality while reducing noise? A) cv2.Laplacian() B) cv2.Canny() C) cv2.Sobel() with dx=1, dy=1 D) cv2.blur() + thresholding…
Correct answer: C) `cv2.Sobel()` with dx=1, dy=1

import cv2
import numpy as np

img = cv2.imread('image.jpg', cv2.IMREAD_GRAYSCALE)

# Sobel with directional gradients
sobel_x = cv2.Sobel(img, cv2.CV_64F, 1, 0, ksize=5) # Horizontal edges
sobel_y = cv2.Sobel(img, cv2.CV_64F, 0, 1, ksize=5) # Vertical edges
combined = np.sqrt(sobel_x**2 + sobel_y**2) # Magnitude preserves direction


### Key Characteristics:
1. Sobel:
- Outputs gradient magnitude and direction (via dx/dy)
- Kernel size (ksize) controls sensitivity
- Use cv2.CV_64F to handle negative gradients

2. Alternatives:
- Laplacian: No directionality (2nd derivative)
- Canny: Directional but non-linear (hysteresis thresholding)
- blur: Loses edges

### Practical Tip:
# Visualize edge directions
angles = np.arctan2(sobel_y, sobel_x) # -π to π radians
hsv = np.zeros((*img.shape, 3), dtype=np.uint8)
hsv[..., 0] = (angles + np.pi) * 90/np.pi # Hue = direction
hsv[..., 2] = cv2.normalize(combined, None, 0, 255, cv2.NORM_MINMAX) # Value = magnitude
direction_map = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR)
Python Data Science Jobs & Interviews
Question 27 (Intermediate - List Operations): What is the time complexity of the list.insert(0, item) operation in Python, and why? A) O(1) - Constant time (like appending) B) O(n) - Linear time (shifts all elements) C) O(log n) - Logarithmic time…
Correct answer: B) O(n) - Linear time (shifts all elements)

import timeit

# Benchmark demonstration
def test_insert(n):
lst = list(range(n))
start = timeit.default_timer()
lst.insert(0, -1) # Insert at beginning
return timeit.default_timer() - start

sizes = [10**3, 10**4, 10**5]
times = [test_insert(n) for n in sizes]
print(times) # Times increase linearly with n


### Key Insights:
1. Memory Layout: Python lists are contiguous arrays
2. Insert at 0: Requires shifting all existing elements right
3. Append vs Insert:
- lst.append(): O(1) amortized
- lst.insert(0): Always O(n)

### Performance Comparison:
# Alternative O(1) options for frequent front-insertions:
from collections import deque
d = deque()
d.appendleft(1) # O(1) operation


*Use Case Guide*:
- Lists: Best for back-heavy operations
- Deque: Preferred for queue-like operations (FIFO)
🙏💸 500$ FOR THE FIRST 500 WHO JOIN THE CHANNEL! 🙏💸

Join our channel today for free! Tomorrow it will cost 500$!

https://t.iss.one/+QHlfCJcO2lRjZWVl

You can join at this link! 👆👇

https://t.iss.one/+QHlfCJcO2lRjZWVl
This channels is for Programmers, Coders, Software Engineers.

0️⃣ Python
1️⃣ Data Science
2️⃣ Machine Learning
3️⃣ Data Visualization
4️⃣ Artificial Intelligence
5️⃣ Data Analysis
6️⃣ Statistics
7️⃣ Deep Learning
8️⃣ programming Languages

https://t.iss.one/addlist/8_rRW2scgfRhOTc0

https://t.iss.one/Codeprogrammer
Please open Telegram to view this post
VIEW IN TELEGRAM
2
Question 30 (Intermediate - PyTorch):
What is the purpose of torch.no_grad() context manager in PyTorch?

A) Disables model training
B) Speeds up computations by disabling gradient tracking
C) Forces GPU memory cleanup
D) Enables distributed training

#Python #PyTorch #DeepLearning #NeuralNetworks

By: https://t.iss.one/DataScienceQ
🔥1
Question 31 (Intermediate - Django ORM):
When using Django ORM's select_related() and prefetch_related() for query optimization, which statement is correct?

A) select_related uses JOINs (1 SQL query) while prefetch_related uses 2+ queries
B) Both methods generate exactly one SQL query
C) prefetch_related works only with ForeignKey relationships
D) select_related is better for many-to-many relationships

#Python #Django #ORM #Database

By: https://t.iss.one/DataScienceQ
🔥1
Question 32 (Advanced - NLP & RNNs):
What is the key limitation of vanilla RNNs for NLP tasks that led to the development of LSTMs and GRUs?

A) Vanishing gradients in long sequences
B) High GPU memory usage
C) Inability to handle embeddings
D) Single-direction processing only

#Python #NLP #RNN #DeepLearning

By: https://t.iss.one/DataScienceQ
2
Please open Telegram to view this post
VIEW IN TELEGRAM
1
Please open Telegram to view this post
VIEW IN TELEGRAM
1