Ders programı

Ders programı

Python, JS ve Go’da VE, VEYA ve DEĞİL Yaz

Senaryo

Aynı oda rezervasyon kuralını Python, JavaScript ve Go’da özdeş girdilerle karşılaştır.

Seçilen durumAşağıdan bir seçenek seç
Sonuç—
Python
def can_book_room(free_seats: int, has_permission: bool) -> bool:
    return free_seats > 0 and has_permission
JavaScript
export function canBookRoom(freeSeats, hasPermission) {
  return freeSeats > 0 && hasPermission;
}
Go
func canBookRoom(freeSeats int, hasPermission bool) bool {
	return freeSeats > 0 && hasPermission
}

Sıra sende

Her durumu seç ve üç dilin de tamamen aynı boolean sonucu döndürdüğünü doğrula.

Açıklamayı göster
  1. freeSeats = 1, hasPermission = true (VE)

    Python: True | JS: true | Go: true. Yazım farklı, ortak kural aynı.

  2. freeSeats = 2, hasPermission = false (VE)

    Python: False | JS: false | Go: false.

  3. isBlocked = false tersleme (DEĞİL)

    Python: not is_blocked -> True | JS/Go: !isBlocked -> true.

Sözdizimi mantığı gizlemesin. Doğruluk tablon hazırsa sözcükler (and/or/not) ile simgeler (&&/||/!) arasında çeviri birebirdir.

Önce gözden geçir
Ortak test durumlarını indir

Sıra sende

"hasStudentCard VEYA hasGuestPass" kuralını Python, JavaScript ve Go’da yaz.

Sık yapılan hata Python’da && yazmak veya JS/Go’da çift yerine tek & kullanmak.

Çalışmanı kontrol et

Python: has_student_card or has_guest_pass; JS/Go: hasStudentCard || hasGuestPass.

Kısa kontrol

Mantıksal VE için Python, JavaScript ve Go eşleşmesi hangisinde doğrudur?
Yanıtı ve gerekçesini göster

Doğru yanıt Python: and | JavaScript: && | Go: &&

Python and anahtar sözcüğünü, JavaScript ve Go ise && simgesini kullanır.