Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
More Challenging Math | First Acquaintance
Introduction to Python

More Challenging Math

Nice work! Python provides several additional math operations, including:

  • // - floor division or integer division;
  • % - modulus or remainder after division;
  • ** - exponentiation or raising to a power.

It's important to note that you can't use the traditional ^ symbol for exponentiation in Python, as it yields a different result. The syntax for these operations mirrors that of basic arithmetic. For example, 18 // 4 results in 4, because we're taking the whole number from the division (the actual result being 4.5). 14 % 5 gives 4, because when we divide 14 by 5, the remainder is 4. 4 ** 3 results in 64, because 4 multiplied by itself three times equals 64.

Task

  • On the second line, compute the floor division of 234 by 32.
  • On the fifth line, determine the remainder when 356 is divided by 17.

Why are these operations helpful?

For instance, picture this scenario: You've got $50 and you want to buy as many cookie packs as possible, with each pack priced at $6. You're trying to figure out the max number of packs you can purchase and the change you'll receive. Using the operations above, you can solve this easily.

  • 50 // 6 gives 8, which means you can buy 8 packs;
  • 50 % 6 results in 2, indicating you'll have $2 left after buying 8 packs.

Everything was clear?

Section 1. Chapter 4
toggle bottom row
course content

Course Content

Introduction to Python

More Challenging Math

Nice work! Python provides several additional math operations, including:

  • // - floor division or integer division;
  • % - modulus or remainder after division;
  • ** - exponentiation or raising to a power.

It's important to note that you can't use the traditional ^ symbol for exponentiation in Python, as it yields a different result. The syntax for these operations mirrors that of basic arithmetic. For example, 18 // 4 results in 4, because we're taking the whole number from the division (the actual result being 4.5). 14 % 5 gives 4, because when we divide 14 by 5, the remainder is 4. 4 ** 3 results in 64, because 4 multiplied by itself three times equals 64.

Task

  • On the second line, compute the floor division of 234 by 32.
  • On the fifth line, determine the remainder when 356 is divided by 17.

Why are these operations helpful?

For instance, picture this scenario: You've got $50 and you want to buy as many cookie packs as possible, with each pack priced at $6. You're trying to figure out the max number of packs you can purchase and the change you'll receive. Using the operations above, you can solve this easily.

  • 50 // 6 gives 8, which means you can buy 8 packs;
  • 50 % 6 results in 2, indicating you'll have $2 left after buying 8 packs.

Everything was clear?

Section 1. Chapter 4
toggle bottom row
some-alt