DEV Community

loading...
Cover image for Learn Python: Numbers

Learn Python: Numbers

rishiabee profile image Rishi Updated on ・1 min read

Numbers

Integer

i_am_an_integer = 2020 
print(i_am_an_integer)

Float

i_am_a_float = 20.123456  
print(i_am_a_float)

Arthmetic Operations

maths_operation = 6 + 5 - 4 * 3 / 2
print(maths_operation)

Division

Division always returns a float.

float_division = 48 / 2 
print(float_division);


float_division2 = 49 / 3 
print(float_division2);

Integer Division

To do integer division, we must use: //.

integer_division = 50 // 2 
print(integer_division);


integer_division2 = 49 // 3 
print(integer_division2);

Modulus | Remainder

remainder = 17 % 5;
print(remainder)



Discussion

pic
Editor guide