Chapterبەش 2 · Lectureوانە 2.4
Rounding and Decimal Placesنزیککردنەوە و خانە دەییەکان
How to round by hand with the cut-line method, what to do with an exact 5, this course's 4-decimal rule, why rounded numbers do not always add up, how rounding differs from truncation, floor and ceiling, and why Python's round() gives 2 for 2.5 and 2.67 for 2.675.
چۆن بە ڕێگای هێڵی بڕین بە دەست نزیک بکەیتەوە، لەگەڵ 5ـێکی ڕێک چی بکەیت، یاسای ئەم کۆرسە بۆ 4 ، بۆچی ژمارە نزیککراوەکان هەمیشە ڕێک کۆ نابنەوە، چ جیاوازییەکی لەگەڵ ، و هەیە و بۆچی round()ـی Python بۆ 2.5 دەڵێت 2 و بۆ 2.675 دەڵێت 2.67.
What you will learnچی فێر دەبیت
- Round a number to a given number of decimal places with the cut-line method.
- Handle the half-way case and carries correctly.
- Explain rounding error and why you round only once, at the end.
- Choose between rounding, truncation, floor and ceiling.
- Predict what Python's
round()does and round by the school rule with the decimal module.
- ژمارەیەک بە ڕێگای هێڵی بڕین نزیک بکەیتەوە بۆ ئەو ژمارەیەی کە داوا کراوە.
- حاڵەتی نیوەی ڕێگا و گواستنەوە بە دروستی چارەسەر بکەیت.
- ڕوون بکەیتەوە و بۆچی تەنها یەک جار و لە کۆتاییدا نزیک دەکەیتەوە.
- لە نێوان ، ، و هەڵبژێریت.
- پێشبینی بکەیت
round()ـی Python چی دەکات و بەdecimalبە یاسای قوتابخانە نزیک بکەیتەوە.
Why we roundبۆچی نزیک دەکەینەوە
Many answers in statistics never end: , , . Nobody can write all the digits, and nobody needs them. So we keep a fixed number of digits after the decimal point and replace the number with the closest shorter number. This is rounding.
زۆر وەڵام لە کۆتاییان نایەت: ، ، . کەس ناتوانێت هەموو ژمارەکان بنووسێت و کەسیش پێویستی پێیان نییە. بۆیە ژمارەیەکی دیاریکراو لە دوای دەهێڵینەوە و ژمارەکە بە نزیکترین ژمارەی کورتتر دەگۆڕین. ئەمە .
Replacing a number with a shorter, close value, for example keeping only two : look at the next digit; 5 or more rounds up.
گۆڕینی ژمارەیەکە بە نرخێکی کورتتر و نزیک، بۆ نموونە هێشتنەوەی تەنها دوو : سەیری ژمارەی دواتر بکە؛ 5 یان زیاتر بەرەو سەرەوە دەبات.
A position of a digit after the . In 8.736 the digits 7, 3 and 6 are in the first, second and third decimal places.
شوێنی ژمارەیەکە لە دوای . لە 8.736دا ژمارەکانی 7 و 3 و 6 لە خانەی دەیی یەکەم و دووەم و سێیەمدان.
Rounding by hand: the cut-line methodنزیککردنەوە بە دەست: ڕێگای هێڵی بڕین
The course notes round 8.736 to two decimal places with a simple picture: a line that cuts the number.
تێبینییەکانی کۆرسەکە 8.736 بە وێنەیەکی سادە بۆ دوو نزیک دەکەنەوە: هێڵێک کە ژمارەکە دەبڕێت.
- Draw the cut lineهێڵی بڕین بکێشە
Keep two decimal places, so draw a line after the second digit after the point: .
دوو دەهێڵینەوە، بۆیە لە دوای دووەم ژمارەی دوای خاڵەکە هێڵێک بکێشە: .
- Look at one digit onlyتەنها سەیری یەک ژمارە بکە
Look at the first digit after the line: 6. Ignore any digits after it.
سەیری یەکەم ژمارەی دوای هێڵەکە بکە: 6. گوێ مەدە بە ژمارەکانی دوای ئەو.
- Decideبڕیار بدە
6 is 5 or more, so round up: add 1 to the last kept digit, 73 becomes 74. (With 0–4 you keep the digits as they are.)
6 پێنج یان زیاترە، بۆیە بەرەو سەرەوە: 1 بخەرە سەر دوایین ژمارەی هێڵراوە، 73 دەبێتە 74. (بە 0–4 ژمارەکان وەک خۆیان دەهێڵیتەوە.)
- Drop the restئەوانی تر فڕێ بدە
Everything after the line goes. Answer: 8.74.
هەموو شتێکی دوای هێڵەکە لادەبرێت. وەڵام: 8.74.
Why it works: 8.736 lies between 8.73 and 8.74. It is 0.006 away from 8.73 but only 0.004 away from 8.74, so 8.74 is the closest number with two decimal places. The cut-line rule is a quick way to find the closest one.
بۆچی کار دەکات: 8.736 لە نێوان 8.73 و 8.74دایە. 0.006 لە 8.73 دوورە، بەڵام تەنها 0.004 لە 8.74 دوورە، بۆیە 8.74 نزیکترین ژمارەیە کە دوو هەبێت. یاسای هێڵی بڕین ڕێگایەکی خێرایە بۆ دۆزینەوەی نزیکترینیان.
Rounding to decimal places: find the last digit you keep, look at the next "decider" digit, round down or up, and keep needed zeros.
بۆ چەند : دوایین کە دەیهێڵیتەوە بدۆزەرەوە، سەیری دواتر («بڕیاردەر») بکە، بۆ خوارەوە یان سەرەوە نزیکی بکەرەوە و سفرە پێویستەکان بهێڵەوە.
Chapters: 0:27 the last digit and the decider, 0:55 round down or up, 3:35 why trailing zeros matter.
بەشەکان: 0:27 دوایین و «بڕیاردەر»، 0:55 بۆ خوارەوە یان سەرەوە، 3:35 بۆچی سفرەکانی کۆتایی گرنگن.
Exactly 5: the half-way caseڕێک 5: نیوەی ڕێگا
If the first dropped digit is 0, 1, 2, 3 or 4, keep the number. If it is 5, 6, 7, 8 or 9, round up. A 5 with nothing after it is a special case: the number is exactly half-way, for example 8.735 between 8.73 and 8.74. Neither neighbour is closer, so we need a rule. The school rule says: round half up.
ئەگەر یەکەم ژمارەی فڕێدراو 0، 1، 2، 3 یان 4 بوو، ژمارەکە وەک خۆی بهێڵەرەوە. ئەگەر 5، 6، 7، 8 یان 9 بوو، بەرەو سەرەوە نزیکی بکەرەوە. 5ـێک کە هیچی لە دوا نەبێت حاڵەتێکی تایبەتە: ژمارەکە ڕێک لە نیوەی ڕێگادایە، بۆ نموونە 8.735 لە نێوان 8.73 و 8.74دا. هیچ کام لە دوو دراوسێکە نزیکتر نییە، بۆیە پێویستمان بە یاسایەکە. یاسای قوتابخانە دەڵێت: .


