Python Practice › Tuple Programs › Program 65
Binary tuple to an integer
Write a Python program to convert a tuple of binary digits into an integer.
Input
(1, 0, 0)
Output
4
Approach
- Join the digits and use
int(text, 2).
Solution
bits = (1, 0, 0)print(int("".join(map(str, bits)), 2))Output
4
Learn the concept
New to this topic? Read the lesson, then come back.