Trouble converting string to float


#1

Can anyone help determine why binary, hexadecimal and not expressions wont work?

class cruncher():

def add(self, operand1, operand2):
    addition = operand1 + operand2
    return addition

def subtract(self,operand1, operand2):
    subtract = operand1 - operand2
    return subtract

def multiply(self,operand1, operand2):
    multiplication = operand1 * operand2
    return multiplication

def power(self,operand1, operand2):
    power_of = operand1 ** operand2
    return power_of

def divide(self,operand1, operand2):
    divided = operand1 / operand2
    return divided

def int_divide(self,operand1 , operand2):
    int_divided = operand1 // operand2
    return int_divided

def modulo(self,operand1, operand2):
    modulod = operand1 % operand2
    return modulod

def hexadecimal(self,operand1, operand2):
    hexadecimals = hex(operand2)
    operand1 = 0
    return hexadecimals

def binary(self,operand1, operand2):
    binarys = bin(operand2) 
    operand1 = 0
    return binarys

def greater_than(self,operand1, operand2):
    greater_then = operand1 > operand2
    return greater_then

def less_than(self,operand1, operand2):
    less_then = operand1 < operand2
    return less_then

def greater_equal(self,operand1, operand2):
    greater_or_equal = operand1 >= operand2
    return greater_or_equal

def less_equal(self,operand1, operand2):
    less_or_equal = operand1 <= operand2
    return less__or_equal

def expression_and(self,operand1, operand2):
    and_expression = operand1 and operand2
    return and_expression

def expression_or(self,operand1, operand2):
    or_expression = operand1 or operand2
    return or_expression

def expression_not(self,operand2):
    not_expression = not operand2
    return not_expression

answer = 0

def dtree(self, operand1,operator,operand2):

    if operator == "+":
        answer = self.add(operand1,operand2)
        return answer

    elif operator == "-":
        answer = self.subtract(operand1,operand2)
        return answer

    elif operator == "*":
        answer = self.multiply(operand1,operand2)
        return answer

    elif operator == "**":
        answer  = self.power(operand1,operand2)
        return answer

    elif operator == "/":
        answer = self.divide(operand1,operand2)
        return answer

    elif operator == "//":
        answer = self.int_divide(operand1,operand2)
        return answer

    elif operator == "%":
        answer = self.modulo(operand1,operand2)
        return answer

    elif operator == "0x":
        answer = self.hex(operand2)
        return answer

    elif operator == "b":
        answer = self.bin(operand2)
        return answer

    elif operator == ">":
        answer = self.greater_than(operand1,operand2)
        return answer

    elif operator == "<":
        answer = self.less_than(operand1,operand2)
        return answer

    elif operator == ">=":
        answer = self.greater_equal(operand1,operand2)
        return answer

    elif operator == "and":
        answer = self.expression_and(operand1,operand2)
        return answer

    elif operator == "<=":
        answer = self.less_equal(operand1,operand2)
        return answer

    elif operator == "or":
        answer = self.expression_or(operand1,operand2)
        return answer

    elif operator == "not":
        answer = self.expression_not(operand2)
        return answer
    else:
        return("Invalid input")

def crunch():

crunch = cruncher()

cal_str = input("Please type your equation (+,-,*,**,/,//,%,0x,bin,>,<,>=,<=,and,or,not)")
cal_list = cal_str.split()
operand1 = cal_list[0]

if cal_list[1] == 'and' or cal_list[1] == 'or' or cal_list[1] == 'not' or cal_list[1] == '0x' or cal_list[1] == 'b':
    operand1 = str(operand1)
else:
    operand1 = float(operand1)




operator = cal_list[1]
operand2 = cal_list[2]


if cal_list[1] == 'and' or cal_list[1] == 'or' or cal_list[1] == 'not' or cal_list[1] == '0x' or cal_list[1] == 'b':
    operand2 = str(operand2)
else:
    operand2 = float(operand2)

    
print(operand1, cal_list[1],operand2)
answer = crunch.dtree(operand1,cal_list[1],operand2)
print(answer)

crunch()