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
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
Please open Telegram to view this post
VIEW IN TELEGRAM
2🔥1
Python Data Science Jobs & Interviews
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…
Correct answer: B) Speeds up computations by disabling gradient tracking

import torch

model = torch.nn.Linear(10, 1)
x = torch.randn(5, 10)

# Inference without gradient tracking
with torch.no_grad():
prediction = model(x) # 30-50% faster than regular forward()
print(prediction.requires_grad) # False


### Key Use Cases:
1. Model Inference:
- Reduces memory overhead by ~40%
- Prevents accidental weight updates

2. Validation/Testing:
   for data in val_loader:
with torch.no_grad():
outputs = model(data) # No backprop needed


3. Weight Freezing:
   for param in model.layer.parameters():
param.requires_grad = False # Often used with no_grad()


### Performance Impact:
| Operation | Time (ms) | Memory (MB) |
|--------------------|-----------|-------------|
| Regular Forward | 15.2 | 1200 |
| no_grad() Forward| 9.8 | 720 |

*Note: Critical for deployment where every millisecond matters*
Python Data Science Jobs & Interviews
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…
Correct answer: A) `select_related` uses JOINs (1 SQL query) while `prefetch_related` uses 2+ queries

# Example models
class Author(models.Model):
name = models.CharField(max_length=100)

class Book(models.Model):
title = models.CharField(max_length=100)
author = models.ForeignKey(Author, on_delete=models.CASCADE)
genres = models.ManyToManyField('Genre')

# Optimized queries
books = Book.objects.select_related('author') # Single JOIN query
books = Book.objects.prefetch_related('genres') # 2 queries: books + genres


### Key Differences:
| Method | SQL Queries | Best For | Underlying Mechanism |
|----------------------|-------------|------------------------|----------------------|
| select_related() | 1 | ForeignKey, OneToOne | SQL JOIN |
| prefetch_related() | 2+ | ManyToMany, Reverse FK | Python-level caching |

### Performance Benchmark:
# Without optimization (N+1 problem)
for book in Book.objects.all():
print(book.author.name) # 1 query per book!

# With select_related (1 query total)
for book in Book.objects.select_related('author').all():
print(book.author.name) # Data already loaded


*Pro Tip*: Use Django Debug Toolbar to verify query counts!
Python Data Science Jobs & Interviews
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…
Correct answer: A) Vanishing gradients in long sequences

# Vanilla RNN vs LSTM comparison
import torch.nn as nn

rnn = nn.RNN(input_size=100, hidden_size=50, num_layers=1)
lstm = nn.LSTM(input_size=100, hidden_size=50, num_layers=1)

# Forward pass for 10 timesteps
inputs = torch.randn(10, 1, 100) # (seq_len, batch, input_size)
h_rnn = torch.zeros(1, 1, 50) # Initial hidden state
h_lstm = (torch.zeros(1, 1, 50), torch.zeros(1, 1, 50)) # LSTM state

out_rnn, _ = rnn(inputs, h_rnn) # Prone to vanishing gradients
out_lstm, _ = lstm(inputs, h_lstm) # Better long-term memory


### Key Problems with Vanilla RNNs:
1. Gradient Issues:
- Error signals decay exponentially over timesteps
- Tanh/Sigmoid activations compound the problem

2. LSTM/GRU Solutions:
| Mechanism | Purpose |
|-----------------|----------------------------------|
| Forget Gate | Controls what to remember |
| Input Gate | Regulates new information |
| Cell State | Highway for long-term gradients |

### Practical Impact:
# Training a sentiment analyzer
rnn_model = nn.RNN(embed_dim, hidden_dim) # Fails beyond 50 words
lstm_model = nn.LSTM(embed_dim, hidden_dim) # Handles 500+ words


*Modern Alternative*: Transformers (no recurrent connections at all)
Please open Telegram to view this post
VIEW IN TELEGRAM
1
🔥 Master Vision Transformers with 65+ MCQs! 🔥

Are you preparing for AI interviews or want to test your knowledge in Vision Transformers (ViT)?

🧠 Dive into 65+ curated Multiple Choice Questions covering the fundamentals, architecture, training, and applications of ViT — all with answers!

🌐 Explore Now: https://hackmd.io/@husseinsheikho/vit-mcq

🔹 Table of Contents
Basic Concepts (Q1–Q15)
Architecture & Components (Q16–Q30)
Attention & Transformers (Q31–Q45)
Training & Optimization (Q46–Q55)
Advanced & Real-World Applications (Q56–Q65)
Answer Key & Explanations

#VisionTransformer #ViT #DeepLearning #ComputerVision #Transformers #AI #MachineLearning #MCQ #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
2
🚀 Comprehensive Guide: How to Prepare for a Python Job Interview – 200 Most Common Interview Questions

Are you ready: https://hackmd.io/@husseinsheikho/Python-interviews

#PythonInterview #JobPrep #PythonQuestions #CodingInterview #DataStructures #Algorithms #OOP #WebDevelopment #MachineLearning #DevOps

✉️ 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