Python Chapter - 4 Notes P2

Relational Operators / रिलेशनल ऑपरेटर

Relational operators compare two values and return a Boolean result: True or False.
दो मानों की तुलना करते हैं और परिणाम देते हैं: सही (True) या गलत (False)।

Operator / ऑपरेटर Meaning / अर्थ Example / उदाहरण Result / परिणाम
>Greater than / बड़ा5 > 3True
<Less than / छोटा3 < 2False
>=Greater or equal / बड़ा या बराबर5 >= 5True
<=Less or equal / छोटा या बराबर4 <= 3False
==Equal to / बराबर4 == 4True
!=Not equal to / बराबर नहीं5 != 4True

Logical Operators / तार्किक ऑपरेटर

Logical operators combine multiple conditions and return True or False based on logical rules.
कई शर्तों को जोड़ते हैं और सही या गलत परिणाम देते हैं।

  • and – True if both conditions are true ✅
    (दोनों शर्तें सही होने पर True)
  • or – True if any condition is true ✅
    (कोई एक या अधिक शर्तें सही होने पर True)
  • not – Reverses the Boolean value ❌
    (सत्य को असत्य और असत्य को सत्य बदल देता है)

Example / उदाहरण

print(5 > 3 and 2 < 4)    # Output: True
print(5 < 3 or 2 > 4)     # Output: False
print(not (5 == 5))          # Output: False

# 'and' only returns True when both sides are true.
# 'or' returns True if any one side is true.
# 'not' flips True to False and vice versa.

# 'and' तभी True देता है जब दोनों शर्तें सही हों।
# 'or' True देता है जब कोई एक शर्त सही हो।
# 'not' बूलियन मान को उलट देता है।
  

Change the values and try running the code to see behavior.
मान बदलें और टिप्पणीकृत कोड चलाकर देखिए परिणाम।

Comments

Popular posts from this blog

O-Level M1 + M2 Test Paper | NIELIT Practice

Introduction to Python Programming in IDLE: Beginners Guide | Python परिचय

IoT Part 3: How Smart Devices Talk (Communication Models)