طريقة بايثون math.floor ()
مثال
تقريب الأرقام لأسفل إلى أقرب عدد صحيح:
# Import math library
import math
# Round numbers down to the
nearest integer
print(math.floor(0.6))
print(math.floor(1.4))
print(math.floor(5.3))
print(math.floor(-5.3))
print(math.floor(22.6))
print(math.floor(10.0))
التعريف والاستخدام
تقوم math.floor()
الطريقة بتقريب رقم لأسفل إلى أقرب عدد صحيح ، إذا لزم الأمر ، وإرجاع النتيجة.
نصيحة: لتقريب رقم لأعلى إلى أقرب عدد صحيح ، انظر إلى الطريقة.
math.ceil()
بناء الجملة
math.floor(x)
قيمه المعامل
Parameter | Description |
---|---|
x | Required. Specifies the number to round down |
تفاصيل تقنية
قيمة الإرجاع: | قيمة تمثل int الرقم المقرّب |
---|---|
تغيير السجل: | Python 3+: إرجاع int قيمة Python 2.x: إرجاع float قيمة |