#Aaron McTaggart
#IT
#March 2nd, 2021
def main():
binaryInput = input("Enter A Binary Number >>") #This input makes it so we can type in our 1's and 0's.
exponentValue = len(binaryInput)#This tells the code how long the binary number is
totalValue = 0
#This is telling the user that runs this code that if they put nothing
#there, you have to put something for it to run.
if exponentValue < 1:# if the exponent value is less than 1, the program will delete the variables below.
del binaryInput #this deletes the binary input
del exponentValue #this deletes the exponent variable
del totalValue #this deletes the totalValue variable
print("Bro, type a value") #this notices if you entered without putting anything and will tell you
#to put something.
main()
for conversion in range(exponentValue): #this is converting the decimal numbers to binary numbers.
if binaryInput[conversion] == "0":
actualValue = 0
elif binaryInput[conversion] == "1":
actualValue = 2
else:
print("Ones or Zeroes my boy, Ones or Zeroes.") #This is telling the user that runs this
#code that if they put anything other than 1's or 0's they will be treated with that message.
del binaryInput #this deletes the binary input
del exponentValue #this deletes the exponent variable
del totalValue #this deletes the totalValue variable
main()
trueValue = actualValue ** (exponentValue -1)#this is doing the math needed for the
#decimals to convert to binary
if actualValue == 0 and exponentValue == 1: #this is asking the code if the
#actualValue and the exponentValue equal there values.
trueValue = 0
exponentValue -= 1 #this is subtracting one from the exponentValue
totalValue += trueValue #this is adding the totalValue and the trueValue
print("The decimal value of {} is {}".format(binaryInput, totalValue)) #This just displays the final
#result of everything
main()