Skip to main content

All Questions

Filter by
Sorted by
Tagged with
4 votes
4 answers
2k views

Convert Integer to Binary String

This code takes a user input number which is a positive integer, and outputs a string representation of the number in binary. For example, input 2 outputs ...
nexus_2006's user avatar
4 votes
2 answers
1k views

Program to convert number from any base to decimal

I have made a script to convert number from any base to decimal. I am trying to optimize the code because I think it is bloated and can be improved but if I change anything it affects error handling ...
Harvey's user avatar
  • 75
0 votes
1 answer
561 views

Binary to decimal in python

binaryToDecimal = lambda binary: sum([[int(2**index) for index in range(len(binary))][-index-1] for index, char in enumerate(binary) if int(char)]) I wrote a ...
Hum4n01d's user avatar
  • 111
5 votes
1 answer
1k views

Base conversion: decode and encode base to integer

I encountered this question as I am preparing for my code interview. I was implementing a base function that can decode and encode any bases from base 2 to base 36. I think my ...
NinjaG's user avatar
  • 2,489
1 vote
1 answer
423 views

Python Decimal to Binary converter (without using bin() or output formatting)

There is no input validation for this, but that aside, I would appreciate it if anyone could help me improve the logic of this script. ...
Confettimaker's user avatar
2 votes
1 answer
2k views

Python binary to decimal converter (without using built-ins)

Any ideas how I could improve this? I already know that there is no checking for anything other than a 1, so you can enter a 2 ...
Confettimaker's user avatar