Search⌘ K
AI Features

Numbers and Strings

Learn to recognize and use Python's various number types like integers, floats, and complex numbers. Understand string representations, formatting methods such as f-strings and format(), and how to convert between strings and numbers effectively.

Introduction to numbers

There are several different kinds of numbers in Python. The following describes all of these:

  • A decimal integer consists of either the number 0 or a sequence of digits not beginning with 0.
  • A binary integer consists of binary digits (0, 1), beginning with 0b or 0B.
  • An octal integer consists of a sequence of octal digits (0 to 7), beginning with 0o or 0O.
  • A hexadecimal integer consists of a sequence of hex digits (0 to 9 and a to f or
...