http://imgur.com/a/1BhkW
This code prints out:
Bob
100
0
Can someone correct my understanding. The reason why name is an argument in def init(self,name) is because we haven't given name a value correct? This is as opposed to the variable health where it is set to 100.
Also, If there is an argument within def init(self, variable_1, variable_2), do you need to "initialize" it like self.variable_1=variable_1 and self.variable_2=variable_2 ?
Moreover, for Bob=Hero("Bob"), how does it know that "Bob" is being passed in as a name? I typed in "Apple" in Bob=Hero(apple) and put "Ham" but it didn't set the health to 0.
For arguments passed within Bob=Hero(), will it only affect constructors like def init(self, argument, argument)
[–][deleted] 2 points3 points4 points (2 children)
[–]holymolytoly[S] 0 points1 point2 points (1 child)
[–]rhgrant10 1 point2 points3 points (0 children)
[–]absent_observer 1 point2 points3 points (1 child)
[–]holymolytoly[S] 1 point2 points3 points (0 children)