Crack de code
Python
Algorithms & Data Structures
Stat attack
100

What is wrong with the code (Python)
x = 3

if x = 3:

    print("Three!")

Uses = (assignment) instead of == (comparison)

100

What’s the most common Python library for data visualization?

Matplotlib or Seaborn

100

What is the time complexity of a linear search?

O(N)

100

What’s the formula to calculate the mean?

sum(x)/len(x)

200

a = [[0]] * 3

a[0][0] = 99

print(a)


[[99], [99], [99]]

200

What Python command is used to install packages from the Python Package Index?

pip install <package-name>

200

Which data structure uses FIFO (First-In, First-Out)?

кью

200

If all values in a dataset are increased by 5, what statistic in the dataset does not change

std, variance

300

class Person:

    def __init__(self, name):

        name = name

p = Person("Alice")

print(p.name)

Person object has no attribute 'name'

300

Which Python library is commonly used to handle missing data, filtering, and group-by operations in data pipelines?

Pandas

300

def funct(n):

    for i in range(n):

        j = 1

        while j < n:

            j *= 2

            print(i, j)

O(n log n)

300

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

400

def countdown(n):

    if n == 0:

        print("Lift off!")

    else:

        print(n)

        countdown(n - 1)

        countdown(n - 2)


Maximum recursion depth error

400

a = [1, 2, 3]; b = a; b.append(4) → What is a?

a becomes [1, 2, 3, 4]

400

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)

400

When would we prefer logistic regression over linear regression ?

when dataset has categoricall data

500

result = [x**2 for x in range(5) if x % 2 == 0]

print(result)

[0, 4, 16]

500

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.

500

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.

500

When should you use median instead of mean to describe the central tendency of a dataset

When distribution is skewed