# Python program to convert decimal to binary using while loop

## Creating a binary to decimal converter using while loop

makes the loop useless, so the code only executes once no matter If you don 't need to keep the original number, you can change If you want to print all the steps, the print will be inside the loop so it while number!.

and    enemy at the gates full movie in hindi watch online

By using our site, you acknowledge that you have read and understand our Cookie Policy , Privacy Policy , and our Terms of Service. Setup a private space for you and your coworkers to ask questions and share information. Making a "break" without any condition, makes the loop useless, so the code only executes once no matter what. If you want to print all the steps, the print will be inside the loop so it prints multiple times. This is string concatenation.

To understand this example, you should have the knowledge of following Python programming topics:. Decimal number is converted into binary by dividing the number successively by 2 and printing the remainder in reverse order. You can change the variable dec in the above program and run it to test out for other values. This program works only for whole numbers. It doesn't work for real numbers having fractional values such as:

Given a decimal number as input, the task is to write a Python program to convert the given decimal number into equivalent binary number. Below is the implementation of above recursive solution:. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute. 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. Writing code in comment? Please use ide.

Well it looks to me like you are calculating the digits in the reverse order that you want to display them. You can't just print remainder in the order that you calculate it because then the digits are in reverse order, and currently remainder is writing over itself. Currently you HAVE to write over remainder before displaying because you have no place to store the old remainder. Solution: use an array that sets aside an integer for every digit. Since you are using integers and integers have 32 bits, you might as well make an array called digit that would hold 32 integers. So say the user typed in the number In binary, that is:.

## Python Program to Convert Decimal to Binary

.

.

.

.

-

.

.

janet jackson alright with me

.

.

.

## 2 thoughts on “Python program to convert decimal to binary using while loop”

1. Payvertingless says:

Python Program to Convert Decimal to Binary Using Recursion

2. Timotea R. says:

Decimal to binary - Python