Something in common

Report a typo

In the code template below, you can see two functions that represent different mathematical processes. However, there is a line of code repeated in both of these functions. Since this part of code does the same thing in both functions, it can be moved from these functions into another separate function.

Find this line of code and create a function with it. Name this function common_part. For now, you may leave the existing functions unchanged.

You do NOT need to work with the input or call any functions.

Tip: Don't forget that your function should also have an argument.

Write a program in Python 3
def calculate_linear(k, b, x):
y = k * x + b
print("Value of the function equals", y)
return y


def calculate_quadratic(a, b, c, x):
y = (a * x * x) + (b * x) + c
print("Value of the function equals", y)
return y


# create function common_part
___

Create a free account to access the full topic