Mantıksal Operatörler (Logical Operators)
- Verilerimizle nasıl karşılaştırma yapabileceğimizi gördük. Bunların cevaplarını birleştirmek isteyebiliriz. İki ifadenin sonucu da doğru olunca bir şey yapmak veya en az biri doğruyken bir şey yapmak isteyebilirim.
- Bunu sağlayabilmek için
booleanveri tipleri üzerine uygulanabilecek mantıksal operatörlere bakacağız.
- Göreceğimiz mantıksal operatörlerinin uygulandığı veri tipleri
booleanolmalı.
not
not True
False
not False
True
not 5 < 6
False
not 5 == 5
False
a = 4
b = 10
not a < b
False
not (a > b)
True
and
- Sadece iki ifade de
TrueiseTruesonucu verir, yoksaFalseolur.
True and True
True
True and False
False
False and False
False
a = 4
b = 1
c = 10
(a > b) and (b < c)
True
(a > b) and (b > c)
False
or
- Sadece iki ifade de
FalseiseFalsesonucu verir, yoksaTrueolur.
True or True
True
True or False
True
False or False
False
a = 4
b = 1
c = 10
(a > b) or (b < c)
True
(a > b) or (b > c)
True
(a < b) or (b > c)
False
Quiz
Answer the questions to check your understanding.
This lesson includes a short quiz.
Lesson discussion
Swap insights and ask questions about Python Temel
Be the first to start the discussion
Ask a question or share your thoughts about this lesson.