🧷 8-BO‘LIM: Real Interview’dan olingan savollar va javoblar


🔹 Git: merge vs rebase

Savol: git merge va git rebase orasidagi farq nima?

Javob:

📌 Ishlatish:


🔹 Docker: Image, Container, Volume

Savol: Docker image, container, volume nima?

Javob:

docker build -t myapp .
docker run -v /data:/app/data myapp

🔹 Web: REST API va Django arxitekturasi

Savol: REST nima va Django arxitekturasi qanday?

Javob:


🔹 Database: Index va INNER JOIN

Savol: Index nima? INNER JOIN qanday ishlaydi?

Javob:

SELECT * FROM orders
JOIN customers ON orders.customer_id = customers.id

🔹 CI/CD

Savol: CI/CD tushunchasi qanday?

Javob:


🔹 Python Types & Ops: dict, is vs ==, copy vs deepcopy, mutable


1. dict ichki ishlashi + hash


2. is vs ==

a = [1, 2]; b = a
a is b  # True
a == b  # True

3. copy() vs deepcopy()

from copy import copy, deepcopy

x = [[1], [2]]
shallow = copy(x)
deep = deepcopy(x)

4. Mutable vs Immutable

Type Mutable?
list
tuple
dict
str

🔹 Algorithms: Complexity

Savol: Complexity nima? O(n log n) nima anglatadi?

Javob:


🔹 Functions in Python

Savol: Python’da funksiya nima va qanday obyekt?

Javob:

def outer():
    x = 5
    def inner():
        return x
    return inner

🔹 Memory: Reference Counting

✅ Har bir object’ning ref count bor. gc moduli bilan kuzatish mumkin.

import sys
x = []
print(sys.getrefcount(x))  # 2

🔹 Multitasking: GIL, thread vs process

GIL (Global Interpreter Lock) – CPython’ning global locki → faqat bitta thread ishlaydi

Model Better for
Thread IO-bound
Process CPU-bound

multiprocessing, asyncio, concurrent.futures → parallelizmga erishish yo‘llari


🔹 OOP: Encapsulation, Data hiding

class A:
    def __init__(self):
        self.__secret = 123

🔖 Bonus: Advanced Concepts (Real Interview Recommendations)


🔹 Decorator without @:

def dec(f):
    def wrapper(*a, **kw):
        return f(*a, **kw)
    return wrapper

def hello():
    return "hi"

hello = dec(hello)

🔹 Inheritance, MRO, Diamond, C3 Algorithm

class A: pass
class B(A): pass
class C(A): pass
class D(B, C): pass
print(D.__mro__)

🔹 LEGB Rule (scope)

Scope Description
L Local
E Enclosing
G Global
B Built-in
def outer():
    x = "enclosing"
    def inner():
        print(x)
    inner()