Ad
Code
Diff
  • def run(Type ,*args):
        if Type == 'add':
            a = 0
            for i in args: a+=i
            return a
        elif Type == 'minum':
            a = 0
            for i in args:
                if a == 0:
                    a+=i
                else:
                    a-=i
            return a
        elif Type == 'multiply':
            a = 1
            for i in args: a =a*i
            return a
        elif Type == 'divide':
            a = args[0]
            for i in args:
                if i == a: pass
                else: a = a//i
            return a
    • add = lambda *args:sum(args)
    • def minum(*args):
    • xxx = args[0]
    • for i in range(1,len(args)):
    • xxx = xxx - args[i]
    • return xxx
    • def multiply(*args):
    • xxx = 1
    • for i in args:
    • xxx = xxx * i
    • return xxx
    • def divide(*args):
    • xxx = args[0]
    • for i in args[1:]:
    • xxx = xxx / i
    • return xxx
    • def run(func,*args):
    • return func(*args)
    • def run(Type ,*args):
    • if Type == 'add':
    • a = 0
    • for i in args: a+=i
    • return a
    • elif Type == 'minum':
    • a = 0
    • for i in args:
    • if a == 0:
    • a+=i
    • else:
    • a-=i
    • return a
    • elif Type == 'multiply':
    • a = 1
    • for i in args: a =a*i
    • return a
    • elif Type == 'divide':
    • a = args[0]
    • for i in args:
    • if i == a: pass
    • else: a = a//i
    • return a