course content

Course Content

Introduction to Python | Mobile-Friendly

Integer Division and ModulusInteger Division and Modulus

If you divide two integers, the result will not always be an integer. For example, if a trunk's capacity is 400 kg, then you can place only two 150kg items in it. The remaining capacity will be 100kg. This simple example shows us the real-life application of integer division and the remainder. The result of the integer division of 400 by 150 is 2, and the remainder is 100.

These operations can be performed in Python using the following operators:

  • // - an integer division
  • % - a remainder

The example above can be represented in code in the following way:


Suppose you have $50 and are willing to buy as many snacks as possible. Each snack costs $15. Find out the maximum possible number of snacks and the leftover amount of change using integer division and the remainder.


Fill in the gaps to answer both questions.

# Find the number of snacks
print("Number of snacks:", 50
# Find the change
print("The change:", 50
Number of snacks: 3
The change: 5

Click or drag`n`drop items and fill in the blanks

Everything was clear?

Section 1. Chapter 7