Python math.hypot() နည်းလမ်း
ဥပမာ
ထောင့်မှန်တြိဂံ၏ ဟိုက်ထရိုတင်းနစ်ကို ရှာပါ၊
#Import math Library
import math
#set perpendicular and base
parendicular = 10
base = 5
#print the hypotenuse of a right-angled
triangle
print(math.hypot(parendicular, base))
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
math.hypot()
နည်းလမ်းသည် Euclidean စံနှုန်းကို ပြန်ပေးသည် ။ Euclidian စံနှုန်းသည် မူလမှ ပေးထားသော သြဒိနိတ်များဆီသို့ အကွာအဝေးဖြစ်သည်။
Python 3.8 မတိုင်မီတွင်၊ ဤနည်းလမ်းကို ညာဘက်ထောင့်တြိဂံ၏ hypotenuse ကိုရှာဖွေရန်သာ အသုံးပြုခဲ့သည်- sqrt(x*x + y*y)။
Python 3.8 မှ၊ Euclidean စံနှုန်းကိုလည်း တွက်ချက်ရန် ဤနည်းလမ်းကို အသုံးပြုသည်။ n-dimensional ကိစ္စများတွင်၊ ဖြတ်သွားသော သြဒိနိတ်များကို (x1၊ x2၊ x3၊ ..., xn) ကဲ့သို့ဟု ယူဆပါသည်။ ထို့ကြောင့် မူလမှ ယူကလစ်အလျားကို sqrt(x1*x1 + x2*x2 +x3*x3.... xn*xn) ဖြင့် တွက်ချက်သည်။
အထားအသို
math.hypot(x1, x2, x3, ..., xn)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
x1, x2, x3, ..., xn | Required. Two or more points representing coordinates |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | nfloat သွင်းအားစု များအတွက် မူရင်းမှ ယူကလစ်အကွာအဝေးကို ကိုယ်စားပြုသော တန်ဖိုးတစ်ခု ၊ သို့မဟုတ် သွင်းအားစုနှစ်ခုအတွက် ညာထောင့်တြိဂံ၏ hypotenuse၊ |
---|---|
မှတ်တမ်းပြောင်းရန်- | 3.8 မှ- n -dimensional အမှတ်များကိုလည်း ပံ့ပိုးပေးသည်။ အစောပိုင်းဗားရှင်းများသည် နှစ်ဘက်မြင်အချက်များကိုသာ ပံ့ပိုးပေးသည်။ |
နောက်ထပ် ဥပမာများ
ဥပမာ
ပေးထားသောအချက်များအတွက် Euclidean စံနှုန်းကိုရှာပါ
#Import math Library
import math
#print the Euclidean norm for
the given points
print(math.hypot(10, 2, 4, 13))
print(math.hypot(4, 7, 8))
print(math.hypot(12, 14))