np.power/sqrt का इस्तेमाल
power numbers को exponents तक raise करता है और sqrt square roots लेता है, एक साथ हर element के लिए।
In this page:
Syntax
np.power(a, n)
np.sqrt(a)
np.power/sqrt
np.power(a, n) a ** n का function form है और exponents का एक array भी accept करता है। np.sqrt square roots return करता है, और np.cbrt cube roots। Negative floats का sqrt लेना एक warning के साथ nan देता है; ज़रूरत पड़ने पर complex dtype इस्तेमाल करें।
Note:
np.square(a) a ** 2 के लिए एक fast shortcut है।
उदाहरण: np.power/sqrt
import numpy as np
a = np.array([1, 2, 3, 4])
print(np.power(a, 3))
print(np.power(2, a))
print(np.sqrt(a).round(3))
print(np.cbrt(np.array([8, 27])))
# Output:
# [ 1 8 27 64]
# [ 2 4 8 16]
# [1. 1.414 1.732 2. ]
# [2. 3.]
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. #}
आम गलतियां
- Negative numbers का square root लेना
- Negative exponents वाली Integer powers एक error raise करती हैं
- np.power को np.exp से confuse करना
चैप्टर सारांश
- np.power ** operator से match करता है
- Exponents arrays हो सकते हैं
- Negatives का sqrt nan देता है
- np.square और np.cbrt shortcuts हैं
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: