np.logical_and/or/not का इस्तेमाल
logical_and, logical_or, और logical_not conditions को element by element combine करते हैं।
In this page:
Syntax
np.logical_and(a, b)
np.logical_or(a, b)
np.logical_not(a)
np.logical_and/or/not
ये functions boolean arrays के लिए &, |, और ~ के named versions हैं। ये कोई भी array-like input accept करते हैं और non-zero को True treat करते हैं। exclusive or के लिए np.logical_xor भी available है।
Note:
Operators के साथ, हर comparison को parentheses में wrap करना याद रखें।
उदाहरण: np.logical_and/or/not
import numpy as np
a = np.array([1, 4, 7, 10, 13])
big = a > 5
even = a % 2 == 0
print(np.logical_and(big, even))
print(np.logical_or(big, even))
print(np.logical_not(big))
# Output:
# [False False False True False]
# [False True True True True]
# [ True True False False False]
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the
view already swaps in the hi_ translation fields (or blanks these
out if untranslated), so this renders correctly for both languages
without a lang_code check here. #}
आम गलतियां
- arrays पर Python का and या or इस्तेमाल करना
- & और | के साथ parentheses भूल जाना
- non-boolean integers पर ~ apply करना
चैप्टर सारांश
- logical_and, & के बराबर है
- logical_or, | के बराबर है
- logical_not, ~ के बराबर है
- data filter करने के लिए masks combine करें
🔒
Chapter Quiz — Complete all 6 topics to unlock
0/6 topics done
Complete these topics first: