The result variable in computer programming doesn't work.

Asked 1 months ago, Updated 1 months ago, 4 views

I created a program that allows me to do simple calculations with python 3 and save up to 10 calculations in a list, and save the answers after the 10th one from the beginning, but no matter how many times I re-programmed it,

name 'result' is not defined

The only error was that the and result variables were not defined.I thought, "Did I forget to define the result?" and checked the code several times, but I didn't find any particular definition errors or errors in the variables in the module.
Please tell me where you forgot to define the result variable in this code, or what is wrong with the variable

 answerlist=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    counter = 1

    defdecideprocess():
        global decision
        decision=str(input("Enter+for adding, -for subtraction, *for multiply, /for deviding, and 'all' for see what all calculation results so far.:"))

    default processes (result):
        global decision
        global counter
        decision=decideprocess()
        while decision=="+" or decision=="-" or decision=="*" or decision=="/" or decision=="all":
            if decision=="+":
                result=addition()
                decideprocess()

                return counter

            elif decision=="-":
                result=subtraction()
                decideprocess()

                return counter

            elif decision=="*":
                result=multiplecation()
                decideprocess()

                return counter

            elif decision=="/":
                result=device()
                decideprocess()

                return counter

            elif decision=="all":
                for a range(0,len(answerlist)):
                    print(answerlist[a])
                decideprocess()

            else:
                showallresult()

        return result

    default():
        global counter
        a=float(input("Enter any number.":")
        b=float(input("Enter any number.":")
        result=a+b
        print(result)
        counter=counter+1
        assignment(result)

        return(result)

    def subtraction():
        global counter
        a=float(input("Enter any number.":")
        b=float(input("Enter any number.":")
        result = a-b
        print(result)
        counter=counter+1
        assignment(result)


        return result

    default multiplexing():
        global counter
        a=float(input("Enter any number.":")
        b=float(input("Enter any number.":")
        result=a*b
        print(result)
        counter=counter+1
        assignment(result)


        return result

    def deviation():
        global counter
        a=float(input("Enter any number.":")
        b=float(input("Enter any number.":")
        result = a/b
        print(result)
        counter=counter+1
        assignment(result)


        return result

    default assignment(result):
        global counter
        while counter <10:
            assignmentanswer (result)
        if counter>=10:
            changecountervalue()
            assignmentanswerover 10 (result, newcounter)

        return result, newcounter

    defaultassignmentanswer(result):
        global counter
        answerlist [counter] = result

        return result

    def changecountervalue():
        global counter
        counter10 = int (counter/10)
        newcounter=(counter10*10) - counter

        return newcounter

    default assignmentanswerover 10 (result, newcounter):
        answerlist [newcounter] = result

        return result, newcounter

    default showallresult():
        for a range(0,len(answerlist)):
            print(answerlist[a])

    default calculator(result):
        global counter
        global decision
        processes(result)

        return result

    default CALCULATOR(result):
        calculator(result)

        return result



CALCULATOR (result) 

python python3

2022-09-30 11:15

1 Answers

Please tell me where you forgot to define the result variable in this code, or what is wrong with the variable

Last line

CALCULATOR(result) 

The argument result is undefined.


2022-09-30 11:15

If you have any answers or tips


© 2022 OneMinuteCode. All rights reserved.