Tüm uzmanlıklarTeknoloji · İş görüşmesi

Python

Python mülakatları dil ayrıntılarını pratik alışkanlıklarla karıştırır. Her fikri küçük bir örnekle, kısa sözlü cümlelerle anlatmayı çalışın.

Kelimeler → ifadeler → cümleler → konuşma

SpeakRole’i dene ↗
İş görüşmesiPython
V

When would you choose Python over a statically typed language?

0:18
Mülakat sorusu

Python

Python mülakatçıları basit görünen ama altında bir neden olan şeyleri sormayı sever: bir tuple neden sözlük anahtarı olabilir, bir generator gerçekte ne yapar ve thread'ler neden diğer dillerden farklı davranır. İyi bir cevap yalnızca kuralı değil, mekanizmayı da açıklar.

Her cevap için aynı biçimi kullanın: tek cümlelik bir tanım, kısa bir örnek ve gerçek bir projede bunu ne zaman kullanacağınıza dair bir not. Davranış Python sürümüne bağlıysa bunu söyleyin ve hangi sürümü kullandığınızı belirtin.

  • ✓Kelimeler → ifadeler → cümleler → konuşma
  • ✓Yanıtın anlamı
  • ✓Dil

Sık sorulan mülakat soruları ve örnek cevaplar

What is the difference between a list and a tuple, and when would you use each?

List ile tuple arasındaki fark nedir ve her birini ne zaman kullanırsınız?

Mülakatçı ne duymak ister. Değiştirilebilirlik (mutability), bunun sonucu olarak hash'lenebilirlik, yüzeysel değişmezlik (shallow immutability) ve hıza değil anlama göre yapılan seçim.

Yüksek sesle çalışmak için İngilizce örnek cevap

Both are ordered sequences. The main difference is that a list is mutable and a tuple is immutable. I can change, add or remove items in a list, but not in a tuple. Because of this, a tuple of immutable items is hashable, so it can be a dictionary key or a set member, and a list cannot. I use a list for a collection that grows or changes, like a list of results. I use a tuple for a fixed record, like coordinates or a returned pair of values. Remember that immutability is shallow: a tuple that contains a list can still change that list. I choose by meaning, not by speed.

What is a generator, and why would you use one?

Generator nedir ve neden kullanırsınız?

Mülakatçı ne duymak ister. yield ile tembel değerlendirme (lazy evaluation), bellek tasarrufu, iterator protokolüne bağlantı ve tek kullanımlık olma sınırı.

Yüksek sesle çalışmak için İngilizce örnek cevap

A generator is a function that uses yield to produce values one at a time instead of returning a full list. It keeps its state between calls and computes each value only when it is requested. This is lazy evaluation, and it saves memory: I can process a very large file line by line without loading all of it. Under the hood, it follows the iterator protocol, with the special methods dunder-iter and dunder-next, which a for loop calls for me. There is also a short syntax called a generator expression, with round brackets. The limit is that a generator can be used only once. After it is exhausted, I must create a new one.

What is the GIL, and how do you handle concurrency in Python?

GIL nedir ve Python'da eşzamanlılığı (concurrency) nasıl yönetirsiniz?

Mülakatçı ne duymak ister. Kilidin CPython'da ne yaptığı, I/O-bound ile CPU-bound iş arasındaki fark ve her biri için doğru araç.

Yüksek sesle çalışmak için İngilizce örnek cevap

The GIL, or global interpreter lock, is a lock in the standard CPython interpreter. It allows only one thread to run Python bytecode at a time. So threads do not give real parallelism for CPU-heavy work in pure Python. But for I/O-bound work, like network calls, threads and asyncio work well, because the lock is released while the program waits. For CPU-bound work, I use multiprocessing, where each process has its own interpreter, or I move the heavy part to a library with native code, such as NumPy. Newer Python versions are adding experimental free-threaded builds, but I would check the current status before relying on that.

What is a decorator, and how would you write one?

Decorator nedir ve nasıl yazarsınız?

Mülakatçı ne duymak ister. Birinci sınıf nesne olarak fonksiyonlar, sarmalama (wrapping) fikri, gerçek kullanım senaryoları ve functools.wraps kullanma alışkanlığı.

Yüksek sesle çalışmak için İngilizce örnek cevap

A decorator is a function that takes another function and returns a new function, usually one that wraps the original with extra behaviour. The syntax with the at sign is only a shortcut: decorating a function means passing it to the decorator and assigning the result to the same name. This works because functions are first-class objects in Python. I use decorators for cross-cutting things like logging, timing, caching, retries and access checks. A good habit is to use functools.wraps inside the decorator, so the wrapped function keeps its name and its documentation. A decorator with its own arguments needs one more level: a function that returns the decorator.

How do you keep a Python project reproducible and maintainable?

