In [21]:
# here is a comment this is a documentation
# I use the binary input to create a space where you can enter a binary number
def main():
binaryInput = input("Enter a binary number ==> ")
exponentValue = len(binaryInput)
totalValue = 0

if exponentValue < 1:
del binaryInput
del exponentValue
del totalValue
print("All you did was press enter, I need a value")
main()
# the print statemet tells us that wer can only enter o or 1 because we have to convert it to a binary number
# the Print statement is use to show what happenes to what ever that you show
for conversion in range(exponentValue):
if binaryInput[conversion] == "0":
actualValue = 0
elif binaryInput[conversion] == "1":
actualValue = 2
else:
print("0 or 1 please")
del binaryinput
del exponentvalue
del totalValue
main()
# THis shows what the vale of the number the user enters
trueValue = actualValue ** (exponentValue -1)

if actualValue == 0 and exponentValue == 1:
trueValue = 0

exponentValue -= 1

totalValue += trueValue
print("The decimal Value of {} is {} ". format(binaryInput, totalValue))

main()

Enter a binary number ==> 1011
The decimal Value of 1011 is 11

In [ ]: