Category : methods

I have code class Render(): def __init__(self): pass def init_screen(self, h, w): raise NotImplementedError def add_object(self, char, x, y): raise NotImplementedError def draw_screen(self): raise NotImplementedError def get_input(self): raise NotImplementedError there is a task: I need to create a ShellRenderer class that will draw the game screen in the console. -Create a _screen field in it, ..

Read more

class PlayingCard: # constructor def __init__(self, rankNum, suitNum): self.rank = rankNum self.suit = suitNum def __str__(self): return "{} of {}".format(self.rank, self.suit) def getRank(self): if self.rank == 11: return "Jacks" elif self.rank == 12: return "Queen" elif self.rank == 13: return "King" elif self.rank == 14: return "Ace" else: return self.rank def getSuit(self): if self.suit == ..

Read more

my problem is that I need to use the return value of a method inside of a class into another method with a different input argument in the same class as the below code: In Sofmax class, the return value of forward method (probs) is needed in backward method. I tried self.forward(self.x) but it doesn’t ..

Read more

I get this error and I do not know how solve them Blockquote def f(x): return x**3-x-2 def bisection(f,a,b,app=0.3): Fa,Fb=f(a),f(b) if Fa*Fb>0: raise Exception(‘Fails’) for i in range(a,b): x=(a+b)/2 if f*Fa>0: a=x else: b=x return x print(bisection(f,{‘a’:1,’b’:2},0.00003)) Blockquote runfile(‘/Users/mashaelsaad/untitled0.py’, wdir=’/Users/mashaelsaad’) Traceback (most recent call last): File "/Users/mashaelsaad/untitled0.py", line 26, in print(bisection(f,{‘a’:1,’b’:2},0.00003)) File "/Users/mashaelsaad/untitled0.py", line 14, ..

Read more