PYTHON CORE · LESSON 24

Dividing remainder

Mark. · about 11 minutes

Learning with progressRead the summary for free. To save the work, log in to the account.
STEP 1

What's left?

The % sign shows the remainder after division. 7 is divided by 2 three times and 1 remains.

print(7 % 2)

✦ Answer 1.

STEP 2

Check the parity.

An even number is divided by 2 without a remainder. So the remainder is zero.

number = 8
print(number % 2 == 0)

✦ Answer True: eight even.

IN-CLASS PRACTICE

Type the code yourself

Reprint the check. Don't confuse % and /.

number = 10
print(number % 2 == 0)
Open the editor for class work
HOMEWORK

Solve it yourself

Save 9 to number. Is the remainder of dividing number by 2 equal to 1?

The answer is hidden. Use similar examples from the lesson notes.

Opening up your homework