0Pricing
Mojo Academy · Ders

while ile Döngü Kurma

Bir koşul değişene kadar tekrarlayın.

while ile Döngü Kurma, CoddyKit'te ücretsiz bir Mojo Academy dersidir. Bu, 4 dersinin 2. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Mojo Academy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Mojo Academy kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Repeat Until Done

Sometimes you must run code again and again. A while loop repeats its block as long as a condition stays true. 🔁

The while Shape

Write while, a condition, a colon, then an indented block. Mojo rechecks the condition before every pass through the body.

while count < 3:
    print(count)

Change the Condition Inside

The body must eventually make the condition false. Usually you update a counter so the loop progresses toward stopping.

var count = 0
while count < 3:
    print(count)
    count += 1

Watch for Infinite Loops

If the condition never turns false, the loop runs forever. An infinite loop usually means you forgot to update the variable it checks.

Condition Checked First

Mojo tests the condition before the first pass. If it is already false, the body never runs even once.

while False:
    print("never shown")

Accumulate a Result

Loops shine when building up a value. Keep a running total in a variable and add to it on each pass.

var total = 0
var i = 1
while i <= 5:
    total += i
    i += 1

Counting Down

A while loop can move in any direction. Start high and decrement each pass to count down toward a stopping point.

var n = 3
while n > 0:
    print(n)
    n -= 1

Loop on a Flag

The condition need not be a number. A boolean flag works too, letting other logic decide when the loop should end.

var running = True
while running:
    running = step()

Combine with if

Inside a while body you can branch with if. This lets each pass make its own decision based on the current state.

while i < 10:
    if i % 2 == 0:
        print(i)
    i += 1

Pick while When Count Is Unknown

Use while when you do not know in advance how many passes you need, such as reading until a value appears.

Update Before You Forget

A reliable habit: put the update step right where the loop must make progress, so the condition can truly change each pass.

Quick Check

You wrote a while loop but it runs forever and never stops. What is the most likely cause?

Recap

A while loop repeats while its condition is true, checking before each pass. Update the condition inside the body to avoid looping forever. 🎯

Sıkça Sorulan Sorular

“while ile Döngü Kurma” dersi ücretsiz mi?

Evet — “while ile Döngü Kurma” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Mojo Academy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Mojo Academy kursu toplamda 4 dersten oluşur.

“while ile Döngü Kurma” dersinde ne öğreneceğim?

Bir koşul değişene kadar tekrarlayın. Mojo Academy ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

Mojo Academy öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Mojo Academy, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 2. dersidir.

“while ile Döngü Kurma” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu Mojo Academy dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Mojo Academy dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. if/else ile Seçim Yapma
  2. while ile Döngü Kurma
  3. for ve range ile Yineleme
  4. break, continue ve Erken Çıkış
← Mojo Academy Sayfasına Dön