• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
July 09, 2022 |38.0K Views
Convert Decimal to Binary in Python
Description
Discussion

In this video, we will learn how to convert decimal to binary numbers using python. We have divided this video into 3 sections .

Below is the list of approaches that we will cover in this section:

1. Understanding how to convert decimal to binary number
2. Brute recursion
3. Approach in-build bin() function

To convert a decimal number to a binary number let us see an example.

Eg: 10
10 in binary is 1010. To find decimal to binary equivalent, divide 10 successively by 2 until the quotient becomes 0. Here we will use a recursion method to get our binary number from any decimal input.

Another method is to use the python in-build function bin() which will give the binary output of any number. for example, 10 = 0b1010. 
Here '0b' represent that the output is in form of binary.

Python program to convert Decimal to Binary:
https://www.geeksforgeeks.org/python-program-to-covert-decimal-to-binary-number/