What is wrong with the code (Python)
x = 3
if x = 3:
print("Three!")
Uses = (assignment) instead of == (comparison)
What’s the most common Python library for data visualization?
Matplotlib or Seaborn
What is the time complexity of a linear search?
O(N)
What’s the formula to calculate the mean?
sum(x)/len(x)
a = [[0]] * 3
a[0][0] = 99
print(a)
[[99], [99], [99]]
What Python command is used to install packages from the Python Package Index?
pip install <package-name>
Which data structure uses FIFO (First-In, First-Out)?
кью
If all values in a dataset are increased by 5, what statistic in the dataset does not change
std, variance
Person object has no attribute 'name'
Which Python library is commonly used to handle missing data, filtering, and group-by operations in data pipelines?
Pandas
def funct(n):
for i in range(n):
j = 1
while j < n:
j *= 2
print(i, j)
O(n log n)
A dataset has a mean of 50 and a standard deviation of 0. What can you say about all the values in the dataset?
All values in the dataset are exactly 50
def countdown(n):
if n == 0:
print("Lift off!")
else:
print(n)
countdown(n - 1)
countdown(n - 2)
Maximum recursion depth error
a = [1, 2, 3]; b = a; b.append(4) → What is a?
a becomes [1, 2, 3, 4]
def funct(arr):
result = []
for i in range(len(arr)):
for j in range(i + 1, len(arr)):
if arr[i] > arr[j]:
result.append((arr[i], arr[j]))
return result
inversion of the list
O(n^2)
When would we prefer logistic regression over linear regression ?
when dataset has categoricall data
result = [x**2 for x in range(5) if x % 2 == 0]
print(result)
[0, 4, 16]
What’s the key performance difference between a list comprehension and a for loop in Python?
List comprehensions are usually faster, optimized internally in C, and avoid repeated method lookups and function calls.
You’re building a dashboard showing patient alerts in real time. Should you use a list, stack, queue, or set to manage alerts, and why?
A queue is best: alerts are time-ordered (FIFO).
A list allows order but is less efficient.
Stack is LIFO doesn't work for alerts in real time.
Set is unordered.
When should you use median instead of mean to describe the central tendency of a dataset
When distribution is skewed