Skip to content
Sign upLog in
Profile icon

Justine Horesh

@JustineHoresh
Repls
Community
JustineHoresh
JustineHoresh
shared a Post
4 years ago
4
Binary
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
alpedhuezdewey735
alpedhuezdewey735
Screenshot 2022-04-07 2.05.33 PM5 months ago
PranshulMankad
PranshulMankad
Decimal To Binary: print("Converting Decimal Numbers To Binary\n\n") a=int(input("Enter The Number: ")) b=a%2 print(b) c=(a//2)%2 print(c) d=(a//4)%2 print(d) e=(a//8)%2 print(e) f=(a//16)%2 print(f) g=(a//32)%2 print(g) h=(a//64)%2 print(h) i=(a//128)%2 print(i) print("The binary number of the decimal number", a, "is\n", i,h,g,f,e,d,c,b) Binary To Decimal: a=str(input("Enter The Number: ")) b=(a[7:8]) c=(a[6:7]) d=(a[5:6]) e=(a[4:5]) f=(a[3:4]) g=(a[2:3]) h=(a[1:2]) i=(a[0:1]) j=int(b) k=int9 months ago
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 make4 years ago