Sign in

Intro to Computer Science / Unit 4: Programming Basics in Python

4.3 Arithmetic Operators

3 practice questionsNot yet reviewed

Notes

Python can do math with these operators:

OperatorMeaningExampleResult
+ - *add, subtract, multiply4 * 312
/division (always a float)7 / 23.5
//floor division7 // 23
%remainder (modulus)7 % 21
**exponent2 ** 38
  • Order of operations: parentheses, then **, then * / // %, then + -.
  • 10 / 2 gives 5.0, a float, not 5.
  • n % 2 == 0 is a common test for an even number.

Practice

What does print(17 % 5) display?
What does print(2 + 3 * 4) display?
What does print(10 // 4) display?

Ready for more? Take the Unit 4 test.