DNPotapov / Codewars-katas-

0 stars 0 forks source link

Find the calculation type (7 kyu) #3

Open DNPotapov opened 1 year ago

DNPotapov commented 1 year ago
def calc_type(a, b, res):
    if a+b == res:
        return "addition"
    elif a*b == res:
        return "multiplication"
    elif a-b == res:
        return "subtraction"
    else:
        return "division"
DNPotapov commented 1 year ago

You have to create a function calcType, which receives 3 arguments: 2 numbers, and the result of an unknown operation performed on them (also a number).

Based on those 3 values you have to return a string, that describes which operation was used to get the given result.

The possible return strings are: "addition", "subtraction", "multiplication", "division".

Example: calcT_type(1, 2, 3) --> 1 ? 2 = 3 --> "addition" Notes In case of division you should expect that the result of the operation is obtained by using / operator on the input values - no manual data type conversion or rounding should be performed. Cases with just one possible answers are generated. Only valid arguments will be passed to the function. Only valid arguments will be passed to the function!

DNPotapov commented 1 year ago

https://www.codewars.com/kata/5aca48db188ab3558e0030fa