Python16 min read

Python Numbers

Understand integers, floats, operators, rounding, and the math module with practical examples and outputs.

Emily Davis
August 14, 2025
6.8k299

Numbers are core to programming. Python mainly uses:

  • int for whole numbers
  • float for decimals

Basic arithmetic operators

x = 10
y = 3

print(x + y)
print(x - y)
print(x * y)
print(x / y)
print(x // y)
print(x % y)
print(x ** y)

Expected output:

13
7
30
3.3333333333333335
3
1
1000

What each operator means (concept)

  • / gives true division (usually float)
  • // gives floor division (drops decimal)
  • % gives remainder
  • ** is power/exponent

Rounding and absolute values

print(round(3.7))
print(round(3.14159, 2))
print(abs(-10))

Expected output:

4
3.14
10

math module (advanced operations)

import math

print(math.sqrt(16))
print(math.floor(3.7))
print(math.ceil(3.1))

Expected output:

4.0
3
4

Graph: division behavior

flowchart TD
  A["10 / 3"] --> B[3.333... float]
  C["10 // 3"] --> D[3 int]
  E["10 % 3"] --> F[1 remainder]

In the next lesson, you will learn lists, how indexing works, and how to manipulate collections of data.

#Python#Beginner#Numbers