Skip to main content

Section 14.4 Summary of Expression Types

Here is a table summarizing the basic arithmetic operations:
Table 14.4.1.
Expression Arithmetic meaning
1 + 2 Addition, the result is 3
3 * 4 Multiplication, the result is 12
4 / 3 Division, the result is 1.333333333333
4 // 3 Integer Division, the result is 1
16 % 3 Modulo (remainder), the result is 1
2 ** 3 Power, 2 to the 3rd power - the result is 8
-1 Negation, the result is -1

Checkpoint 14.4.2.

    What is the result of 3 / 4?
  • 0
  • In some languages, this would be correct. But, this book uses Python, so you get a decimal result.
  • 1
  • No, try again.
  • 0.75
  • Correct.
  • 0.25
  • This would be correct if it was 1 / 4, 1.0 / 4, or 1 / 4.0

Checkpoint 14.4.3.

    What is the result of 8 // 5?
  • 2
  • You will get an integer answer, but that is not it.
  • 1
  • Correct. // does integer division.
  • 1.6
  • Remember that // does integer division
  • 0.25
  • This would be correct if it was 1 / 4, 1.0 / 4, or 1 / 4.0

Checkpoint 14.4.4.

    What is the result of 18 % 5?
  • 0
  • This would be correct if it was 18 % 2, but what is the remainder of 18 divided by 5?
  • 1
  • This would be correct if it was 18 % 17, since 17 goes into 18 one time and the remainder is 18 - 17 = 1.
  • 2
  • What is the highest multiple of 5 that is less than or equal to 18? The remainder is 18 - that number.
  • 3
  • The reminder is 3 since 5 goes into 18 three times (15) and 18 - 15 = 3.

Checkpoint 14.4.5.

    What is the result of 2 % 6?
  • 0
  • This would be correct if it was 6 % 2.
  • 1
  • This would be correct if it was some odd number divided by 2, but it is not.
  • 2
  • 6 goes into 2 zero times with 2 left over.
  • 6
  • If you have a smaller number divided by a larger number the remainder is always the smaller number.
You have attempted of activities on this page.