Python math.trunc() နည်းလမ်း
ဥပမာ
မတူညီသောဂဏန်းများ၏ ကိန်းပြည့်အစိတ်အပိုင်းကို ရှာပါ-
# Import math Library
import math
# Return the truncated integer
parts of
different numbers
print(math.trunc(2.77))
print(math.trunc(8.32))
print(math.trunc(-99.29))
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
နည်းလမ်းသည် နံပါတ် တစ်ခု၏ math.trunc()
ဖြတ်တောက်ထားသော ကိန်းပြည့်အပိုင်းကို ပြန်ပေးသည်။
မှတ်ချက်- ဤနည်းလမ်းသည် ဂဏန်းအတက်/အောက်ကို အနီးဆုံးကိန်းပြည့်သို့ ဝိုင်းမည်မဟုတ်သော်လည်း ဒဿမများကို ရိုးရိုးရှင်းရှင်းဖယ်ရှားပါ။
အထားအသို
math.trunc(x)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
x | Required. The number you want to remove the decimal part of. If the value is not a number, it returns a TypeError |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | int ဂဏန်းတစ်ခု၏ ဖြတ်တောက်ထားသော ကိန်းပြည့်အစိတ်အပိုင်းများကို ကိုယ်စားပြုသည့် တန်ဖိုး တစ်ခု |
---|---|
Python ဗားရှင်း- | ၁.၄ |