logical operators in python

python reference

العوامل المنطقية logical operators in python من خلال الثلاث كلمات المحجوزة في لغة بايثون (and,or,not) يمكن إجراء فحص مركب من خلال الشرط if, حيث لابد من تحقق أكثر من شرط أو إحدي الشرطين لإجراء بعض الأوامر.

تحقق جميع الشروط لإجراء تنفيذ الأوامر

age = 17
gender = "female"
member = True

if age >= 18 and gender=="male" and member == True:
    print("welcome to my my application")
else:
    print("you not allowed to use this application")

تحقق شرط من إحدى الشروط لإجراء تنفيذ الأوامر

age = 17
gender = "female"
member = True

if age >= 18 or gender=="male" or member == True:
    print("welcome to my my application")
else:
    print("you not allowed to use this application")

التحقق من عدم تحقق الشرط لتعود بالقيمة المنطقية True

age = 17
gender = "female"
member = True
print(not(gender == "female" and age >=18 ))

Leave a Reply