我不明白出了什么问题。我一直认为我错过了必要的位置论证。
class CoinToss(object):
def __init__(self, flip, ID_Num, Value):
self.flip = flip
self.ID_Num = ID_Num
self.Value = Value
def Flip(self):
"""
Method is important in determining the number of flips and simulating the coin
"""
data = []
Num_flip = int(input("how many times do you want to flip the coin? :"))
print("the ball at the start: ball: d%, state: d% value: d% " %(self.ID_Num))
for i in range(Num_flip):
self.flip = self.flip = 1
if randint(0,1) == 0:
self.Value = self.Value + 1
data.append(self.value)
else:
self.Value = self.Value - 1
data.append(self.Value)
答案 0 :(得分:2)
显然,当您使用CoinToss
时,只需使用2个参数flip
和ID_NUM
来调用它。这会导致错误,因为您未向CoinToss.__init__()
提供所需的Value
参数。