Skip to content
Sign upLog in
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
4

Binary

JustineHoresh
JustineHoresh

Hello folks. I need a python program that is converting a number in binary like 2=10.
Thanks in advance for your help and sorry for my broken english

4 years ago
You are viewing a single comment. View All
1
finleyparr
finleyparr

num = int(input('Input number between 0 and 255 and I will convert it into binary.'))
if num < 256:
print(bin(num))

this code it quite short but it has an annoying 0b at the start and i dont know how to remove it, but as long as you can ignore it or can remove it yourself, feel free to use it, it took me a couple minutes to make

4 years ago
0
PabloJuan
PabloJuan

@finleyparr

bin(int(x)).split('0b')[1]

2 years ago
1
PranshulMankad
PranshulMankad

@finleyparr
Use StrSlicing Code

First Take The Length By Len(#The Number or Variable Here.)
Then Take #The Variable or Number[3:#The Length]

11 months ago