Chuyển đến nội dung

Bài 10 · Integers and Rational Numbers

Integers and the Number Line

Meet negative numbers: learn integers, how to place and compare them on a number line, opposites and absolute value, with real-life examples and code.

Whole numbers cannot describe everything. A freezer at 18 degrees below zero, a bank account that is 40 dollars overdrawn, a diver 12 meters under the surface: these need numbers on the other side of zero. Integers include the whole numbers, their negatives and zero:

..., −3, −2, −1, 0, 1, 2, 3, ...

Numbers greater than zero are positive; numbers less than zero are negative. Zero is neither. A negative sign is written with a minus sign directly in front of the number: −7 is read "negative seven".

Integers in real life

Situation Integer
5 degrees Celsius below freezing −5
Gaining 8 points in a game +8
A diver at 12 m below sea level −12
Withdrawing 30 dollars −30
3rd floor above ground 3
2nd basement floor −2

Notice that the sign gives direction and the number gives size.

The number line

A number line is a straight line with equally spaced marks. Zero is the origin. Positive numbers are to the right, negatives to the left.

flowchart LR
    A["-3"] --- B["-2"] --- C["-1"] --- D["0"] --- E["1"] --- F["2"] --- G["3"]

Numbers increase to the right and decrease to the left.

On a number line, a number is always greater than every number to its left. That gives the key rule for comparing integers:

  • Any positive number is greater than any negative number: 2 > −100.
  • Zero is greater than every negative number: 0 > −4.
  • Among negatives, the one closer to zero is greater: −2 > −9. Think of temperature: −2 °C is warmer than −9 °C.
Python Compare and sort integers

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Opposites

Two numbers the same distance from zero on opposite sides are opposites: 5 and −5. The opposite of 0 is 0. Writing a minus sign in front of a number takes its opposite: −(5) = −5, and −(−5) = 5. The opposite of the opposite is the number itself.

Absolute value

The absolute value of a number is its distance from zero on the number line. Distance is never negative. We write it with vertical bars:

  • |7| = 7
  • |−7| = 7
  • |0| = 0

So opposites have the same absolute value. Absolute value ignores direction and keeps only size.

Python Absolute value and distance from zero

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

A larger absolute value does not mean a larger number when the number is negative. |−9| = 9 is bigger than |4| = 4, but −9 < 4.

Distance between two numbers

The distance between two points on a number line is the absolute value of their difference. Between −3 and 5: |5 − (−3)| = |8| = 8. You can also count steps: 3 steps from −3 to 0, then 5 more steps to 5, total 8. (Subtracting negatives is the topic of the next lesson.)

Python Distance between two integers

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. Which list is in order from least to greatest?

    −5 is farthest left, then −1, then 0, then 3.
  2. 2. What is |−15|?

    Absolute value is distance from zero, which is always non-negative.
  3. 3. Which statement is true?

    −6 is to the left of −1, so −6 < −1. Among negatives, the number nearer zero is greater.
  4. 4. What is the distance between −4 and 6 on the number line?

    |6 − (−4)| = |10| = 10. Distance is never negative.

Summary

  • Integers are the whole numbers, their negatives and zero.
  • On a number line, numbers increase to the right; compare by position.
  • Opposites are the same distance from zero on opposite sides.
  • Absolute value is the distance from zero, so it is never negative.
  • Distance between two numbers is the absolute value of their difference.

Next: Adding and Subtracting Integers

Theo dõi tiến độ của bạn

Tạo tài khoản miễn phí để đánh dấu bài đã học và tiếp tục từ chỗ bạn dừng lại trên mọi thiết bị.