bug while trying to create a function from other functions in python
Question: I have been trying to create a calculator and i had for practical reasons i
tried to import functions from a separate python file. It works at some extent
but it breaks when it tries to do the calculations. The bug is is that the add
is not defined but i did defined it while importing the function. Here is the
code:

    
    
    class Calculator(object):
    
    import a10 as add
    import d10 as div
    import m10 as mult
    import s10 as sub
    
    def choice(self):
        print("A. Addition\l B. Substraction\l C. Division\l D. Multiplication")
        xn = input("What do you want to do? ")
        if xn == "a":
            addition = add.addition
            x = self.addition()
            self.x = x
            return x
        elif xn == "b":
            subtraction = sub.subtraction
            z = self.subtraction()
            self.z = z
            return z
        elif xn == "c":
            division = div.division
            y = self.division()
            self.y = y
            return y
        elif xn == 'd':
            Multiplication = mult.multiplication
            v = self.Multiplication()
            self.v = v
            return v
    
    
    objcalc = Calculator()
    print(objcalc.choice())
    

Here is the a10

    
    
    def addition(self):
    try:
        n = int(input("enter number: "))  
        n_for_add = int(input("What do you want to add on " + str(n) + " ? "))       
    except ValueError: 
        print("you must enter an integer!") 
    n_from_add = n + n_for_add
    print(str(n) + " plus " + str(n_for_add) + " equals to " + str(n_from_add))  
    

s10

    
    
    def subtraction(self):
        try:
            nu = int(input("enter number: "))
            nu_for_sub = int(input("What do you want to take off " + str(nu) + " ? "))
        except ValueError:
            print("you must enter an integer!")
        nu_from_sub = nu - nu_for_sub
        print(str(nu) + " minus " + str(nu_for_sub) + " equals to " + str(nu_from_sub))
    

m10

    
    
    def Multiplication(self):
        try:
            numb = int(input("enter number: "))
            numb_for_multi = int(input("What do you want to multiply " + str(numb) + " on? "))
        except ValueError:
            print("you must enter an integer!")
        numb_from_multi = numb * numb_for_multi
        print(str(numb) + " multiplied by  " + str(numb_for_multi) + " equals to " + str(numb_from_multi))
    

d10

    
    
    def division(self):
        try:
            num = int(input("enter number: "))
            num_for_div = int(input("What do you want to divide " + str(num) + " off? "))
        except ValueError:
            print("you must enter an integer!")
        num_from_div = num / num_for_div
        print(str(num) + " divided by " + str(num_for_div) + " equals to " + str(num_from_div))
    


Answer: In the `if` statements, like this:

    
    
    if xn == "a":
        addition = add.addition
        x = self.addition()
        self.x = x
        return x
    

`addition` is created as a variable local to the function `choice`, but you're
then setting `x` to be `self.addition()`, which isn't defined.

If you mean to write `x = add.addition()` then be warned that your `addition`
function doesn't return anything, it just prints out a value. The same for the
other functions - none of them return anything. So `self.addition` is not
defined, and `x` will be a `NoneType` object

Your `addition`, `subtraction` and other functions also take `self` as an
argument, when they're not methods in a class, so this doesn't make much
sense.

