Не уверен, что вы собираетесь делать, но я думаю, что одно из них должно сработать для вас.
bias = 1.04
# Accept two values multiply them and the bias and return one result
def apply_bias(self, first, second):
return (first * second) * bias
# or if you want to accept two values and return a tuple of two results
def apply_bias(self, first, second):
return first * bias, second * bias
Редактировать после прочтения вашего комментария, я думаю, что я понимаю лучше. Попробуйте это:
class Summation:
def __init__(self, first, second, bias=1.04):
self.first = first
self.second = second
self.bias = bias
def summate(self, include_bias=False):
result = self.first + self.second
if not include_bias:
return result
return result * self.bias
def mult(self, include_bias=False):
result = self.first * self.second
if not include_bias:
return result
return result * self.bias
def divis(self, include_bias=False):
result = self.first / self.second
if not include_bias:
return result
return result * self.bias
def diff(self, include_bias=False):
result = self.first - self.second
if not include_bias:
return result
return result * self.bias
def apply_bias(self, bias):
self.bias = bias
def summary(self, include_bias=False):
print(f'Sum = {input_values.summate(include_bias)}')
print(f'Multiplied = {input_values.mult(include_bias)}')
print(f'Divided = {input_values.divis(include_bias)}')
print(f'The difference between the two values is {input_values.diff(include_bias)}')
input_values = Summation(int(input("first:")), int(input("second:")))
input_values.summary()
str_bias = input("bias:")
if str_bias:
input_values.apply_bias(float(str_bias))
input_values.summary(True)
Это напечатало бы то, что вы описываете
first:2
second:2
Sum = 4
Multiplied = 4
Divided = 1.0
The difference between the two values is 0
bias:1.04
Sum = 4.16
Multiplied = 4.16
Divided = 1.04
The difference between the two values is 0.0