Exactly 5: the half-way caseڕێک 5: نیوەی ڕێگا
“5 or more”, and carrying«5 یان زیاتر» و گواستنەوە
Rounding up can carry into the digits on the left, just as in addition: 19.9999 to two places gives 20.00, and 2.7395 to three places gives 2.740.
بەرەو سەرەوە دەکرێت بگوازرێتەوە بۆ ژمارەکانی لای چەپ، هەروەک لە کۆکردنەوەدا: 19.9999 بۆ دوو خانە دەبێتە 20.00 و 2.7395 بۆ سێ خانە دەبێتە 2.740.
This course's rule: 4 decimal places, rounded at the endیاسای ئەم کۆرسە: 4 خانەی دەیی، لە کۆتاییدا نزیک بکەرەوە
Unless a question asks for something else, this course gives decimal answers to 4 decimal places:
ئەگەر پرسیارێک شتێکی تر نەخوازێت، ئەم کۆرسە وەڵامە دەییەکان بە 4 دەدات:
| Exact valueبەهای ورد | To 4 placesبە 4 خانە |
|---|---|
| 1.5789 | |
| 0.6667 | |
| 1.0414 | |
| 2.6458 | |
| 14.8571 |
Round only the final answer. Every rounded number carries a small rounding error, and the errors add up. The 60 values of the next lesson fall into 7 classes with frequencies 4, 5, 9, 12, 16, 7, 7. As percentages of 60 they are exactly 100% together, but rounded to two decimal places they give , and rounded to whole numbers . Nothing was counted wrong: it is only rounding.
تەنها وەڵامی کۆتایی نزیک بکەرەوە. هەر ژمارەیەکی نزیککراو هەڵدەگرێت، هەرچەندە بچووکیش بێت. ئەم هەڵانە کەڵەکە دەبن. 60 نرخەکەی وانەی داهاتوو دەکەونە 7 بە 4، 5، 9، 12، 16، 7، 7. وەک لە 60، پێکەوە ڕێک 100%ن، بەڵام کە بۆ دوو نزیک بکرێنەوە دەبنە و کە بۆ نزیک بکرێنەوە دەبنە . هیچ شتێک بە هەڵە نەژمێردراوە: تەنها .
The small difference between an exact value and its rounded or stored value. Computers store most decimals in binary, so tiny errors appear.
جیاوازییە بچووکەکەی نێوان نرخێکی ورد و نرخە نزیککراوەکەی یان هەڵگیراوەکەیەتی. کۆمپیوتەر زۆربەی ژمارە دەییەکان بە هەڵدەگرێت، بۆیە هەڵەی زۆر بچووک دەردەکەون.
This course's rule: 4 decimal places, rounded at the endیاسای ئەم کۆرسە: 4 خانەی دەیی، لە کۆتاییدا نزیک بکەرەوە
Round once, at the endیەک جار و لە کۆتاییدا نزیک بکەرەوە
Rounding, truncating, floor and ceilingنزیککردنەوە، بڕینەوە، نەخشەی گەورەترین ژمارەی تەواو و نەخشەی بچووکترین ژمارەی تەواو
Rounding chooses the closest number. Three other tools always go one way, whatever the dropped digits are:
نزیکترین ژمارە هەڵدەبژێرێت. سێ ئامرازی تر هەمیشە بەرەو یەک لا دەڕۆن، ژمارە فڕێدراوەکان هەرچی بن:
Shortening a number by simply dropping the digits after a chosen place, without : 8.736 truncated to two is 8.73. In Python, math.trunc() and int() cut off the fraction part.
کورتکردنەوەی ژمارەیەکە تەنها بە فڕێدانی ژمارەکانی دوای شوێنێکی دیاریکراو، بەبێ : 8.736 بە بڕینەوە بۆ دوو دەبێتە 8.73. لە Pythonـدا math.trunc() و int() بەشی کەرتی فڕێ دەدەن.
| Toolئامراز | Meaningواتا | to 2 places بۆ 2 خانە | to 2 places بۆ 2 خانە |
|---|---|---|---|
| Rounding | closestنزیکترین | ||
| Truncation | cut the extra digits offژمارە زیادەکان ببڕەوە | ||
| Floor | always down (to the left on the number line)هەمیشە بەرەو خوار (بەرەو چەپ لەسەر ) | ||
| Ceiling | always up (to the right)هەمیشە بەرەو سەرەوە (بەرەو ڕاست) |
Floor and ceiling are explained, with their step graphs, in Piecewise functions: absolute value, floor and ceiling. They give a neat formula for school rounding of a positive number to a whole number: . For 8.736: .
و لەگەڵ هێڵکارییە پلەدارەکانیان لە نەخشە ڕێسا پەلدارەکان: نرخی ڕووت، نەخشەی گەورەترین ژمارەی تەواو و نەخشەی بچووکترین ژمارەی تەواو ڕوون کراونەتەوە. بۆ قوتابخانە بۆ ، بۆ هاوکێشەیەکی جوان دەدەن: . بۆ 8.736: .
When you must round up: when a smaller answer would not be enough. 45 students travel in buses of 20 seats: , and 2 buses leave 5 students behind, so you need . The same happens in the next lesson: a class width of must be rounded up to 15, because a width of 14 would leave the largest values outside the table (see class width).
کەی دەبێت بەرەو سەرەوە نزیک بکەیتەوە: کاتێک وەڵامێکی بچووکتر بەس نییە. 45 قوتابی بە پاسی 20 کورسی گەشت دەکەن: ، 2 پاس 5 قوتابی بەجێ دەهێڵێت، بۆیە پێویستت بە پاسە. لە وانەی داهاتوودا هەمان شت ڕوو دەدات: دەبێت بەرەو سەرەوە بۆ 15 نزیک بکرێتەوە، چونکە پانیی 14 گەورەترین نرخەکان لە دەرەوەی خشتەکە دەهێڵێتەوە (سەیری پانیی کلاس بکە).
import math
x = 8.736
print(round(x, 2)) # nearest: 8.74
print(math.trunc(x * 100) / 100) # cut off the rest
print(math.floor(x * 100) / 100) # always down
print(math.ceil(x * 100) / 100) # always up
print(math.ceil(104 / 7)) # a class width must be rounded up8.74 8.73 8.73 8.74 15
Rounding in Python: round half to evenنزیککردنەوە لە Pythonـدا: نیوە بۆ جووت
Python's round() does not use the school rule for exact halves. It uses round half to even: an exact half goes to the neighbour whose last digit is even. The basics of round() are in Operators and expressions; here is what it means for statistics.
round()ـی Python بۆ نیوە ڕێکەکان یاسای قوتابخانە بەکار ناهێنێت. بەکار دەهێنێت: نیوەیەکی ڕێک دەچێت بۆ ئەو دراوسێیەی کە دوایین ژمارەی جووتە. بنەماکانی round() لە کارپێکەرەکان و دەربڕینەکاندان؛ لێرەدا دەبینین چ واتایەکی بۆ هەیە.
A rounding rule that sends an exact half to the nearest even digit, so ties do not always go up. Python's round() uses it.
یاسایەکی کە نیوەی ڕێک دەنێرێت بۆ نزیکترین ژمارەی جووت، بۆیە هاوتاکان هەمیشە بەرەو سەرەوە ناچن. round()ـی Python ئەمە بەکار دەهێنێت.
print(round(8.736, 2)) # the cut-line example
print(round(0.5), round(1.5), round(2.5), round(3.5)) # exact halves go to the even neighbour
print(round(0.125, 2)) # 0.125 is stored exactly: a true tie
print(round(2.675, 2)) # a surprise: see below8.74 0 2 2 4 0.12 2.67
Why even? Imagine rounding many exact halves. The school rule always goes up, so the total drifts upwards. Half to even sends half of them up and half down, so the total stays fair:
بۆچی جووت؟ وێنا بکە زۆر نیوەی ڕێک نزیک دەکەیتەوە. یاسای قوتابخانە هەمیشە بەرەو سەرەوە دەچێت، بۆیە کۆی گشتی بەرەو سەرەوە دەخزێت. نیوە بۆ جووت نیوەیان بەرەو سەرەوە و نیوەیان بەرەو خوار دەنێرێت، بۆیە کۆی گشتی دادپەروەر دەمێنێتەوە:
ties = [0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5]
print(sum(ties)) # the true total
print(sum(round(t) for t in ties)) # Python: half to even
print(sum(int(t + 0.5) for t in ties)) # school rule: half up50.0 50 55
This is why half to even is the default rule for floating-point numbers in computers (the IEEE 754 standard) and in Python's decimal module; in money matters it is also called banker's rounding. By hand, in this course, use the school rule.
لەبەر ئەمەیە کە نیوە بۆ جووت یاسای بنەڕەتیی لە کۆمپیوتەردایە (ستانداردی IEEE 754) و decimalـی Pythonـیش هەر ئەمە بەکار دەهێنێت؛ لە کاروباری پارەدا پێی دەڵێن بانکی. بە دەست، لەم کۆرسەدا، یاسای قوتابخانە بەکار بهێنە.
Rounding in Python: round half to evenنزیککردنەوە لە Pythonـدا: نیوە بۆ جووت
Why round(2.675, 2) gives 2.67بۆچی round(2.675, 2) دەکاتە 2.67
This is not the half-to-even rule (with an exact half the even neighbour would be 2.68). The reason is storage. A float (decimal numbers in Python) keeps numbers in binary, and 2.675 has no exact binary form. Python stores the closest binary number, which is a tiny bit smaller than 2.675 — so it is below half-way and rounds down:
ئەمە یاسای نیوە بۆ جووت نییە (بە نیوەیەکی ڕێک دراوسێ جووتەکە 2.68 دەبوو). هۆکارەکە هەڵگرتنە. Python هەر (ژمارە کەرتییەکان لە Pythonـدا) بە هەڵدەگرێت و 2.675 هیچ شێوەیەکی وردی نییە. Python نزیکترین ژمارەی هەڵدەگرێت کە کەمێک بچووکترە لە 2.675 — بۆیە لە خوار نیوەی ڕێگاوەیە و بەرەو خوار دەچێت:
from decimal import Decimal
print(Decimal(2.675)) # the number the float really holds
print(Decimal("2.675")) # the decimal number you typed2.67499999999999982236431605997495353221893310546875 2.675
To round exactly by the school rule, give the number to the decimal module as text and ask for ROUND_HALF_UP:
بۆ ئەوەی بە وردی بە یاسای قوتابخانە نزیک بکەیتەوە، ژمارەکە وەک دەق بدە بە decimal و داوای ROUND_HALF_UP بکە:
from decimal import Decimal, ROUND_HALF_UP
def round_half_up(text, places):
step = Decimal(1).scaleb(-places) # 0.01 when places = 2
return Decimal(text).quantize(step, rounding=ROUND_HALF_UP)
print(round_half_up("2.675", 2))
print(round_half_up("2.7395", 3))
print(round_half_up("8.736", 2))
print(round_half_up("12.995", 2))2.68 2.740 8.74 13.00
Explain the codeڕوونکردنەوەی کۆدەکە
- Lineدێڕی 4
scaleb(-places)turns 1 into 0.01 (for 2 places), the step to round to.scaleb(-places)1 دەکاتە 0.01 (بۆ 2 خانە)، ئەو هەنگاوەی بۆی نزیک دەکەینەوە.- Lineدێڕی 5
Decimal(text)keeps exactly the digits you typed;ROUND_HALF_UPsends halves away from zero, like the school rule.Decimal(text)ڕێک ئەو ژمارانە دەهێڵێتەوە کە نووسیوتن؛ROUND_HALF_UPنیوەکان دوور لە سفر دەنێرێت، وەک یاسای قوتابخانە.
Why 0.7 + 0.6 does not print exactly 1.3: computers store decimals in binary, so floats are approximations.
بۆچی Python بۆ 0.7 + 0.6 ژمارەی 1.2999999999999998 پیشان دەدات: ژمارەی بە هەڵدەگرێت، بۆیە زۆر ژمارەی سادە تەنها نزیکەیین.
Explains the binary storage behind surprises like round(2.675, 2).
هۆکاری ئەنجامی چاوەڕواننەکراوی وەک round(2.675, 2) ڕوون دەکاتەوە: هەڵگرتنی ژمارەکان بە .
Common mistakesهەڵە باوەکان
| Mistakeهەڵە | Exampleنموونە | Correctدروست |
|---|---|---|
| Cutting off instead of rounding لە جیاتی | ||
| “More than 5” ruleیاسای «زیاتر لە 5» | ||
| Rounding twiceدوو جار | ||
| Forgetting the carryلەبیرکردنی گواستنەوە | ||
| Dropping a needed final 0لابردنی 0ـی کۆتایی کە پێویستە | 2.740 written as 2.74 when 3 places are asked2.740 وەک 2.74 نووسراوە کاتێک 3 خانە داوا کراوە | |
| Rounding a class width to the nearest بۆ نزیکترین نزیک کراوەتەوە | , but : the largest values are left out، بەڵام : گەورەترین نرخەکان دەمێننە دەرەوە | round up: 7بەرەو سەرەوە: 7 |
Expecting round() to follow the school ruleچاوەڕوانی ئەوە کە round() یاسای قوتابخانە بەکار بهێنێت | round(2.5) → 2 | use decimal with ROUND_HALF_UPdecimal لەگەڵ ROUND_HALF_UP بەکار بهێنە |
Exercisesڕاهێنانەکان
Round each number with the school rule: (a) 3.14159 to 2 and to 4 places; (b) 0.0049 to 2 places; (c) 12.995 to 2 places; (d) 7.45 to 1 place; (e) 19.9999 to 2 places; (f) 2.0451 to 2 places. You can check your answers with an online rounding calculator such as the one the course notes link to (calculatorsoup.com); it uses the same half-up rule.
هەر ژمارەیەک بە یاسای قوتابخانە نزیک بکەرەوە: (أ) 3.14159 بۆ 2 و بۆ 4 خانە؛ (ب) 0.0049 بۆ 2 خانە؛ (ج) 12.995 بۆ 2 خانە؛ (د) 7.45 بۆ 1 خانە؛ (هـ) 19.9999 بۆ 2 خانە؛ (و) 2.0451 بۆ 2 خانە. دەتوانیت وەڵامەکانت بە ئۆنلاینی بپشکنیت، وەک ئەوەی تێبینییەکانی کۆرسەکە بەستەری بۆ داناوە (calculatorsoup.com)؛ هەمان یاسای نیوە بۆ سەرەوە بەکار دەهێنێت.
Show answerوەڵامەکە پیشان بدە
- (a) 3.14 and 3.1416
- (b) 0.00 — the dropped digit is 4
- (c) 13.00 — the 5 rounds up and carries twice
- (d) 7.5 — the dropped digit is 5
- (e) 20.00 — the carry runs to the left
- (f) 2.05 — only the first dropped digit (5) counts
- (أ) 3.14 و 3.1416
- (ب) 0.00 — ژمارەی فڕێدراو 4ـە
- (ج) 13.00 — 5ـەکە بەرەو سەرەوە دەچێت و دوو جار دەگوازرێتەوە
- (د) 7.5 — ژمارەی فڕێدراو 5ـە
- (هـ) 20.00 — گواستنەوەکە بەرەو چەپ دەڕوات
- (و) 2.05 — تەنها یەکەم ژمارەی فڕێدراو (5) گرنگە
“2.7395 to three decimal places is 2.739, because the next digit, 5, is not more than 5.” What is wrong?
«2.7395 بۆ سێ دەکاتە 2.739، چونکە ژمارەی دواتر، 5، زیاتر نییە لە 5.» چی هەڵەیە؟
Show answerوەڵامەکە پیشان بدە
The rule is “5 or more rounds up”, not “more than 5”. The answer is 2.740.
یاساکە «5 یان زیاتر بەرەو سەرەوە»یە نەک «زیاتر لە 5». وەڵامەکە 2.740ـە.
Exercisesڕاهێنانەکان
More exercisesڕاهێنانی زیاتر
Without running it, predict what this prints. Then run it and explain each line.
بەبێ کارپێکردن پێشبینی بکە ئەمە چی چاپ دەکات. پاشان کاری پێ بکە و هەر دێڕێک ڕوون بکەرەوە.
print(round(6.5), round(7.5))
print(round(12.995, 2))Show answerوەڵامەکە پیشان بدە
print(round(6.5), round(7.5))
print(round(12.995, 2))6 8 12.99
6.5 and 7.5 are exact halves: they go to the even neighbours 6 and 8. 12.995 is stored slightly below 12.995, so it rounds down to 12.99; by hand (school rule) it is 13.00.
6.5 و 7.5 نیوەی ڕێکن: دەچن بۆ دراوسێ جووتەکانیان 6 و 8. 12.995 کەمێک لە خوار 12.995ـەوە هەڵدەگیرێت، بۆیە دەبێتە 12.99؛ بە دەست (یاسای قوتابخانە) دەکاتە 13.00.
For each case, say whether you round to the nearest whole number or always up: (a) the average mark of a class, 67.4; (b) the number of 30-seat classrooms for 95 students; (c) a class width of .
بۆ هەر حاڵەتێک بڵێ بۆ نزیکترین نزیک دەکەیتەوە یان هەمیشە بەرەو سەرەوە: (أ) نمرەی پۆلێک، 67.4؛ (ب) ژمارەی پۆلی 30 کورسی بۆ 95 قوتابی؛ (ج) .
Show answerوەڵامەکە پیشان بدە
- (a) nearest: 67 (or keep 67.4)
- (b) up: classrooms
- (c) up: , so that the classes cover the whole range
- (أ) نزیکترین: 67 (یان 67.4 بهێڵەرەوە)
- (ب) سەرەوە: پۆل
- (ج) سەرەوە: ، بۆ ئەوەی هەموو بگرنەوە
Summaryپوختە
- Rounding replaces a number with the closest number that has the wanted number of decimal places.
- Cut after the last kept place and look at the first dropped digit: 0–4 keep, 5–9 round up.
- This course: 4 decimal places, rounded only at the end, rounded once.
- Truncation, floor and ceiling always go one way; class widths are always rounded up.
- Python's
round()sends exact halves to the even neighbour, and binary floats can make a ‘half’ slightly smaller or larger.
- ژمارەیەک بە نزیکترین ژمارە دەگۆڕێت کە ژمارەی داواکراوی هەبێت.
- لە دوای دوایین خانەی هێڵراوە ببڕە و سەیری یەکەم ژمارەی فڕێدراو بکە: 0–4 وەک خۆی، 5–9 بەرەو سەرەوە.
- ئەم کۆرسە: 4 ، تەنها لە کۆتاییدا و یەک جار نزیک دەکرێتەوە.
- ، و هەمیشە بەرەو یەک لا دەڕۆن؛ هەمیشە بەرەو سەرەوە نزیک دەکرێتەوە.
round()ـی Python نیوە ڕێکەکان دەنێرێت بۆ دراوسێ جووتەکە و دەتوانن «نیوەیەک» کەمێک بچووکتر یان گەورەتر بکەن.
Round 8.736 to two decimal places and explain.8.736 بۆ دوو خانەی دەیی نزیک بکەرەوە و ڕوونی بکەرەوە.
8.74: the first dropped digit is 6, which is 5 or more, so 73 becomes 74.
8.74: یەکەم ژمارەی فڕێدراو 6ـە کە 5 یان زیاترە، بۆیە 73 دەبێتە 74.
Why can rounded percentages add up to 100.01?بۆچی کۆی ڕێژە سەدییەکان دوای نزیککردنەوە دەکرێت ببێتە 100.01؟
Each one carries a small rounding error, and the errors add up.
هەریەکەیان هەڵدەگرێت و هەڵەکان کۆ دەبنەوە.
What is round(2.5) in Python, and why?round(2.5) لە Pythonـدا چەندە و بۆچی؟
2, because Python rounds exact halves to the even neighbour.
2، چونکە Python نیوە ڕێکەکان بۆ دراوسێ جووتەکە نزیک دەکاتەوە.
Lesson complete!وانەکە تەواو بوو!
Well done. Review the key terms, then go on to the next lesson.دەستخۆش. سەیرێکی زاراوە سەرەکییەکان بکەرەوە، پاشان بڕۆ بۆ وانەی داهاتوو.
Key termsزاراوە سەرەکییەکان
Grouping Data: Frequency Tablesپۆلێنکردنی دراوە: خشتەکانی دووبارەبوونەوە
Related lecturesوانە پەیوەندیدارەکان
- Piecewise Functions: Absolute Value, Floor and Ceilingنەخشە ڕێسا پەلدارەکان: نرخی ڕووت، نەخشەی گەورەترین ژمارەی تەواو و نەخشەی بچووکترین ژمارەی تەواو
- Grouping Data: Frequency Tablesپۆلێنکردنی دراوە: خشتەکانی دووبارەبوونەوە
- Operators and Expressionsکارپێکەرەکان و دەربڕینەکان
- Data typesجۆرەکانی دراوە
- Variables and Data Typesگۆڕاوەکان و جۆرەکانی دراوە
References and further readingسەرچاوەکان و خوێندنەوەی زیاتر
- Python documentation: Built-in functions — round() (ties go to the even choice; round(2.675, 2))
- Python tutorial: Floating-point arithmetic — issues and limitations
- Python documentation: decimal — rounding modes (ROUND_HALF_UP, ROUND_HALF_EVEN, default context)
- Python documentation: math — math.floor, math.ceil, math.trunc
- OpenStax, Introductory Statistics 2e, 1.3 Frequency, Frequency Tables, and Levels of Measurement (rounding rule, rounding error in relative frequencies)
- CalculatorSoup: Rounding numbers calculator (round half away from zero) — linked in the course notes
- Wikipedia: IEEE 754 — Rounding rules (round to nearest, ties to even, is the default)
This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.