Bir Python projesini tekrarlanabilir ve bakımı kolay nasıl tutarsınız?

Mülakatçı ne duymak ister. Sanal ortamlar (virtual environments), sabitlenmiş (pinned) bağımlılıklar ve bir ekipte type hint'lerin ve statik denetleyicinin rolü.

Yüksek sesle çalışmak için İngilizce örnek cevap

I give every project its own virtual environment, so its dependencies do not conflict with other projects or with the system Python. I create it with the built-in venv module, or with a tool such as Poetry or uv, and I never install project packages globally. I pin the dependency versions in a lock file or a requirements file, so a colleague and the CI server get exactly the same environment. For type hints, I add annotations to function signatures and run a checker such as mypy or pyright in CI. Python does not enforce the hints at runtime, but the checker finds many mistakes before the code runs. It also makes the code easier to read.

Anahtar terimler nasıl telaffuz edilir

Python
PAY-thon (ilk hece “pie” gibi; th: dil dişlerin arasında)
tuple
TAP-ıl ya da TU-pıl
mutable
MYU-tı-bıl
dunder
DAN-dır (“double underscore” kısaltması)
generator
CEN-ı-rey-tır
decorator
DEK-ı-rey-tır
GIL
gil (sert “g”) ya da harf harf: Cİ-ay-EL
venv
Vİ-env

Cevap vermek için kullanışlı kalıplar

  • In Python, everything is an object.Python'da her şey bir nesnedir.
  • It depends on whether the work is I/O-bound or CPU-bound.Bunun I/O-bound mu yoksa CPU-bound mu olduğuna bağlı.
  • A tuple of immutable items can be a dictionary key.Değiştirilemez (immutable) öğelerden oluşan bir tuple, sözlük anahtarı olabilir.
  • I would use a generator here to save memory.Belleği korumak için burada bir generator kullanırdım.
  • That is a convention in Python, not a rule of the language.Bu, Python'da bir gelenek (convention), dilin kuralı değil.
  • I would check the documentation for the current behaviour.Güncel davranış için dokümantasyona bakardım.
  • In practice, I would pin the dependencies.Pratikte bağımlılıkları sabitlerdim (pin).

Sık yapılan hatalar

  • "Python is slow" deyip durmak. Zamanın nereye gittiğini, CPU'ya mı yoksa beklemeye mi, ve ne yaptığınızı açıklayın: önce profil çıkarın, doğru veri yapısını seçin ve sık çalışan kodu native kütüphanelere taşıyın.
  • "GIL means Python has no threads" ya da "threads are useless" demek. Thread'ler I/O-bound işte hâlâ işe yarar. Sınır, saf Python'da paralel CPU işidir.
  • Varsayılan liste argümanı olan bir fonksiyon yazıp sorunu bilmemek. Varsayılan değer bir kez oluşturulur, bu yüzden çağrılar arasında paylaşılır. Varsayılan olarak None kullanın ve listeyi fonksiyonun içinde oluşturun.
  • "I am working with Python since five years" demek. “for” ile present perfect kullanın: "I have worked with Python for five years". "since"i yalnızca "since 2019" gibi bir başlangıç noktasıyla kullanın. Türkçede “beş yıldır çalışıyorum” denildiği için şimdiki zaman kalıbı akla gelir.
  • Bir list'e "array" demek. Python'da array, standart kütüphaneden ayrı bir türdür. Mülakatçının ne kastettiğinizi bilmesi için "list" ya da "sequence" deyin.

Sıkça sorulan sorular

Hangi Python sürümünden söz etmeliyim?

Son projenizin kullandığı sürümden ve beğendiğiniz bir özellikten; örneğin yeni sürümlerdeki type hint'ler, dataclass'lar ya da structural pattern matching. Kullanmadığınız sürümlerin özelliklerini iddia etmeyin. "I would check the release notes" demek, bir tahminden iyidir.

asyncio bilmem gerekir mi?

Backend ve veri servisi pozisyonları için temelleri bilin: coroutine'ler, event loop, await, ne zaman işe yaradığı (çok sayıda ağ beklemesi) ve ne zaman yaramadığı (CPU yoğun iş). İşinizden gerçek bir örnek, uzun bir tanımdan daha değerlidir.

Mülakatta Python kodu yazacak mıyım?

Çoğu zaman evet: küçük bir fonksiyon ya da bir veri görevi. Önce planınızı söyleyin, boş girdi gibi uç durumlardan söz edin ve enumerate, zip, comprehension'lar ve collections modülü gibi yerleşik araçları kullanın. Sonunda çözümünüzün zaman ve bellek maliyetini söyleyin.

Bir cevabı okumak ile onu söylemek aynı şey değildir. Her soruyu yüksek sesle çalışın, ardından kendi cevabınızın anlamını ve dilini karşılaştırın.

SpeakRole’i dene ↗

Bu alandaki diğer konular