How to convert binary to int in Python

3 Answers

0 votes
b = 0b101

print(b)

    
    
    
'''
run:
    
5
 
'''

 



answered Apr 23, 2021 by avibootz
0 votes
n = int('101', 2)

print(n)

    
    
    
'''
run:
    
5
 
'''

 



answered Apr 23, 2021 by avibootz
0 votes
n = f'{0b101:#0}'

print(n)

    
    
    
'''
run:
    
5
 
'''

 



answered Apr 23, 2021 by avibootz
...