Skip to ContentMini Arrow Down Icon
  • Codecademy Logo
  • Codecademy Logo
abs()
all()
any()
ascii()
bin()
bool()
breakpoint()
bytearray()
bytes()
callable()
chr()
classmethod()
compile()
complex()
delattr()
dict()
eval()
filter()
float()
frozenset()
hasattr()
help()
input()
int()
len()
list()
map()
max()
min()
next()
open()
pow()
print()
range()
reversed()
round()
set()
sorted()
str()
super()
tuple()
type()
zip()
Back to Python
  1. Docs/
  2. Python/
  3. Built-in Functions/
  4. bin()

bin()

Open IconEdit on GitHub

Converts an integer into its binary equivalent string.

Syntax

bin(integer)

Example 1

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

print(bin(1))
# Output: 0b1

Example 2

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

Favicon Icon
Code
Output
Loading...

Contributors

  1. net8535613879's avatar'
    net8535613879
Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.
Open IconEdit on GitHub

Learn Python on Codecademy

Career path

Computer Science

Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
Checker Dense
Includes 6 Courses
Checker Dense
Certificate Icon
With Professional Certification
Checker Dense
Level Icon
Beginner Friendly
82 Lessons
Career path

Data Scientist: Machine Learning Specialist

Machine Learning Data Scientists solve problems at scale, make predictions, find patterns, and more! They use Python, SQL, and algorithms.
Checker Dense
Includes 27 Courses
Checker Dense
Certificate Icon
With Professional Certification
Checker Dense
Level Icon
Beginner Friendly
81 Lessons
Course

Learn Python 3

Learn the basics of Python 3, one of the most powerful, versatile, and in-demand programming languages today.
Checker Dense
Certificate Icon
With Certificate
Checker Dense
Level Icon
Beginner Friendly
14 Lessons
Open IconEdit on GitHub

Contributors

  1. net8535613879's avatar'
    net8535613879
    net8535613879's avatar'
    net853561387924 contributions

Company

  • About
  • Careers
  • Affiliates
    • Twitter Icon
    • Facebook Icon
    • Instagram Icon
    • Youtube Icon

Resources

  • Articles
  • Blog
  • Cheatsheets
  • Code challenges
  • Docs
  • Projects
  • Videos
  • Workspaces

Support

  • Help Center

Resources

  • Articles
  • Blog
  • Cheatsheets
  • Code challenges
  • Docs
  • Projects
  • Videos
  • Workspaces

Support

  • Help Center

Plans

  • Paid memberships
  • For students
  • Business solutions

Community

  • Forums
  • Chapters
  • Events
  • Discord

Codecademy from Skillsoft

Codecademy from Skillsoft

Subjects

  • AI
  • Cloud Computing
  • Code Foundations
  • Computer Science
  • Cybersecurity
  • Data Analytics
  • Data Science
  • Data Visualization
  • Developer Tools
  • DevOps
  • Game Development
  • IT
  • Machine Learning
  • Math
  • Mobile Development
  • Web Design
  • Web Development

Languages

  • Bash
  • C
  • C++
  • C#
  • Go
  • HTML & CSS
  • Java
  • JavaScript
  • Kotlin
  • PHP
  • Python
  • R
  • Ruby
  • SQL
  • Swift

Career building

  • Career paths
  • Career services
  • Interview prep
  • Professional certification
  • —
  • Full Catalog
  • Beta Content
  • Roadmap

Mobile

  • Download on the App Store
  • Get it on Google Play

Mobile

  • Download on the App Store
  • Get it on Google Play
  • Privacy Policy
  • Cookie Policy
  • Do Not Sell My Personal Information
  • Terms
Made with ❤️in NYC © 2023 Codecademy