Integers or Int are whole numbers without the decimal point or fractional part. It can be positive or negative or zero.It can be binary, octal or hexadecimal values.

Let’s do mathematical calculation:

Arithmetic operators:

addition = +

subtraction = –

multiplication = *

division = /

modulus = %

exponent = **

floor division = //

exponent = **

floor division = //

-modulus will output the remainder of the division

-exponent will output the exponent

-floor division will output quotient in which the digits after the decimal point are removed.

Examples:

>>> 4+2

6

>>> 4-2

2

>>> 4*2

8

>>> 4/2

2.0

>>> 9/4

2.25

>>> 9%4

1

>>> 9//4

2

So is like 9 divided by 4 = 2 remainder 1.So the quotient without the remainder is the floor division.

So from what I learned, if you use division , the quotient of two whole numbers (int) becomes float because it has decimal point.

Example:

>>> 20/210.0>>> div = 20/2>>> print (div)10.0>>> print (type(div))<class ‘float’>

>>> x = 8+8

>>> print (x)16>>> print (type(x))

<class ‘int’>

Some key things to take note:

1. Leading zeroes are not allowed to represent integeer or whole numbers

e.g.

>>> 012345File “<stdin>”, line 1012345^

SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers

2. It does not allow comma to use as delimeter, use the symbol underscore (_)

e.g.

>>> 1,2,3,4(1, 2, 3, 4)>>> 1_2_3_41234

3. Do not use decimal point, else it will become a float data type

e.g.

>>> x = 100>>> print (type(x))<class ‘int’>>>> x = 100.0>>> print (type(x))<class ‘float’>

4. As mentioned above, integers can be binary, octal or hexadecimal values, but need to use these characters in front of it

binary =

__0b__hexadecimal =

__0x__(or 0X)octal =

__0o__(or 0O)e.g.

decimal= 100

if convert becomes:

binary = 1100100

hexadecimal = 64

octal = 144

octal = 144

>>> 100100>>> 0b1100100100>>> 0x64100>>> 0o144100

5. there’s a function called int() to convert strings to int

>>> x = 12.34>>> int(x)12

>>> x = 777.888>>> int (x)777

>>> int(‘100’)100

If you directly put it inside the int function, you will get something like this error:

>>> int (‘777.888’)Traceback (most recent call last):File “<stdin>”, line 1, in <module>ValueError: invalid literal for int() with base 10: ‘777.888’

Since it is a float, need to do something like this:

>>> int(float(‘777.888’))777