Overview
Do everyday maths in Python: + - * /, whole-number division with // and the remainder with %.
- + - * / and **
- // divides and drops the decimals
- % gives the remainder
Short Course
/ always gives a decimal. // gives only the whole part, and %
gives what is left over.
print(7 / 2) # 3.5
print(7 // 2) # 3 (whole part)
print(7 % 2) # 1 (left over)
print(2 ** 3) # 8 (power)
Task
Write split_guests(guests, per_table) that returns the number of full
tables and the guests left over, e.g. split_guests(10, 4) → (2, 2).
Test Suites
Pending
Stdout