As for classes this week, I feel like the biggest difficulty of recursion for me, is that, though i can understand them step by step, i could not write the code on my own. I hope though intense exercise, I could overcome this problem. Turtle is great fun. Methods: colour, setheading(left/right), forward/backward, speed, hideturtle, clone(). Notably, every recursion should have a base case as how to exit, or would result in an endless cycle.
I don't have a partner for lab this week, so i get to do everything on my own, but it's not actually a bad experience. I get to organize my thoughts and plan everything step independently. I learn how to manipulate a subclass by inheriting specific attribute from parent class.
class Car(Motorized):
def Car(self):
Motorized.__init__(self,*,*,*)
In addition, this is the first time i ever trying writing unittest. just for future reference:
import unitest
class TestSpecficClass(unittest.Testcase):
def setUp(self):
#create a specific object of the class
self.classname = Class(**)
def tearDown(self):
def test_something(self):
self.aseertEqual(call, expected value, error message)
self.assertRaises(CertainError, call the function, give the separate parameter)
self.assertTrue(usually take one parameter)
if __name__=="__main__":
unittest.main(exit=False)
NOTE:
1.exception hierarchy
ValueError
| Exception
| BaseException
| object
2. property function
3. print function
for i in a:
print(i,end=" ")
dsf dsf
for i in a:
print(i,end="")
dsfdsf
Question:
now does super works?
the call
super(self.__class__,self)
is going to return the superclass of certain class