Informatics Practices
WAP to convert binary number to decimal number.
Python Control Flow
2 Likes
Answer
binary = input("Enter a binary number: ")
decimal = 0
for digit in binary:
decimal = decimal * 2 + int(digit)
print("The decimal equivalent of", binary, "is", decimal)
Output
Enter a binary number: 110
The decimal equivalent of 110 is 6
Answered By
2 Likes