VOOZH about

URL: https://www.codecademy.com/resources/docs/python/built-in-functions/bin

⇱ Python | Built-in Functions | bin() | Codecademy


Skip to Content

Python bin()

Preview: Anonymous contributor 3120 total contributions
Anonymous contributor

3120 total contributions

Published Jun 15, 2021Updated Sep 3, 2021

Converts an integer into its binary equivalent string.

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 CoursesIncludes 6 Courses
    • With Professional CertificationWith Professional Certification
    • Beginner Friendly.
      75 hours75 hours
  • Machine Learning Data Scientists solve problems at scale, make predictions, find patterns, and more! They use Python, SQL, and algorithms.
    • Includes 27 CoursesIncludes 27 Courses
    • With Professional CertificationWith Professional Certification
    • Beginner Friendly.
      95 hours95 hours

Syntax

bin(integer)
Copy to clipboard
Copy to clipboard

Example 1

Use bin() function to return the binary equivalent of the integer 1:

print(bin(1))
# Output: 0b1
Copy to clipboard
Copy to clipboard

Example 2

Use bin() to return the binary equivalent of the integer 100:

Visit us
Visit us
Hide code
Code
Output
Hide output
Copy to your clipboard

All contributors

Learn Python on Codecademy

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 CoursesIncludes 6 Courses
    • With Professional CertificationWith Professional Certification
    • Beginner Friendly.
      75 hours75 hours
  • Machine Learning Data Scientists solve problems at scale, make predictions, find patterns, and more! They use Python, SQL, and algorithms.
    • Includes 27 CoursesIncludes 27 Courses
    • With Professional CertificationWith Professional Certification
    • Beginner Friendly.
      95 hours95 hours