The unofficial CircuitPython Reference

arithmetic operators

description

These operators enable basic arithmetic (addition, subtraction, multiplication, etc.) of values and variables. Most can operate on and return any numeric data type. Division in Python will always result in a float data type.

syntax

OperatorNameDescriptionSyntaxResult
+addadd operands1 + 23
-subtractsubtract operands3 - 21
*multiplymultiply operands4 * 520
/dividedivide value by operand20 / 54.0
%modulodivide value by operand and return the remainder10 % 91
**exponentvalue to the power of operand2 ** 38
//floor divisionvalue divided by operand and return integer without decimals10 // 33

methods

parameters

returns

example code

serial output:

see also: