The unofficial CircuitPython Reference

integer

description

Python has 5 primitive classes of data: string, integer, float, boolean, and complex. There is no need to declare a specific data type for variable as Python will infer the data type at assignment.

The integer type stores positive and negative whole numbers in Python. It is declared with the = assignment operator followed by an integer value. Integer values will be stored as they are implicitly.

When declaring a variable in Python it must begin with a letter and the name may only contain letters, numbers, and underscores. For the sake of readability it is conventional to use all lower case letters and numbers for variable names with underscores to separate words. It is best to avoid I and O for single letter variable names as they can look like 1 and 0. Python does not have a constant keyword and there is therefore no enforced constant but again for readability it is conventional to name CONSTANTS with all caps and underscores between words.

syntax

declare an integer (implicit)

my_int = 1983

declare multiple integers

int1, int2, int3 = 3, 8, 3

methods

parameters

returns

example code

serial output:

code.py output:

1983

3

8

3

see also: