Given a decimal number as input, the task is to write a Python program to convert the given decimal number into equivalent binary number.
Input : 7 Output :111 Input :10 Output :1010
Method #1: Recursive solution
DecimalToBinary(num): if num > 1: DecimalToBinary(num // 2) print num % 2
Below is the implementation of above recursive solution:
Method #2: Decimal to binary using in-built function
1000 10010 111
- Python program to convert float decimal to Octal number
- Program for Decimal to Binary Conversion
- Program for Binary To Decimal Conversion
- Recursive Program for Binary to Decimal
- Binary to decimal and vice-versa in python
- Python | Decimal to binary list conversion
- Decimal to binary number using recursion
- Python Program to Count number of binary strings without consecutive 1's
- Decimal representation of given binary string is divisible by 20 or not
- Decimal representation of given binary string is divisible by 10 or not
- Decimal to binary conversion without using arithmetic operators
- Program to Convert Octal Number to Binary Number
- Python Program for Binary Insertion Sort
- Python program to convert floating to binary
- Python Program for Binary Search (Recursive and Iterative)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.