Skip to content
UPEEC

int(), float() and complex()

Create numbers from strings or other numbers.

Beginner
Comments 0
int("0b1010", 0)     # 10 — base 0 detects the prefix
float("1e-3")        # 0.001
complex(3, 4)        # (3+4j)
abs(complex(3, 4))   # 5.0

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.