DEV Community

Cover image for Learn Python: Numbers
Rishi
Rishi

Posted on • Edited on

2 1

Learn Python: Numbers

Numbers

Integer

i_am_an_integer = 2020 
print(i_am_an_integer)
Enter fullscreen mode Exit fullscreen mode

Float

i_am_a_float = 20.123456  
print(i_am_a_float)
Enter fullscreen mode Exit fullscreen mode

Arthmetic Operations

maths_operation = 6 + 5 - 4 * 3 / 2
print(maths_operation)
Enter fullscreen mode Exit fullscreen mode

Division

Division always returns a float.

float_division = 48 / 2 
print(float_division);
Enter fullscreen mode Exit fullscreen mode


float_division2 = 49 / 3 
print(float_division2);
Enter fullscreen mode Exit fullscreen mode

Integer Division

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

integer_division = 50 // 2 
print(integer_division);
Enter fullscreen mode Exit fullscreen mode


integer_division2 = 49 // 3 
print(integer_division2);
Enter fullscreen mode Exit fullscreen mode

Modulus | Remainder

remainder = 17 % 5;
print(remainder)
Enter fullscreen mode Exit fullscreen mode



Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs