0Pricing
Mojo Academy · Ders

if/else ile Seçim Yapma

Koşullara göre dallanın.

if/else ile Seçim Yapma, CoddyKit'te ücretsiz bir Mojo Academy dersidir. Bu, 4 dersinin 1. 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.

Code That Decides

Programs often need to choose a path. The if statement runs a block only when its condition is true, so your code can react to data. 🔀

Your First if

Write if, a condition, a colon, then an indented block. If the condition holds, Mojo runs the block; otherwise it skips it entirely.

if score > 90:
    print("Top marks!")

Conditions Are Booleans

The bit after if must boil down to True or False. Comparisons like greater-than and equals naturally produce a boolean for you.

var ready = count == 0
if ready:
    print("Empty")

Add an else Branch

Pair else with if to cover the other case. Exactly one of the two blocks runs, so nothing is ever left unhandled.

if temp > 30:
    print("Hot")
else:
    print("Mild")

Indentation Defines the Block

Like Python, Mojo uses indentation to mark what belongs to a branch. Consistent spaces, usually four, keep the structure clear and valid.

Comparison Operators

Build conditions with operators like ==, !=, <, and >=. Each compares two values and hands back the boolean that if needs.

if age >= 18:
    print("Adult")

Chain More Cases with elif

Need more than two paths? Insert one or more elif branches between if and else to test extra conditions in order.

if g >= 90:
    print("A")
elif g >= 80:
    print("B")
else:
    print("C")

Only the First Match Wins

Mojo checks branches top to bottom and stops at the first condition that is true. The rest are skipped, even if they would also match.

Combine Conditions with and / or

Join checks using and and or. With and both must be true; with or just one is enough to enter the block.

if hungry and has_food:
    print("Eat now")

Flip a Condition with not

Put not in front of a condition to invert it. It turns True into False, handy for checking the absence of something.

if not logged_in:
    print("Please sign in")

Nesting Branches

You can place an if inside another branch to refine a decision. Keep nesting shallow so the logic stays easy to read.

if signed_in:
    if is_admin:
        print("Dashboard")

Quick Check

You want to handle three or more separate cases in one decision. Which keyword do you reach for?

Recap

You branch with if, add else for the other case, and chain elif for more. Conditions are booleans you can combine with and, or, and not. 🎯

Sıkça Sorulan Sorular

“if/else ile Seçim Yapma” dersi ücretsiz mi?

Evet — “if/else ile Seçim Yapma” 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.

“if/else ile Seçim Yapma” dersinde ne öğreneceğim?

Koşullara göre dallanı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 1. dersidir.

“if/else ile Seçim Yapma” 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